1
1
import os
2
+ import random
3
+ import shutil
4
+ import string
5
+
2
6
import fire
3
7
import datetime
4
8
from loguru import logger
17
21
red = '\033 [1;31m'
18
22
end = '\033 [0m'
19
23
20
- version = 'v1.0 '
24
+ version = 'v1.1 '
21
25
message = white + '{' + red + version + ' #dev' + white + '}'
22
26
23
27
banner = f"""
@@ -49,10 +53,19 @@ class Komo(object):
49
53
50
54
mode:
51
55
install Download the required tools
52
- all all scan and attack
56
+ all all scan and attack:subdomain, survival detection, finger, portscan, email collect, sensitive(crawl urls), pocscan, Weak password scanning, to_xray
57
+ --domain one domain
58
+ --domains a domain file
59
+ all2 run scan and attack except domain collection: survival detection, finger, portscan, email collect, sensitive(crawl urls), pocscan, Weak password scanning, to_xray
60
+ --subdomain one subdomain
61
+ --subdomains a subdomain file
62
+ collect run all collection modules :subdomain, survival detection, finger, port, email collect, sensitive(crawl urls), pocscan, to_xray
53
63
--domain one domain
54
64
--domains a domain file
55
- collect run all collection modules :subdomain, finger, port, sensitive, poc, to_xray
65
+ collect1 run collection modules :subdomain, survival detection, finger
66
+ --domain one domain
67
+ --domains a domain file
68
+ collect2 run collection modules :subdomain, survival detection, finger, portscan
56
69
--domain one domain
57
70
--domains a domain file
58
71
subdomain only collect subdomain
@@ -67,28 +80,42 @@ class Komo(object):
67
80
sensitive only collect directory with crawl,email
68
81
--url one url
69
82
--urls an urls file
70
- webattack only attack web from url or urls
83
+ webattack only attack web from url or urls: pocscan, Weak password scanning, crawl urls to xray
84
+ --url one url
85
+ --urls an urls file
86
+ webattack2 only poc scan from url or urls: pocscan, Weak password scanning
71
87
--url one url
72
88
--urls an urls file
73
89
hostattack only attack ip from ip or ips
74
90
--ip one ip
75
91
--ips an ips file
92
+ attack run webattack and hostattack: crawl url to xray, pocscan, Weak password scanning
93
+
76
94
77
95
Example:
78
96
python3 Komo.py install
79
97
python3 Komo.py --domain example.com all
80
98
python3 Komo.py --domains ./domains.txt all
81
99
python3 Komo.py --domain example.com collect
82
100
python3 Komo.py --domains ./domains.txt collect
101
+ python3 Komo.py --domain example.com collect1
102
+ python3 Komo.py --domains ./domains.txt collect1
103
+ python3 Komo.py --domain example.com collect2
104
+ python3 Komo.py --domains ./domains.txt collect2
83
105
python3 Komo.py --domain example.com subdomain
84
106
python3 Komo.py --domains ./domains.txt subdomain
85
107
108
+ python3 Komo.py --subdomain aaa.example.com all2
109
+ python3 Komo.py --subdomains ./subdomains.txt all2
110
+
86
111
python3 Komo.py --url http://example.com finger
87
112
python3 Komo.py --urls ./urls.txt finger
88
113
python3 Komo.py --url http://example.com sensitive
89
114
python3 Komo.py --urls ./urls.txt sensitive
90
115
python3 Komo.py --url http://example.com webattack
91
116
python3 Komo.py --urls ./urls.txt webattack
117
+ python3 Komo.py --url http://example.com webattack2
118
+ python3 Komo.py --urls ./urls.txt webattack2
92
119
93
120
python3 Komo.py --ip example.com portscan
94
121
python3 Komo.py --ips ./domains.txt portscan
@@ -98,18 +125,24 @@ class Komo(object):
98
125
99
126
:param domain:
100
127
:param domains:
128
+ :param subdomain:
129
+ :param subdomains:
101
130
:param url:
102
- :param urlsfile :
131
+ :param urls :
103
132
:param ip:
104
133
:param ips:
105
134
:param attackflag:
135
+ :param date:
106
136
'''
107
137
108
- def __init__ (self , domain = None , domains = None , url = None , urls = None , ip = None , ips = None , attackflag = False , date = None ):
138
+ def __init__ (self , domain = None , domains = None , subdomain = None , subdomains = None , url = None , urls = None , ip = None ,
139
+ ips = None , attackflag = False , date = None ):
109
140
110
141
date1 = str (datetime .datetime .now ().strftime ("%Y-%m-%d-%H-%M-%S" ))
111
142
self .domain = domain
112
143
self .domains = domains # domainsfile
144
+ self .subdomain = subdomain
145
+ self .subdomains = subdomains
113
146
self .url = url
114
147
self .urlsfile = urls
115
148
self .ip = ip
@@ -119,6 +152,11 @@ def __init__(self, domain=None, domains=None, url=None, urls=None, ip=None, ips=
119
152
self .domains_list = []
120
153
create_logfile ()
121
154
print (banner )
155
+ self .randomstr = '' .join (random .sample (string .ascii_letters + string .digits , 16 ))
156
+ # 创建结果文件夹
157
+ self .result_folder = f"result/{ self .date } "
158
+ if os .path .exists (self .result_folder ) is False :
159
+ os .makedirs (self .result_folder )
122
160
123
161
if self .domain and self .domains is None :
124
162
self .domains_list .append (self .domain )
@@ -128,6 +166,32 @@ def __init__(self, domain=None, domains=None, url=None, urls=None, ip=None, ips=
128
166
line = line .strip ()
129
167
self .domains_list .append (line )
130
168
self .domains_list = list (set (self .domains_list ))
169
+ elif self .subdomain and self .subdomains is None :
170
+ with open (f"result/{ self .date } /{ self .randomstr } .final.subdomains.txt" , "w" , encoding = "utf-8" ) as f :
171
+ f .write (str (self .subdomain ))
172
+ elif self .subdomains and self .subdomain is None :
173
+ if os .path .exists (self .subdomains ):
174
+ shutil .copy (self .subdomains , f"result/{ self .date } /{ self .randomstr } .final.subdomains.txt" )
175
+ else :
176
+ logger .error (f"[-] { self .subdomains } Not found and exit!" )
177
+ exit (1 )
178
+
179
+ # 变成绝对路径
180
+ if self .domains is not None :
181
+ if os .path .isabs (self .domains ) is False :
182
+ newpath = os .path .realpath (os .getcwd () + '/' + self .domains )
183
+ if os .path .exists (newpath ):
184
+ self .domains = newpath
185
+ if self .urlsfile is not None :
186
+ if os .path .isabs (self .urlsfile ) is False :
187
+ newpath = os .path .realpath (os .getcwd () + '/' + self .urlsfile )
188
+ if os .path .exists (newpath ):
189
+ self .urlsfile = newpath
190
+ if self .ips is not None :
191
+ if os .path .isabs (self .ips ) is False :
192
+ newpath = os .path .realpath (os .getcwd () + '/' + self .ips )
193
+ if os .path .exists (newpath ):
194
+ self .ips = newpath
131
195
132
196
def install (self ):
133
197
# download tools
@@ -171,7 +235,6 @@ def sensitive(self):
171
235
logger .error ("[-] Please check --url or --urlsfile" )
172
236
173
237
# 对urls进行漏洞扫描
174
- # def vulscan(self):
175
238
def webattack (self ):
176
239
self .attackflag = True
177
240
if self .url :
@@ -185,6 +248,16 @@ def webattack(self):
185
248
else :
186
249
logger .error ("[-] Please check --url or --urlsfile" )
187
250
251
+ # only poc scan
252
+ def webattack2 (self ):
253
+ self .attackflag = True
254
+ if self .url :
255
+ vulscan_main .webmanager (domain = None , url = self .url , urlsfile = None , date = self .date )
256
+ elif self .urlsfile :
257
+ vulscan_main .webmanager (domain = None , url = None , urlsfile = self .urlsfile , date = self .date )
258
+ else :
259
+ logger .error ("[-] Please check --url or --urlsfile" )
260
+
188
261
# 对主机ip攻击
189
262
def hostattack (self ):
190
263
self .attackflag = True
@@ -199,7 +272,7 @@ def hostattack(self):
199
272
200
273
def attack (self ):
201
274
self .webattack ()
202
- self .webattack ()
275
+ self .hostattack ()
203
276
204
277
# 只扫描,不攻击 提供主域名或者主域名文件,顺序执行
205
278
def collect (self ):
@@ -220,6 +293,26 @@ def collect(self):
220
293
else :
221
294
logger .error ("[-] Please check --domain or --domains" )
222
295
296
+ def collect1 (self ):
297
+ # self.attackflag = False
298
+ if self .domains_list :
299
+ for domain in self .domains_list :
300
+ domain_main .manager (domain = domain , date = self .date )
301
+ finger_main .manager (domain = domain , url = None , urlsfile = None , date = self .date )
302
+ # portscan_main.manager(domain=domain, ip=None, ipfile=None, date=self.date)
303
+ else :
304
+ logger .error ("[-] Please check --domain or --domains" )
305
+
306
+ def collect2 (self ):
307
+ # self.attackflag = False
308
+ if self .domains_list :
309
+ for domain in self .domains_list :
310
+ domain_main .manager (domain = domain , date = self .date )
311
+ finger_main .manager (domain = domain , url = None , urlsfile = None , date = self .date )
312
+ portscan_main .manager (domain = domain , ip = None , ipfile = None , date = self .date )
313
+ else :
314
+ logger .error ("[-] Please check --domain or --domains" )
315
+
223
316
# 扫描+攻击 all_scan
224
317
def all (self ):
225
318
'''
@@ -233,14 +326,76 @@ def all(self):
233
326
domain_main .manager (domain = domain , date = self .date )
234
327
finger_main .manager (domain = domain , urlsfile = None , date = self .date )
235
328
portscan_main .manager (domain = domain , ip = None , ipfile = None , date = self .date )
236
- sensitiveinfo_main .manager (domain = domain , url = None , urlsfile = None , attackflag = self .attackflag ,
237
- date = self .date )
238
329
vulscan_main .webmanager (domain = domain , url = None , urlsfile = None , date = self .date )
239
330
vulscan_main .hostmanager (domain = domain , ip = None , ipfile = None , date = self .date )
331
+ sensitiveinfo_main .manager (domain = domain , url = None , urlsfile = None , attackflag = self .attackflag ,
332
+ date = self .date )
240
333
else :
241
334
logger .error ("[-] Please check --domain or --domains" )
242
335
336
+ # 扫描+攻击 提供子域名列表,不扫描子域
337
+ def all2 (self ):
338
+ '''
339
+ python main.py --subdomain aaa.tiqianle.com all2
340
+ python main.py --subdomains tiqianle.com.txt all2
341
+ :return:
342
+ '''
343
+ self .attackflag = True
344
+ if self .subdomain or self .subdomains :
345
+ # for domain in self.domains_list:
346
+ # domain_main.manager(domain=domain, date=self.date)
347
+ finger_main .manager (domain = self .randomstr , urlsfile = None , date = self .date )
348
+ portscan_main .manager (domain = self .randomstr , ip = None , ipfile = None , date = self .date )
349
+ vulscan_main .webmanager (domain = self .randomstr , url = None , urlsfile = None , date = self .date )
350
+ vulscan_main .hostmanager (domain = self .randomstr , ip = None , ipfile = None , date = self .date )
351
+ sensitiveinfo_main .manager (domain = self .randomstr , url = None , urlsfile = None , attackflag = self .attackflag ,
352
+ date = self .date )
353
+ else :
354
+ logger .error ("[-] Please check --subdomain or --subdomains" )
355
+
243
356
244
357
if __name__ == '__main__' :
245
358
fire .Fire (Komo )
246
359
360
+ # fire.Fire(ctfr)
361
+ # fire.Fire(test1.b)
362
+ # test1.a()
363
+ # fire.Fire(test1.ooo)
364
+ # test1.a()
365
+ # fire.Fire(oneforall.OneForAll)
366
+
367
+ # class ooo(object):
368
+ # def __init__(self, target=None, targets=None, brute=None, dns=None, req=None,
369
+ # port=None, alive=None, fmt=None, path=None, takeover=None):
370
+ # self.target = target
371
+ # self.targets = targets
372
+ # self.brute = brute
373
+ # self.dns = dns
374
+ # self.req = req
375
+ # self.port = port
376
+ # self.alive = alive
377
+ # self.fmt = fmt
378
+ # self.path = path
379
+ # self.takeover = takeover
380
+ # self.domain = str() # The domain currently being collected
381
+ # self.domains = set() # All domains that are to be collected
382
+ # self.data = list() # The subdomain results of the current domain
383
+ # self.datas = list() # All subdomain results of the domain
384
+ # self.in_china = None
385
+ # self.access_internet = False
386
+ # self.enable_wildcard = False
387
+ # print(self.target)
388
+ #
389
+ # def run(self):
390
+ #
391
+ #
392
+
393
+
394
+ # os.system("python3 core/test1/test1.py")
395
+
396
+
397
+ # domain_main.manager("tiqianle.com", date)
398
+ #
399
+ # test1.yoyo()
400
+ # test1.Yoyo().yoyoketang()
401
+ # test1.sss()
0 commit comments