Skip to content

Commit be4bdc8

Browse files
committed
bayonet 1.1
1 parent 615b79e commit be4bdc8

File tree

622 files changed

+2929740
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

622 files changed

+2929740
-1
lines changed

.DS_Store

-6 KB
Binary file not shown.

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,70 @@
1-
#### 正在更新全新版本,请稍等!
1+
### 简介
2+
3+
> Bayonet是整合多款安全工具并以web形式展现,它辅助渗透测试人员进行安全检查。工具大小一百多M,其中IP数据库占据大部分,代码量体积不大。
4+
5+
### 功能点
6+
7+
- 子域名扫描:oneforall
8+
- 端口服务扫描:shodan+异步socket+nmap
9+
- URL可用探测
10+
- 驱动浏览器爬虫采集数据:crawlergo
11+
- 被动漏洞扫描:w13scan
12+
13+
### 安装说明
14+
15+
- Python3.7以上(推荐Python3.8)
16+
- 数据库(推荐postgres)
17+
- chromium浏览器
18+
19+
##### 以Ubuntu16.04为例
20+
21+
- 1、安装Python3.8以及相关编译环境(dev之类),这里推荐使用`miniconda`安装,并安装`requirements.txt`文件所需模块
22+
23+
- 2、安装postgresql数据库,可将源换成国内源进行快速安装,完成后创建一个空数据库。
24+
25+
- 3、安装chromium浏览器
26+
```
27+
sudo apt-get install chromium-browser
28+
```
29+
30+
### 使用说明
31+
- 1、修改`config.py``db_config.py`文件,填入`数据库链接项``shodanapi项`,其他选项选填。
32+
33+
- 2、执行`python app.py`,开启web服务,若能正常访问说明数据库链接无误
34+
35+
- 3、执行`python Run.py`,将会起四个进程分别启动子域名扫描、端口扫描、URL扫描、爬虫模块
36+
37+
- 4、进入`tools/scan/W13scan目录`,执行`python cli.py`开启被动漏洞扫描(w13scan未整合到项目中,故需手动执行)。以上操作可用`nohub`进行后台执行。
38+
39+
- 5、查看web页面数据状态,等待扫描即可。注意`漏洞扫描需要去web页面的扫描任务管理手动开启`,这样做是为了不必要扫描不需要的子域名。
40+
41+
### 更新日志
42+
43+
##### 2020年3月04日
44+
> bayonet V1.1版本完成。添加并完善了:
45+
46+
- 1:加入了WAF、CDN、ip归属地识别,进行自动跳过,节约了扫描时间
47+
- 2:加入了异步socket常规端口探测功能、nmap探测功能、防止shodan探测不完整
48+
- 3:数据表进行了关联,新增且优化了web页面设计
49+
- 4:爬虫采集到的子域名再次入库,URL探测支持二级目录扫描
50+
- 5:子域名、端口扫描、URL扫描、爬虫模块整合到一个项目以便关联
51+
- 6:修复了一些bug
52+
53+
尚未添加功能:
54+
- xray扫描器
55+
- 端口服务漏洞扫描
56+
57+
##### 2020年2月13日
58+
> bayonet V1.0版本完成,基本连接了这几个工具模块到一起
59+
60+
### 演示
61+
62+
![index](https://github.com/CTF-MissFeng/bayonet/blob/master/doc/1.png)
63+
64+
![index](https://github.com/CTF-MissFeng/bayonet/blob/master/doc/2.png)
65+
66+
![index](https://github.com/CTF-MissFeng/bayonet/blob/master/doc/3.png)
67+
68+
![index](https://github.com/CTF-MissFeng/bayonet/blob/master/doc/4.png)
69+
70+
![index](https://github.com/CTF-MissFeng/bayonet/blob/master/doc/5.png)

Run.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import multiprocessing
2+
3+
import tools.oneforall.Run
4+
import tools.portscan.Run
5+
import tools.urlscan.Run
6+
import tools.scan.Chromium.Run
7+
8+
def worker():
9+
subdomain_worker = multiprocessing.Process(target=tools.oneforall.Run.main, name='subdomain')
10+
subdomain_worker.start()
11+
12+
portscan_worker = multiprocessing.Process(target=tools.portscan.Run.port_main, name='portscan')
13+
portscan_worker.start()
14+
15+
urlscan_worker = multiprocessing.Process(target=tools.urlscan.Run.urlscan_main, name='urlscan')
16+
urlscan_worker.start()
17+
18+
chromium_worker = multiprocessing.Process(target=tools.scan.Chromium.Run.main, name='chromiumscan')
19+
chromium_worker.start()
20+
21+
if __name__ == '__main__':
22+
worker()

app.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from web.models import User
2+
from web import APP, DB
3+
4+
def CreateDatabase():
5+
'''创建数据库'''
6+
DB.create_all()
7+
8+
def CreateUser():
9+
'''创建测试账户'''
10+
sql = User.query.filter(User.username == 'root').first()
11+
if not sql:
12+
user1 = User(username='root', password='qazxsw@123', name='管理员', phone='1388888888', email='admin@qq.com',
13+
remark='安全工程师')
14+
DB.session.add(user1)
15+
DB.session.commit()
16+
17+
def DeletDb():
18+
'''重置数据库'''
19+
DB.drop_all()
20+
CreateDatabase()
21+
CreateUser()
22+
23+
def bayonet_main():
24+
CreateDatabase()
25+
CreateUser()
26+
APP.run(host='0.0.0.0', port=80)
27+
#APP.run()
28+
29+
if __name__ == '__main__':
30+
#DeletDb()
31+
bayonet_main()

config.py

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
import os
2+
import pathlib
3+
import urllib3
4+
5+
class BayonetConfig(object):
6+
'''Flask数据配置'''
7+
SECRET_KEY = 'a819f87b3e371a82dafb8c535c1242c9bba5e91da02ff1d87095367d1d4e188e'
8+
SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:123456@127.0.0.1/bayonet' # 数据库连接字符串
9+
SQLALCHEMY_TRACK_MODIFICATIONS = False
10+
TITLE = 'Bayonet 资产管理系统'
11+
12+
class Oneforall:
13+
# 模块API配置
14+
# Censys可以免费注册获取API:https://censys.io/api
15+
censys_api_id = ''
16+
censys_api_secret = ''
17+
# Binaryedge可以免费注册获取API:https://app.binaryedge.io/account/api
18+
# 免费的API有效期只有1个月,到期之后可以再次生成,每月可以查询250次。
19+
binaryedge_api = ''
20+
# Chinaz可以免费注册获取API:http://api.chinaz.com/ApiDetails/Alexa
21+
chinaz_api = ''
22+
# Bing可以免费注册获取API:https://azure.microsoft.com/zh-cn/services/
23+
# cognitive-services/bing-web-search-api/#web-json
24+
bing_api_id = ''
25+
bing_api_key = ''
26+
# SecurityTrails可以免费注册获取API:https://securitytrails.com/corp/api
27+
securitytrails_api = ''
28+
# https://fofa.so/api
29+
fofa_api_email = '' # fofa用户邮箱
30+
fofa_api_key = '' # fofa用户key
31+
# Google可以免费注册获取API:
32+
# https://developers.google.com/custom-search/v1/overview
33+
# 免费的API只能查询前100条结果
34+
google_api_key = '' # Google API搜索key
35+
google_api_cx = '' # Google API搜索cx
36+
# https://api.passivetotal.org/api/docs/
37+
riskiq_api_username = ''
38+
riskiq_api_key = ''
39+
# Shodan可以免费注册获取API: https://account.shodan.io/register
40+
# 免费的API限速1秒查询1次
41+
shodan_api_key = ''
42+
# ThreatBook API 查询子域名需要收费 https://x.threatbook.cn/nodev4/vb4/myAPI
43+
threatbook_api_key = ''
44+
# VirusTotal可以免费注册获取API: https://developers.virustotal.com/reference
45+
virustotal_api_key = ''
46+
# https://www.zoomeye.org/doc?channel=api
47+
zoomeye_api_usermail = ''
48+
zoomeye_api_password = ''
49+
# Spyse可以免费注册获取API: https://spyse.com/
50+
spyse_api_token = ''
51+
# https://www.circl.lu/services/passive-dns/
52+
circl_api_username = ''
53+
circl_api_password = ''
54+
# https://www.dnsdb.info/
55+
dnsdb_api_key = ''
56+
# ipv4info可以免费注册获取API: http://ipv4info.com/tools/api/
57+
# 免费的API有效期只有2天,到期之后可以再次生成,每天可以查询50次。
58+
ipv4info_api_key = ''
59+
# https://github.com/360netlab/flint
60+
# passivedns_api_addr默认空使用http://api.passivedns.cn
61+
# passivedns_api_token可为空
62+
passivedns_api_addr = ''
63+
passivedns_api_token = ''
64+
# Github Token可以访问https://github.com/settings/tokens生成,user为Github用户名
65+
# 用于子域接管
66+
github_api_user = ''
67+
github_api_token = ''
68+
# Github子域收集模块使用
69+
github_email = ''
70+
github_password = ''
71+
# 路径设置
72+
oneforall_relpath = pathlib.Path(__file__).parent.joinpath('tools', 'oneforall') # oneforall代码相对路径
73+
oneforall_abspath = oneforall_relpath.resolve() # oneforall代码绝对路径
74+
oneforall_module_path = oneforall_relpath.joinpath('modules') # oneforall模块目录
75+
data_storage_path = oneforall_relpath.joinpath('data') # 数据存放目录
76+
result_save_path = oneforall_relpath.joinpath('results') # 结果保存目录
77+
if not result_save_path.is_dir():
78+
result_save_path.mkdir()
79+
# 模块设置
80+
save_module_result = False # 保存各模块发现结果为json文件(默认False)
81+
enable_all_module = False # 启用所有模块(默认True)
82+
enable_partial_module = [('modules.search', 'baidu'),
83+
('modules.search', 'bing'),
84+
('modules.search', 'exalead'),
85+
('modules.search', 'so'),
86+
('modules.search', 'sogou'),
87+
('modules.search', 'yandex'),
88+
('modules.intelligence', 'virustotal'),
89+
('modules.dnsquery', 'srv'),
90+
('modules.datasets', 'bufferover'),
91+
('modules.datasets', 'cebaidu'),
92+
('modules.datasets', 'chinaz'),
93+
('modules.datasets', 'dnsdumpster'),
94+
('modules.datasets', 'hackertarget'),
95+
('modules.datasets', 'netcraft'),
96+
('modules.datasets', 'ptrarchive'),
97+
('modules.datasets', 'riddler'),
98+
('modules.datasets', 'robtex'),
99+
('modules.datasets', 'sitedossier'),
100+
('modules.datasets', 'threatcrowd'),
101+
('modules.certificates', 'certspotter'),
102+
('modules.certificates', 'crtsh'),
103+
('modules.certificates', 'entrust'),
104+
('modules.check', 'axfr'),
105+
('modules.check', 'cert'),
106+
]
107+
# 只使用ask和baidu搜索引擎收集子域
108+
# enable_partial_module = [('modules.search', 'ask')
109+
# ('modules.search', 'baidu')]
110+
module_thread_timeout = 360.0 # 每个收集模块线程超时时间(默认6分钟)
111+
# 爆破模块设置
112+
enable_brute_module = False # 使用爆破模块(默认False)
113+
enable_dns_resolve = True # DNS解析子域(默认True)
114+
enable_http_request = False # HTTP请求子域(默认True)
115+
enable_wildcard_check = True # 开启泛解析检测(默认True)
116+
enable_wildcard_deal = True # 开启泛解析处理(默认True)
117+
# 爆破时使用的进程数(根据系统中CPU数量情况设置 不宜大于CPU数量 默认为系统中的CPU数量)
118+
brute_process_num = os.cpu_count()
119+
brute_coroutine_num = 1024 # 爆破时每个进程下的协程数
120+
# 爆破所使用的字典路径 默认data/subdomains.txt
121+
brute_wordlist_path = data_storage_path.joinpath('subnames.txt')
122+
enable_recursive_brute = False # 是否使用递归爆破(默认禁用)
123+
brute_recursive_depth = 2 # 递归爆破深度(默认2层)
124+
# 爆破下一层子域所使用的字典路径 默认data/next_subdomains.txt
125+
recursive_namelist_path = data_storage_path.joinpath('next_subnames.txt')
126+
enable_fuzz = False # 是否使用fuzz模式枚举域名
127+
fuzz_rule = '' # fuzz域名的正则 示例:[a-z][0-9] 第一位是字母 第二位是数字
128+
ips_appear_maximum = 10 # 同一IP集合出现次数超过10认为是泛解析
129+
# 代理设置
130+
enable_proxy = False # 是否使用代理(全局开关)
131+
proxy_all_module = False # 代理所有模块
132+
proxy_partial_module = ['GoogleQuery', 'AskSearch', 'DuckDuckGoSearch',
133+
'GoogleAPISearch', 'GoogleSearch', 'YahooSearch',
134+
'YandexSearch', 'CrossDomainXml',
135+
'ContentSecurityPolicy'] # 代理自定义的模块
136+
proxy_pool = [{'http': 'http://127.0.0.1:1080',
137+
'https': 'https://127.0.0.1:1080'}] # 代理池
138+
# proxy_pool = [{'http': 'socks5h://127.0.0.1:10808',
139+
# 'https': 'socks5h://127.0.0.1:10808'}] # 代理池
140+
# 网络请求设置
141+
enable_fake_header = True # 启用伪造请求头
142+
request_delay = 1 # 请求时延
143+
request_timeout = 30 # 请求超时
144+
request_verify = False # 请求SSL验证
145+
# 禁用安全警告信息
146+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
147+
# 搜索模块设置
148+
enable_recursive_search = False # 递归搜索子域
149+
search_recursive_times = 2 # 递归搜索层数
150+
# DNS解析设置
151+
resolver_nameservers = [
152+
'119.29.29.29', '182.254.116.116', # DNSPod
153+
'180.76.76.76', # Baidu DNS
154+
'223.5.5.5', '223.6.6.6', # AliDNS
155+
'114.114.114.114', '114.114.115.115' # 114DNS
156+
# '8.8.8.8', '8.8.4.4', # Google DNS
157+
# '1.0.0.1', '1.1.1.1' # CloudFlare DNS
158+
# '208.67.222.222', '208.67.220.220' # OpenDNS
159+
] # 指定查询的DNS域名服务器
160+
resolver_timeout = 5.0 # 解析超时时间
161+
resolver_lifetime = 30.0 # 解析存活时间
162+
limit_resolve_conn = 500 # 限制同一时间解析的数量(默认500)
163+
# 请求端口探测设置
164+
# 你可以在端口列表添加自定义端口
165+
default_ports = [80] # 默认使用
166+
small_ports = [80, 443, 8000, 8080, 8443]
167+
# 注意:建议大厂的域名尽量不使用大端口范围,因为大厂的子域太多,加上使用大端口范围会导致生成的
168+
# 请求上十万,百万,千万级,可能会导致内存不足程序奔溃,另外这样级别的请求量等待时间也是漫长的。
169+
# OneForAll不是一个端口扫描工具,如果要扫端口建议使用nmap,zmap之类的工具。
170+
large_ports = [80, 81, 280, 300, 443, 591, 593, 832, 888, 901, 981, 1010, 1080,
171+
1100, 1241, 1311, 1352, 1434, 1521, 1527, 1582, 1583, 1944, 2082,
172+
2082, 2086, 2087, 2095, 2096, 2222, 2301, 2480, 3000, 3128, 3333,
173+
4000, 4001, 4002, 4100, 4125, 4243, 4443, 4444, 4567, 4711, 4712,
174+
4848, 4849, 4993, 5000, 5104, 5108, 5432, 5555, 5800, 5801, 5802,
175+
5984, 5985, 5986, 6082, 6225, 6346, 6347, 6443, 6480, 6543, 6789,
176+
7000, 7001, 7002, 7396, 7474, 7674, 7675, 7777, 7778, 8000, 8001,
177+
8002, 8003, 8004, 8005, 8006, 8008, 8009, 8010, 8014, 8042, 8069,
178+
8075, 8080, 8081, 8083, 8088, 8090, 8091, 8092, 8093, 8016, 8118,
179+
8123, 8172, 8181, 8200, 8222, 8243, 8280, 8281, 8333, 8384, 8403,
180+
8443, 8500, 8530, 8531, 8800, 8806, 8834, 8880, 8887, 8888, 8910,
181+
8983, 8989, 8990, 8991, 9000, 9043, 9060, 9080, 9090, 9091, 9200,
182+
9294, 9295, 9443, 9444, 9800, 9981, 9988, 9990, 9999, 10000,
183+
10880, 11371, 12043, 12046, 12443, 15672, 16225, 16080, 18091,
184+
18092, 20000, 20720, 24465, 28017, 28080, 30821, 43110, 61600]
185+
ports = {'default': default_ports, 'small': small_ports, 'large': large_ports}
186+
# aiohttp有关配置
187+
verify_ssl = False
188+
# aiohttp 支持 HTTP/HTTPS形式的代理
189+
aiohttp_proxy = None # proxy="http://user:pass@some.proxy.com"
190+
allow_redirects = True # 允许请求跳转
191+
fake_header = True # 使用伪造请求头
192+
# 为了保证请求质量 请谨慎更改以下设置
193+
# request_method只能是HEAD或GET,HEAD请求方法更快,但是不能获取响应体并提取从中提取
194+
request_method = 'GET' # 使用请求方法,默认GET
195+
sockread_timeout = 5 # 每个请求socket读取超时时间,默认5秒
196+
sockconn_timeout = 5 # 每个请求socket连接超时时间,默认5秒
197+
# 限制同一时间打开的连接总数
198+
limit_open_conn = 100 # 默认100
199+
# 限制同一时间在同一个端点((host, port, is_ssl) 3者都一样的情况)打开的连接数
200+
limit_per_host = 10 # 0表示不限制,默认10
201+
subdomains_common = {'i', 'w', 'm', 'en', 'us', 'zh', 'w3', 'app', 'bbs',
202+
'web', 'www', 'job', 'docs', 'news', 'blog', 'data',
203+
'help', 'live', 'mall', 'blogs', 'files', 'forum',
204+
'store', 'mobile'}
205+
206+
class PortScan:
207+
cdn_scan = True # 不扫描识别为cdn的IP
208+
shodan_api = 'xxxxx' # shodan查询api
209+
async_scan = False # 是否开启常规端口服务探测
210+
async_scan_timeout = 30 # 异步端口扫描超时时间
211+
async_scan_threads = 500 # 异步协程数
212+
# nmap程序路径地址,可指定具体路径或设置环境变量
213+
nmap_search_path = ('nmap', '/usr/bin/nmap', '/usr/local/bin/nmap', '/sw/bin/nmap', '/opt/local/bin/nmap')
214+
port_num = 500 # 超过多少个端口识别为CDN丢弃
215+
216+
class UrlScan:
217+
timeout = 15 # HTTP访问超时
218+
success_status_code = [200] # 该状态码表示为有web应用程序
219+
failure_status_code = [403, 401] # 该状态码表示为根目录无应用程序,要进行目录枚举寻找二级应用程序
220+
threads = 10 # 多线程数,表示同时处理ports表中的记录
221+
222+
subdirectory = True # 开启二级目录查找
223+
subdirectory_threads = 10 # 二级目录查找线程数
224+
subdirectory_path = ['www', 'web', 'admin', 'user', 'login', 'manager', 'root', 'member', 'bbs', 'index', 'system',
225+
'cms', 'home', 'main', 'wap', 'app', 'console', 'Web', 'download', 'view', 'public', 'tushu',
226+
'sys', 'test', 'api', 'about', 'html', 'site', 'list', 'service', 'help', 'sso', 'mobile',
227+
'info', 'Home', 'blog', 'file', 'auth', 'pages']
228+
229+
class crawlergo:
230+
# chromium浏览器可执行文件绝对路径
231+
chromium_path = '/usr/lib/chromium-browser/chromium-browser'
232+
max_tab_count = '5' # 爬虫同时开启最大标签页
233+
filter_mode = 'smart' # 过滤模式 simple-简单、smart-智能、strict-严格
234+
max_crawled_count = '200' # 爬虫最大任务数量
235+
cache_path = '/Users/[username]/Library/Caches/Google/Chrome/Default/Cache/' # 浏览器缓存地址,会自动删除提高效率

0 commit comments

Comments
 (0)