Skip to content

Commit 36db934

Browse files
committed
Core Update
1 parent 2c496a8 commit 36db934

File tree

4 files changed

+105
-154
lines changed

4 files changed

+105
-154
lines changed

CHANGELOG

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Version 1.0.5 [19-07-2018]
22
- version detection for drupal added
33
- fixed '/' error in url
44
- added a detection method for drupal
5+
- Core updated to make it smaller and faster
6+
- removed multiprocessing with multithreading now cmseek runs on almost all devices
57
- other minor fixes
68
Version 1.0.4 [17-07-2018]
79
- added joomla deep scan and version detection

cmseekdb/core.py

+87-138
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Core Rev 2, small and sexy
2+
13
import sys
24
import os
35
import http.client
@@ -31,144 +33,91 @@ def main_proc(site,cua):
3133
follow_redir = input('[#] Set ' + cmseek.bold + cmseek.fgreen + init_source[3] + cmseek.cln + ' as target? (y/n): ')
3234
if follow_redir.lower() == 'y':
3335
site = init_source[3]
36+
if scode == '':
37+
# silly little check thought it'd come handy
38+
cmseek.error('Aborting detection, source code empty')
39+
return
40+
3441
cmseek.statement("Detection Started")
35-
cmseek.statement("Using headers to detect CMS (Stage 1 of 2)")
36-
c1 = header.check(headers)
37-
if c1[0] == "1":
38-
# Do this shit later
39-
cmseek.success("CMS Detected, CMS ID: \"%s\" - looking up database for CMS information" % c1[1])
40-
cmseek.update_log('detection_param','header') # update log
41-
cmseek.update_log('cms_id',c1[1]) # update log
42-
cka = getattr(cmsdb, c1[1])
43-
if cka['deeps'] != '1': # Deep Scan
44-
if cka['vd'] != '1': # Version Detection not available for the cms show basic stuff
45-
print('\n')
46-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
47-
cmseek.update_log('cms_name',cka['name']) # update log
48-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
49-
cmseek.update_log('cms_url',cka['url']) # update log
50-
else:
51-
cmseek.statement("CMS Version is detectable, detecting CMS Version")
52-
### Detect version
53-
cms_version = version_detect.start(c1[1], site, cua, '1', scode)
54-
print('\n')
55-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
56-
cmseek.update_log('cms_name',cka['name']) # update log
57-
if cms_version != '0':
58-
cmseek.result('',"CMS Version: " + cmseek.bold + cmseek.fgreen + cms_version + cmseek.cln)
59-
cmseek.update_log('cms_version',cms_version) # update log
60-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
61-
cmseek.update_log('cms_url',cka['url']) # update log
62-
# return
63-
else:
64-
advanced.start(c1[1], site, cua, '2', scode) ## The 2 suggests that generator check has not been performed
42+
43+
## init variables
44+
cms = '' # the cms id if detected
45+
cms_detected = '0' # self explanotory
46+
detection_method = '' # ^
47+
ga = '0' # is generator available
48+
if 'generator' in scode or 'Generator' in scode:
49+
ga = '1'
50+
51+
cmseek.statement("Using headers to detect CMS (Stage 1 of 3)")
52+
header_detection = header.check(headers)
53+
if header_detection[0] == '1':
54+
detection_method = 'header'
55+
cms = header_detection[1]
56+
cms_detected = '1'
57+
if cms_detected == '0' and ga == '1':
58+
# cms detection via generator
59+
cmseek.statement("Using Generator meta tag to detect CMS (Stage 2 of 3)")
60+
gen_detection = source.generator(scode)
61+
if gen_detection[0] == '1':
62+
detection_method = 'generator'
63+
cms = gen_detection[1]
64+
cms_detected = '1'
6565
else:
66-
cmseek.warning('No luck with headers... Continuing with source code')
67-
cmseek.statement("Checking for generator meta tag in source code")
68-
if 'Generator' in scode or 'generator' in scode:
69-
cmseek.success("Generator meta tag found.. Continuing with detection (2.1 of 2.2)")
70-
ga = "1" ## Generator tag found .. this will come in handy later to save us some milliseconds ;)
71-
c21 = source.generator(scode)
72-
if c21[0] == '1':
73-
cmseek.success("CMS Detected, CMS ID: \"%s\" - looking up database for CMS information" % c21[1])
74-
cmseek.update_log('detection_param','generator') # update log
75-
cmseek.update_log('cms_id',c21[1]) # update log
76-
cka = getattr(cmsdb, c21[1])
77-
if cka['deeps'] != '1': # Deep Scan not available
78-
if cka['vd'] != '1': # Version Detection not available for the cms show basic stuff
79-
print('\n')
80-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
81-
cmseek.update_log('cms_name',cka['name']) # update log
82-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
83-
cmseek.update_log('cms_url',cka['url']) # update log
84-
else:
85-
cmseek.statement("CMS Version is detectable, detecting CMS Version")
86-
### Detect version
87-
cms_version = version_detect.start(c21[1], site, cua, '1', scode)
88-
print('\n')
89-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
90-
cmseek.update_log('cms_name',cka['name']) # update log
91-
if cms_version != '0':
92-
cmseek.result('',"CMS Version: " + cmseek.bold + cmseek.fgreen + cms_version + cmseek.cln)
93-
cmseek.update_log('cms_version',cms_version) # update log
94-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
95-
cmseek.update_log('cms_url',cka['url']) # update log
96-
# return
97-
else:
98-
advanced.start(c21[1], site, cua, '1', scode)
99-
elif c21[0] == '2': # Empty Source code
100-
cmseek.error("Source code was empty... exiting CMSeek")
101-
# return
102-
else: ## CMS Detection unsuccessful via generator meta tag
103-
cmseek.warning('Could not detect CMS from the generator meta tag, (Procceeding with scan 2.2 of 2.2)')
104-
c22 = source.check(scode, site)
105-
if c22[0] == '1':
106-
cmseek.success("CMS Detected, CMS ID: \"%s\" - looking up database for CMS information" % c22[1])
107-
cmseek.update_log('detection_param','source') # update log
108-
cmseek.update_log('cms_id',c22[1]) # update log
109-
cka = getattr(cmsdb, c22[1])
110-
if cka['deeps'] != '1': # Deep Scan not available
111-
if cka['vd'] != '1': # Version Detection not available for the cms show basic stuff
112-
print('\n')
113-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
114-
cmseek.update_log('cms_name',cka['name']) # update log
115-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
116-
cmseek.update_log('cms_url',cka['url']) # update log
117-
else:
118-
cmseek.statement("CMS Version is detectable, detecting CMS Version")
119-
cms_version = version_detect.start(c22[1], site, cua, '1', scode)
120-
### Detect version
121-
print('\n')
122-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
123-
cmseek.update_log('cms_name',cka['name']) # update log
124-
if cms_version != '0':
125-
cmseek.result('',"CMS Version: " + cmseek.bold + cmseek.fgreen + cms_version + cmseek.cln)
126-
cmseek.update_log('cms_version',cms_version) # update log
127-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
128-
cmseek.update_log('cms_url',cka['url']) # update log
129-
return
130-
else:
131-
advanced.start(c22[1], site, cua, '1', scode)
132-
elif c22[0] == '2': # Empty Source code
133-
cmseek.error("Source code was empty... exiting CMSeek")
134-
return
135-
else:
136-
cmseek.error("Couldn't detect cms... :( \n Sorry master didn't mean to dissapoint but bye for now \n Can't handle this much disappintment \n\n")
137-
return
66+
# Check cms using source code
67+
cmseek.statement("Using source code to detect CMS (Stage 3 of 3)")
68+
source_check = source.check(scode, site)
69+
if source_check[0] == '1':
70+
detection_method = 'source'
71+
cms = source_check[1]
72+
cms_detected = '1'
73+
74+
if cms_detected == '1':
75+
cmseek.success('CMS Detected, CMS ID: ' + cmseek.bold + cms + cmseek.cln + ', Detection method: ' + cmseek.bold + detection_method + cmseek.cln)
76+
cmseek.update_log('detection_param', detection_method)
77+
cmseek.update_log('cms_id', cms) # update log
78+
cmseek.statement('Getting CMS info from databse')
79+
cms_info = getattr(cmsdb, cms)
80+
if cms_info['deeps'] == '1':
81+
# cmseek.success('Starting ' + cmseek.bold + cms_info['name'] + ' deep scan' + cmseek.cln)
82+
advanced.start(cms, site, cua, ga, scode)
83+
return
84+
elif cms_info['vd'] == '1':
85+
cmseek.success('Version detection available')
86+
cms_version = version_detect.start(cms, site, cua, ga, scode)
87+
cmseek.clearscreen()
88+
cmseek.banner("CMS Scan Results")
89+
cmseek.result('Target: ', site)
90+
cmseek.result("Detected CMS: ", cms_info['name'])
91+
cmseek.update_log('cms_name', cms_info['name']) # update log
92+
if cms_version != '0':
93+
cmseek.result("CMS Version: ", cms_version)
94+
cmseek.update_log('cms_version', cms_version) # update log
95+
cmseek.result("CMS URL: ", cms_info['url'])
96+
cmseek.update_log('cms_url', cms_info['url']) # update log
97+
return
13898
else:
139-
cmseek.warning("Generator meta tag not found! (Procceeding with scan 2.2 of 2.2)")
140-
ga = '0' ## Generator meta tag not found as i freakin said earlier this will come in handy later
141-
c22 = source.check(scode, site)
142-
if c22[0] == '1':
143-
cmseek.success("CMS Detected, CMS ID: \"%s\" - looking up database for CMS information" % c22[1])
144-
cmseek.update_log('detection_param','source') # update log
145-
cmseek.update_log('cms_id',c22[1]) # update log
146-
cka = getattr(cmsdb, c22[1])
147-
if cka['deeps'] != '1': # Deep Scan not available
148-
if cka['vd'] != '1': # Version Detection not available for the cms show basic stuff
149-
print('\n')
150-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
151-
cmseek.update_log('cms_name',cka['name']) # update log
152-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
153-
cmseek.update_log('cms_url',cka['url']) # update log
154-
else:
155-
cmseek.statement("CMS Version is detectable, detecting CMS Version")
156-
cms_version = version_detect.start(c22[1], site, cua, '0', scode)
157-
### Detect version
158-
print('\n')
159-
cmseek.result('',"CMS Name: " + cmseek.bold + cmseek.fgreen + cka['name'] + cmseek.cln)
160-
cmseek.update_log('cms_name',cka['name']) # update log
161-
if cms_version != '0':
162-
cmseek.result('',"CMS Version: " + cmseek.bold + cmseek.fgreen + cms_version + cmseek.cln)
163-
cmseek.update_log('cms_version',cms_version) # update log
164-
cmseek.result('',"CMS Link: " + cmseek.bold + cmseek.fgreen + cka['url'] + cmseek.cln)
165-
cmseek.update_log('cms_url',cka['url']) # update log
166-
return
167-
else:
168-
advanced.start(c22[1], site, cua, '0', scode)
169-
elif c22[0] == '2': # Empty Source code
170-
cmseek.error("Source code was empty... exiting CMSeek")
171-
return
172-
else:
173-
cmseek.error("Couldn't detect cms... :( \n Sorry master didn't mean to dissapoint but bye for now \n Can't handle this much disappintment \n\n")
174-
return
99+
# nor version detect neither DeepScan available
100+
cmseek.clearscreen()
101+
cmseek.banner("CMS Scan Results")
102+
cmseek.result('Target: ', site)
103+
cmseek.result("Detected CMS: ", cms_info['name'])
104+
cmseek.update_log('cms_name', cms_info['name']) # update log
105+
cmseek.result("CMS URL: ", cms_info['url'])
106+
cmseek.update_log('cms_url', cms_info['url']) # update log
107+
return
108+
else:
109+
print('\n')
110+
cmseek.error('CMS Detection failed, if you know the cms please help me improve CMSeeK by reporting the cms along with the target by creating an issue')
111+
print('''
112+
{2}Create issue:{3} https://github.com/Tuhinshubhra/CMSeeK/issues/new
113+
114+
{4}Title:{5} [SUGGESTION] CMS detction failed!
115+
{6}Content:{7}
116+
- CMSeeK Version: {0}
117+
- Target: {1}
118+
- Probable CMS: <name and/or cms url>
119+
120+
N.B: Create issue only if you are sure, please avoid spamming!
121+
'''.format(cmseek.cmseek_version, site, cmseek.bold, cmseek.cln, cmseek.bold, cmseek.cln, cmseek.bold, cmseek.cln))
122+
return
123+
return

