-
Notifications
You must be signed in to change notification settings - Fork 499
/
cmseek.py
263 lines (235 loc) · 8.91 KB
/
cmseek.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2018 - 2020 Tuhinshubhra
import sys
## for people who don't bother reading the readme :/
if sys.version_info[0] < 3:
print("\nPython3 is needed to run CMSeeK, Try \"python3 cmseek.py\" instead\n")
sys.exit(2)
import os
import argparse
import json
import importlib
import cmseekdb.basic as cmseek # All the basic functions
import cmseekdb.core as core
import cmseekdb.createindex as createindex
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
parser = argparse.ArgumentParser(prog='cmseek.py',add_help=False)
parser.add_argument('-h', '--help', action="store_true")
parser.add_argument('-v', '--verbose', action="store_true")
parser.add_argument("--version", action="store_true")
parser.add_argument("--update", action="store_true")
parser.add_argument('-r', "--random-agent", action="store_true")
parser.add_argument('--user-agent')
parser.add_argument('--googlebot', action="store_true")
parser.add_argument('-u', '--url')
parser.add_argument('-l', '--list')
parser.add_argument('--clear-result', action='store_true')
parser.add_argument('--follow-redirect', action='store_true')
parser.add_argument('--no-redirect', action='store_true')
parser.add_argument('--batch', action="store_true")
parser.add_argument('-i', '--ignore-cms')
parser.add_argument('--strict-cms')
parser.add_argument('--skip-scanned', action="store_true")
parser.add_argument('--light-scan', action="store_true")
parser.add_argument('-o', '--only-cms', action="store_true")
args = parser.parse_args()
if args.clear_result:
cmseek.clear_log()
if args.help:
cmseek.help()
if args.light_scan:
# Suggestion #99
cmseek.light_scan = True
if args.only_cms:
# Suggestion #99
cmseek.only_cms = True
if args.verbose:
cmseek.verbose = True
if args.skip_scanned:
cmseek.skip_scanned = True
if args.follow_redirect:
cmseek.redirect_conf = '1'
if args.no_redirect:
cmseek.redirect_conf = '2'
if args.update:
cmseek.update()
if args.batch:
#print('Batch true')
cmseek.batch_mode = True
print(cmseek.batch_mode)
if args.version:
print('\n\n')
cmseek.info("CMSeeK Version: " + cmseek.cmseek_version)
cmseek.bye()
if args.ignore_cms:
cmseek.ignore_cms = args.ignore_cms.split(',')
for acms in cmseek.ignore_cms:
cmseek.warning('Ignoring CMS: ' + acms)
if args.strict_cms:
cmseek.strict_cms = args.strict_cms.split(',')
cmseek.warning('Checking target against CMSes: ' + args.strict_cms)
if args.user_agent is not None:
cua = args.user_agent
elif args.random_agent is not None:
cua = cmseek.randomua('random')
else:
cua = None
if args.googlebot:
cua = 'Googlebot/2.1 (+http://www.google.com/bot.html)'
# Update report index
index_status = createindex.init(cmseek.access_directory)
if index_status[0] != '1':
# might be too extreme
# cmseek.handle_quit()
if not cmseek.batch_mode:
input('There was an error while creating result index! Some features might not work as intended. Press [ENTER] to continue:')
if args.url is not None:
s = args.url
target = cmseek.process_url(s)
if target != '0':
if cua == None:
cua = cmseek.randomua()
core.main_proc(target,cua)
cmseek.handle_quit()
elif args.list is not None:
sites = args.list
cmseek.clearscreen()
cmseek.banner("CMS Detection And Deep Scan")
sites_list = []
try:
with open(sites, 'r') as ot:
file_contents = ot.read()
if "," in file_contents: # if comma separated URLs list
file_contents = file_contents.replace('\n','')
sites_list = file_contents.split(',')
else: # if one per line URLs list
sites_list = file_contents.splitlines()
except FileNotFoundError:
cmseek.error('Invalid path! CMSeeK is quitting')
cmseek.bye()
if sites_list != []:
if cua == None:
cua = cmseek.randomua()
for s in sites_list:
s = s.replace(' ', '')
target = cmseek.process_url(s)
if target != '0':
core.main_proc(target,cua)
cmseek.handle_quit(False)
if not cmseek.batch_mode:
input('\n\n\tPress ' + cmseek.bold + cmseek.fgreen + '[ENTER]' + cmseek.cln + ' to continue') # maybe a fix? idk
else:
print('\n')
cmseek.warning('Invalid URL: ' + cmseek.bold + s + cmseek.cln + ' Skipping to next')
print('\n')
cmseek.result('Finished Scanning all targets.. result has been saved under respective target directories','')
else:
cmseek.error("No url provided... CMSeeK is exiting")
cmseek.bye()
################################
### THE MAIN MENU ###
################################
cmseek.clearscreen()
cmseek.banner("Tip: You can use cmseek via arguments as well check the help menu for more information")
print (" Input Description")
print ("======= ==============================")
print (" [1] CMS detection and Deep scan")
print (" [2] Scan Multiple Sites")
print (" [3] Bruteforce CMSs")
print (" [U] Update CMSeeK")
print (" [R] Rebuild Cache (Use only when you add any custom module)")
print (" [0] Exit CMSeeK :( \n")
selone = input("Enter Your Desired Option: ").lower()
if selone == 'r':
cmseek.update_brute_cache()
elif selone == 'u':
cmseek.update()
elif selone == '0':
cmseek.bye()
elif selone == "1":
# There goes the cms detection thingy
cmseek.clearscreen()
cmseek.banner("CMS Detection And Deep Scan")
site = cmseek.targetinp("") # Get The User input
if cua == None:
cua = cmseek.randomua()
core.main_proc(site,cua)
cmseek.handle_quit()
elif selone == '2':
cmseek.clearscreen()
cmseek.banner("CMS Detection And Deep Scan")
sites_list = []
sites = input('Enter comma separated URLs without spaces (http://site1.com,https://site2.org)\nOr enter path of file containing URLs (comma separated or one-per-line):')
if ('http' not in sites or '://' not in sites) and "," not in sites: # because if comma in Input() then its probably comma-separated list
cmseek.info('Treating input as path')
try:
with open(sites, 'r') as ot:
file_contents = ot.read()
if "," in file_contents: # if comma separated URLs list
file_contents = file_contents.replace('\n','')
sites_list = file_contents.split(',')
else: # if one per line URLs list
sites_list = file_contents.splitlines()
except FileNotFoundError:
cmseek.error('Invalid path! CMSeeK is quitting')
cmseek.bye()
else:
cmseek.info('Treating input as URL list')
sites_list = sites.split(',')
if sites_list != []:
if cua == None:
cua = cmseek.randomua()
for s in sites_list:
s = s.replace(' ', '')
target = cmseek.process_url(s)
if target != '0':
core.main_proc(target,cua)
cmseek.handle_quit(False)
if not cmseek.batch_mode:
input('\n\n\tPress ' + cmseek.bold + cmseek.fgreen + '[ENTER]' + cmseek.cln + ' to continue') # maybe a fix? idk
else:
print('\n')
cmseek.warning('Invalid URL: ' + cmseek.bold + s + cmseek.cln + ' Skipping to next')
print('\n')
cmseek.result('Finished Scanning all targets.. result has been saved under respective target directories','')
else:
cmseek.error("No url provided... CMSeeK is exiting")
cmseek.bye()
elif selone == "3":
cmseek.clearscreen()
cmseek.banner("CMS Bruteforce Module")
## I think this is a modular approch
brute_dir = os.path.join(cmseek.cmseek_dir, 'cmsbrute')
brute_cache = os.path.join(brute_dir, 'cache.json')
if not os.path.isdir(brute_dir):
cmseek.error("bruteforce directory missing! did you mess up with it? Anyways CMSeek is exiting")
cmseek.bye()
else:
print ("[#] List of CMSs: \n")
print (cmseek.bold)
with open(brute_cache, 'r') as read_cache:
b_cache = read_cache.read()
cache = json.loads(b_cache)
brute_list = []
for c in cache:
brute_list.append(c)
brute_list = sorted(brute_list)
for i,x in enumerate(brute_list):
n = x
mod = "cmsbrute." + x
exec(n + " = importlib.import_module(mod)")
print('['+ str(i) +'] ' + cache[x])
print(cmseek.cln + '\n')
cmstobrute = input('Select CMS: ')
try:
kek = brute_list[int(cmstobrute)]
print(kek)
cms_brute = getattr(locals().get(kek), 'start')
cms_brute()
except IndexError:
cmseek.error('Invalid Input!')
else:
cmseek.error("Invalid Input!")
cmseek.bye()