forked from Tuhinshubhra/CMSeeK
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmseek.py
194 lines (183 loc) · 6.51 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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
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 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')
args = parser.parse_args()
if args.clear_result:
cmseek.clear_log()
if args.help:
cmseek.help()
if args.verbose:
cmseek.verbose = True
if args.update:
cmseek.update()
if args.version:
print('\n\n')
cmseek.info("CMSeeK Version: " + cmseek.cmseek_version)
cmseek.bye()
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)'
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:
ot = open(sites, 'r')
file_contents = ot.read().replace('\n','')
sites_list = file_contents.split(',')
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:
target = cmseek.process_url(s)
if target != '0':
core.main_proc(target,cua)
cmseek.handle_quit(False)
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("")
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(http://1.com,https://2.org) or enter path of file containing URLs (comma separated): ')
if 'http' not in sites or '://' not in sites:
cmseek.info('Treating input as path')
try:
ot = open(sites, 'r')
file_contents = ot.read().replace('\n','')
sites_list = file_contents.split(',')
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:
target = cmseek.process_url(s)
if target != '0':
core.main_proc(target,cua)
cmseek.handle_quit(False)
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.getcwd() + "/cmsbrute"
brute_cache = 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)
read_cache = open(brute_cache, 'r')
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()