cmseekdb/sc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ def check(s, site): ## Check if no generator meta tag available
140140
r = ['1', 'dru']
141141
return r
142142

143-
elif 'Joomla' in hstring: # Lamest one possible
144-
# Obvious Joomla
145-
r = ['1','joom']
146-
return r
143+
# elif 'Joomla' in hstring: # Lamest one possible
144+
# # Obvious Joomla
145+
# r = ['1','joom']
146+
# return r
147147

148148
elif 'Powered By <a href="http://www.opencart.com">OpenCart' in hstring or "catalog/view/javascript/jquery/swiper/css/opencart.css" in hstring or 'index.php?route=' in hstring:
149149
# OpenCart

deepscans/wp/userenum.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import cmseekdb.basic as cmseek ## Good old module
22
import re ## Comes in handy while detecting version
33
import json ## For parsing the wpvulndb result
4-
import multiprocessing ## Let's speed things up a lil bit (actually a hell lot faster) shell we?
5-
from functools import partial ## needed somewhere :/
4+
import threading
5+
6+
wpparamuser = []
67

78
def wpauthorenum(ua, url, param):
89
## WordPress function for Collecting usernames from author Parameter
910
## Had to create a different function to avoid some pickle issues
11+
global wpparamuser
1012
param = param + 1
1113
i = str(param)
1214
# cmseek.statement('Checking for ?author=' + i) # Looks Ugly.. enable if you want over verbose result
@@ -15,12 +17,12 @@ def wpauthorenum(ua, url, param):
1517
author = re.findall(r'/author/(.*?)/', str(authorsrc[3]))
1618
if author != []:
1719
cmseek.success('Found user from redirection: ' + cmseek.fgreen + cmseek.bold + author[0] + cmseek.cln)
18-
return author[0]
20+
wpparamuser.append(author[0])
1921
elif authorsrc[0] == '1' and '/author/' in authorsrc[1]:
2022
author = re.findall(r'/author/(.*?)/', str(authorsrc[1]))
2123
if author != []:
2224
cmseek.success('Found user from source code: ' + cmseek.fgreen + cmseek.bold + author[0] + cmseek.cln)
23-
return author[0]
25+
wpparamuser.append(author[0])
2426

2527
def start(id, url, ua, ga, source):
2628
cmseek.info("Starting Username Harvest")
@@ -53,15 +55,13 @@ def start(id, url, ua, ga, source):
5355

5456
# the regular way of checking vua user Parameter -- For now just check upto 20 ids
5557
cmseek.info('Harvesting usernames from wordpress author Parameter')
56-
wpparamuser = []
5758
usrrange = range(31)
58-
pool = multiprocessing.Pool()
59-
prepareenum = partial(wpauthorenum, ua, url)
60-
res = pool.map(prepareenum,usrrange)
61-
for r in res:
62-
if r != None:
63-
wpparamuser.append(r)
64-
59+
threads = [threading.Thread(target=wpauthorenum, args=(ua,url,r)) for r in usrrange]
60+
for thread in threads:
61+
thread.start()
62+
for thread in threads:
63+
thread.join()
64+
global wpparamuser
6565
# Combine all the usernames that we collected
6666
usernames = set(wpjsonuser+jpapiuser+wpparamuser)
6767
if len(usernames) > 0:

0 commit comments

Comments
 (0)