Skip to content

Commit 3c96998

Browse files
committed
v1.1,适配linux,修改bug,添加机制
1 parent 17c5ee4 commit 3c96998

19 files changed

+2603
-238
lines changed

Komo.py

+165-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import os
2+
import random
3+
import shutil
4+
import string
5+
26
import fire
37
import datetime
48
from loguru import logger
@@ -17,7 +21,7 @@
1721
red = '\033[1;31m'
1822
end = '\033[0m'
1923

20-
version = 'v1.0'
24+
version = 'v1.1'
2125
message = white + '{' + red + version + ' #dev' + white + '}'
2226

2327
banner = f"""
@@ -49,10 +53,19 @@ class Komo(object):
4953
5054
mode:
5155
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
5363
--domain one domain
5464
--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
5669
--domain one domain
5770
--domains a domain file
5871
subdomain only collect subdomain
@@ -67,28 +80,42 @@ class Komo(object):
6780
sensitive only collect directory with crawl,email
6881
--url one url
6982
--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
7187
--url one url
7288
--urls an urls file
7389
hostattack only attack ip from ip or ips
7490
--ip one ip
7591
--ips an ips file
92+
attack run webattack and hostattack: crawl url to xray, pocscan, Weak password scanning
93+
7694
7795
Example:
7896
python3 Komo.py install
7997
python3 Komo.py --domain example.com all
8098
python3 Komo.py --domains ./domains.txt all
8199
python3 Komo.py --domain example.com collect
82100
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
83105
python3 Komo.py --domain example.com subdomain
84106
python3 Komo.py --domains ./domains.txt subdomain
85107
108+
python3 Komo.py --subdomain aaa.example.com all2
109+
python3 Komo.py --subdomains ./subdomains.txt all2
110+
86111
python3 Komo.py --url http://example.com finger
87112
python3 Komo.py --urls ./urls.txt finger
88113
python3 Komo.py --url http://example.com sensitive
89114
python3 Komo.py --urls ./urls.txt sensitive
90115
python3 Komo.py --url http://example.com webattack
91116
python3 Komo.py --urls ./urls.txt webattack
117+
python3 Komo.py --url http://example.com webattack2
118+
python3 Komo.py --urls ./urls.txt webattack2
92119
93120
python3 Komo.py --ip example.com portscan
94121
python3 Komo.py --ips ./domains.txt portscan
@@ -98,18 +125,24 @@ class Komo(object):
98125
99126
:param domain:
100127
:param domains:
128+
:param subdomain:
129+
:param subdomains:
101130
:param url:
102-
:param urlsfile:
131+
:param urls:
103132
:param ip:
104133
:param ips:
105134
:param attackflag:
135+
:param date:
106136
'''
107137

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):
109140

110141
date1 = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
111142
self.domain = domain
112143
self.domains = domains # domainsfile
144+
self.subdomain = subdomain
145+
self.subdomains = subdomains
113146
self.url = url
114147
self.urlsfile = urls
115148
self.ip = ip
@@ -119,6 +152,11 @@ def __init__(self, domain=None, domains=None, url=None, urls=None, ip=None, ips=
119152
self.domains_list = []
120153
create_logfile()
121154
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)
122160

123161
if self.domain and self.domains is None:
124162
self.domains_list.append(self.domain)
@@ -128,6 +166,32 @@ def __init__(self, domain=None, domains=None, url=None, urls=None, ip=None, ips=
128166
line = line.strip()
129167
self.domains_list.append(line)
130168
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
131195

132196
def install(self):
133197
# download tools
@@ -171,7 +235,6 @@ def sensitive(self):
171235
logger.error("[-] Please check --url or --urlsfile")
172236

173237
# 对urls进行漏洞扫描
174-
# def vulscan(self):
175238
def webattack(self):
176239
self.attackflag = True
177240
if self.url:
@@ -185,6 +248,16 @@ def webattack(self):
185248
else:
186249
logger.error("[-] Please check --url or --urlsfile")
187250

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+
188261
# 对主机ip攻击
189262
def hostattack(self):
190263
self.attackflag = True
@@ -199,7 +272,7 @@ def hostattack(self):
199272

200273
def attack(self):
201274
self.webattack()
202-
self.webattack()
275+
self.hostattack()
203276

204277
# 只扫描,不攻击 提供主域名或者主域名文件,顺序执行
205278
def collect(self):
@@ -220,6 +293,26 @@ def collect(self):
220293
else:
221294
logger.error("[-] Please check --domain or --domains")
222295

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+
223316
# 扫描+攻击 all_scan
224317
def all(self):
225318
'''
@@ -233,14 +326,76 @@ def all(self):
233326
domain_main.manager(domain=domain, date=self.date)
234327
finger_main.manager(domain=domain, urlsfile=None, date=self.date)
235328
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)
238329
vulscan_main.webmanager(domain=domain, url=None, urlsfile=None, date=self.date)
239330
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)
240333
else:
241334
logger.error("[-] Please check --domain or --domains")
242335

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+
243356

244357
if __name__ == '__main__':
245358
fire.Fire(Komo)
246359

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()

common/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author:Komomon
4+
# @Time:2022/12/27 12:22
5+
6+
7+
8+
9+
10+

common/getconfig.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author:Komomon
4+
# @Time:2022/12/27 12:45
5+
import os
6+
import platform
7+
import yaml
8+
from loguru import logger
9+
10+
ostype = platform.system().lower()
11+
pwd_and_file = os.path.abspath(__file__)
12+
pwd = os.path.dirname(pwd_and_file) # E:\ccode\python\006_lunzi\core\tools\domain
13+
root_path = os.path.realpath(f'{pwd}/../')
14+
# 获取当前目录的前三级目录,即到domain目录下,来寻找exe domain目录下
15+
# grader_father = os.path.abspath(os.path.dirname(pwd_and_file) + os.path.sep + "../..")
16+
# print(grader_father) # E:\ccode\python\006_lunzi\core
17+
18+
19+
20+
def getconfig():
21+
toolsyaml_path = f"{root_path}/config/config.yaml"
22+
# toolsyaml_path = "tools_linux.yaml"
23+
if os.path.exists(toolsyaml_path):
24+
with open(toolsyaml_path, 'r', encoding='utf-8') as f:
25+
all_config = yaml.load(f, Loader=yaml.FullLoader)
26+
return all_config
27+
# tools_config =all_config['tools']
28+
# print(tools_config)
29+
else:
30+
logger.error(f"[-] not found {toolsyaml_path}")
31+
logger.error("Exit!")
32+
exit(1)
33+
34+
35+
if __name__ == '__main__':
36+
getconfig()
37+
38+

config/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)