oneforall-kjl 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- OneForAll/__init__.py +15 -0
- OneForAll/brute.py +503 -0
- OneForAll/common/check.py +41 -0
- OneForAll/common/crawl.py +10 -0
- OneForAll/common/database.py +277 -0
- OneForAll/common/domain.py +63 -0
- OneForAll/common/ipasn.py +42 -0
- OneForAll/common/ipreg.py +139 -0
- OneForAll/common/lookup.py +28 -0
- OneForAll/common/module.py +369 -0
- OneForAll/common/query.py +9 -0
- OneForAll/common/records.py +363 -0
- OneForAll/common/request.py +264 -0
- OneForAll/common/resolve.py +173 -0
- OneForAll/common/search.py +78 -0
- OneForAll/common/similarity.py +138 -0
- OneForAll/common/tablib/__init__.py +0 -0
- OneForAll/common/tablib/format.py +89 -0
- OneForAll/common/tablib/tablib.py +360 -0
- OneForAll/common/tldextract.py +240 -0
- OneForAll/common/utils.py +789 -0
- OneForAll/config/__init__.py +17 -0
- OneForAll/config/api.py +94 -0
- OneForAll/config/default.py +255 -0
- OneForAll/config/log.py +38 -0
- OneForAll/config/setting.py +108 -0
- OneForAll/export.py +72 -0
- OneForAll/modules/altdns.py +216 -0
- OneForAll/modules/autotake/github.py +105 -0
- OneForAll/modules/certificates/censys_api.py +73 -0
- OneForAll/modules/certificates/certspotter.py +48 -0
- OneForAll/modules/certificates/crtsh.py +84 -0
- OneForAll/modules/certificates/google.py +48 -0
- OneForAll/modules/certificates/myssl.py +46 -0
- OneForAll/modules/certificates/racent.py +49 -0
- OneForAll/modules/check/axfr.py +97 -0
- OneForAll/modules/check/cdx.py +44 -0
- OneForAll/modules/check/cert.py +58 -0
- OneForAll/modules/check/csp.py +94 -0
- OneForAll/modules/check/nsec.py +58 -0
- OneForAll/modules/check/robots.py +44 -0
- OneForAll/modules/check/sitemap.py +44 -0
- OneForAll/modules/collect.py +70 -0
- OneForAll/modules/crawl/archivecrawl.py +59 -0
- OneForAll/modules/crawl/commoncrawl.py +59 -0
- OneForAll/modules/datasets/anubis.py +45 -0
- OneForAll/modules/datasets/bevigil.py +50 -0
- OneForAll/modules/datasets/binaryedge_api.py +50 -0
- OneForAll/modules/datasets/cebaidu.py +45 -0
- OneForAll/modules/datasets/chinaz.py +45 -0
- OneForAll/modules/datasets/chinaz_api.py +49 -0
- OneForAll/modules/datasets/circl_api.py +49 -0
- OneForAll/modules/datasets/cloudflare_api.py +130 -0
- OneForAll/modules/datasets/dnsdb_api.py +51 -0
- OneForAll/modules/datasets/dnsdumpster.py +52 -0
- OneForAll/modules/datasets/dnsgrep.py +44 -0
- OneForAll/modules/datasets/fullhunt.py +48 -0
- OneForAll/modules/datasets/hackertarget.py +45 -0
- OneForAll/modules/datasets/ip138.py +45 -0
- OneForAll/modules/datasets/ipv4info_api.py +73 -0
- OneForAll/modules/datasets/netcraft.py +66 -0
- OneForAll/modules/datasets/passivedns_api.py +51 -0
- OneForAll/modules/datasets/qianxun.py +61 -0
- OneForAll/modules/datasets/rapiddns.py +45 -0
- OneForAll/modules/datasets/riddler.py +45 -0
- OneForAll/modules/datasets/robtex.py +58 -0
- OneForAll/modules/datasets/securitytrails_api.py +56 -0
- OneForAll/modules/datasets/sitedossier.py +57 -0
- OneForAll/modules/datasets/spyse_api.py +62 -0
- OneForAll/modules/datasets/sublist3r.py +45 -0
- OneForAll/modules/datasets/urlscan.py +45 -0
- OneForAll/modules/datasets/windvane.py +92 -0
- OneForAll/modules/dnsquery/mx.py +35 -0
- OneForAll/modules/dnsquery/ns.py +35 -0
- OneForAll/modules/dnsquery/soa.py +35 -0
- OneForAll/modules/dnsquery/spf.py +35 -0
- OneForAll/modules/dnsquery/txt.py +35 -0
- OneForAll/modules/enrich.py +72 -0
- OneForAll/modules/finder.py +206 -0
- OneForAll/modules/intelligence/alienvault.py +50 -0
- OneForAll/modules/intelligence/riskiq_api.py +58 -0
- OneForAll/modules/intelligence/threatbook_api.py +50 -0
- OneForAll/modules/intelligence/threatminer.py +45 -0
- OneForAll/modules/intelligence/virustotal.py +60 -0
- OneForAll/modules/intelligence/virustotal_api.py +59 -0
- OneForAll/modules/iscdn.py +86 -0
- OneForAll/modules/search/ask.py +69 -0
- OneForAll/modules/search/baidu.py +96 -0
- OneForAll/modules/search/bing.py +79 -0
- OneForAll/modules/search/bing_api.py +78 -0
- OneForAll/modules/search/fofa_api.py +74 -0
- OneForAll/modules/search/gitee.py +71 -0
- OneForAll/modules/search/github_api.py +86 -0
- OneForAll/modules/search/google.py +83 -0
- OneForAll/modules/search/google_api.py +77 -0
- OneForAll/modules/search/hunter_api.py +72 -0
- OneForAll/modules/search/quake_api.py +72 -0
- OneForAll/modules/search/shodan_api.py +53 -0
- OneForAll/modules/search/so.py +75 -0
- OneForAll/modules/search/sogou.py +72 -0
- OneForAll/modules/search/wzsearch.py +68 -0
- OneForAll/modules/search/yahoo.py +81 -0
- OneForAll/modules/search/yandex.py +80 -0
- OneForAll/modules/search/zoomeye_api.py +73 -0
- OneForAll/modules/srv.py +75 -0
- OneForAll/modules/wildcard.py +319 -0
- OneForAll/oneforall.py +275 -0
- OneForAll/takeover.py +168 -0
- OneForAll/test.py +23 -0
- oneforall_kjl-0.1.1.dist-info/METADATA +18 -0
- oneforall_kjl-0.1.1.dist-info/RECORD +114 -0
- oneforall_kjl-0.1.1.dist-info/WHEEL +5 -0
- oneforall_kjl-0.1.1.dist-info/entry_points.txt +2 -0
- oneforall_kjl-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,369 @@
|
|
1
|
+
"""
|
2
|
+
Module base class
|
3
|
+
"""
|
4
|
+
|
5
|
+
import json
|
6
|
+
import threading
|
7
|
+
import time
|
8
|
+
|
9
|
+
import requests
|
10
|
+
from config.log import logger
|
11
|
+
from config import settings
|
12
|
+
from common import utils
|
13
|
+
from common.database import Database
|
14
|
+
|
15
|
+
lock = threading.Lock()
|
16
|
+
|
17
|
+
|
18
|
+
class Module(object):
|
19
|
+
def __init__(self):
|
20
|
+
self.module = 'Module'
|
21
|
+
self.source = 'BaseModule'
|
22
|
+
self.cookie = None
|
23
|
+
self.header = dict()
|
24
|
+
self.proxy = None
|
25
|
+
self.delay = 1 # 请求睡眠时延
|
26
|
+
self.timeout = settings.request_timeout_second # 请求超时时间
|
27
|
+
self.verify = settings.request_ssl_verify # 请求SSL验证
|
28
|
+
self.domain = str() # 当前进行子域名收集的主域
|
29
|
+
self.subdomains = set() # 存放发现的子域
|
30
|
+
self.infos = dict() # 存放子域有关信息
|
31
|
+
self.results = list() # 存放模块结果
|
32
|
+
self.start = time.time() # 模块开始执行时间
|
33
|
+
self.end = None # 模块结束执行时间
|
34
|
+
self.elapse = None # 模块执行耗时
|
35
|
+
|
36
|
+
def have_api(self, *apis):
|
37
|
+
"""
|
38
|
+
Simply check whether the api information configure or not
|
39
|
+
|
40
|
+
:param apis: apis set
|
41
|
+
:return bool: check result
|
42
|
+
"""
|
43
|
+
if not all(apis):
|
44
|
+
logger.log('DEBUG', f'{self.source} module is not configured')
|
45
|
+
return False
|
46
|
+
return True
|
47
|
+
|
48
|
+
def begin(self):
|
49
|
+
"""
|
50
|
+
begin log
|
51
|
+
"""
|
52
|
+
logger.log('DEBUG', f'Start {self.source} module to '
|
53
|
+
f'collect subdomains of {self.domain}')
|
54
|
+
|
55
|
+
def finish(self):
|
56
|
+
"""
|
57
|
+
finish log
|
58
|
+
"""
|
59
|
+
self.end = time.time()
|
60
|
+
self.elapse = round(self.end - self.start, 1)
|
61
|
+
logger.log('DEBUG', f'Finished {self.source} module to '
|
62
|
+
f'collect {self.domain}\'s subdomains')
|
63
|
+
logger.log('INFOR', f'{self.source} module took {self.elapse} seconds '
|
64
|
+
f'found {len(self.subdomains)} subdomains')
|
65
|
+
logger.log('DEBUG', f'{self.source} module found subdomains of {self.domain}\n'
|
66
|
+
f'{self.subdomains}')
|
67
|
+
|
68
|
+
def head(self, url, params=None, check=True, **kwargs):
|
69
|
+
"""
|
70
|
+
Custom head request
|
71
|
+
|
72
|
+
:param str url: request url
|
73
|
+
:param dict params: request parameters
|
74
|
+
:param bool check: check response
|
75
|
+
:param kwargs: other params
|
76
|
+
:return: response object
|
77
|
+
"""
|
78
|
+
session = requests.Session()
|
79
|
+
session.trust_env = False
|
80
|
+
try:
|
81
|
+
resp = session.head(url,
|
82
|
+
params=params,
|
83
|
+
cookies=self.cookie,
|
84
|
+
headers=self.header,
|
85
|
+
proxies=self.proxy,
|
86
|
+
timeout=self.timeout,
|
87
|
+
verify=self.verify,
|
88
|
+
**kwargs)
|
89
|
+
except Exception as e:
|
90
|
+
logger.log('ERROR', e.args[0])
|
91
|
+
return None
|
92
|
+
if not check:
|
93
|
+
return resp
|
94
|
+
if utils.check_response('HEAD', resp):
|
95
|
+
return resp
|
96
|
+
return None
|
97
|
+
|
98
|
+
def get(self, url, params=None, check=True, ignore=False, raise_error=False, **kwargs):
|
99
|
+
"""
|
100
|
+
Custom get request
|
101
|
+
|
102
|
+
:param str url: request url
|
103
|
+
:param dict params: request parameters
|
104
|
+
:param bool check: check response
|
105
|
+
:param bool ignore: ignore error
|
106
|
+
:param bool raise_error: raise error or not
|
107
|
+
:param kwargs: other params
|
108
|
+
:return: response object
|
109
|
+
"""
|
110
|
+
session = requests.Session()
|
111
|
+
session.trust_env = False
|
112
|
+
level = 'ERROR'
|
113
|
+
if ignore:
|
114
|
+
level = 'DEBUG'
|
115
|
+
try:
|
116
|
+
resp = session.get(url,
|
117
|
+
params=params,
|
118
|
+
cookies=self.cookie,
|
119
|
+
headers=self.header,
|
120
|
+
proxies=self.proxy,
|
121
|
+
timeout=self.timeout,
|
122
|
+
verify=self.verify,
|
123
|
+
**kwargs)
|
124
|
+
except Exception as e:
|
125
|
+
if raise_error:
|
126
|
+
if isinstance(e, requests.exceptions.ConnectTimeout):
|
127
|
+
logger.log(level, e.args[0])
|
128
|
+
raise e
|
129
|
+
logger.log(level, e.args[0])
|
130
|
+
return None
|
131
|
+
if not check:
|
132
|
+
return resp
|
133
|
+
if utils.check_response('GET', resp):
|
134
|
+
return resp
|
135
|
+
return None
|
136
|
+
|
137
|
+
def post(self, url, data=None, check=True, **kwargs):
|
138
|
+
"""
|
139
|
+
Custom post request
|
140
|
+
|
141
|
+
:param str url: request url
|
142
|
+
:param dict data: request data
|
143
|
+
:param bool check: check response
|
144
|
+
:param kwargs: other params
|
145
|
+
:return: response object
|
146
|
+
"""
|
147
|
+
session = requests.Session()
|
148
|
+
session.trust_env = False
|
149
|
+
try:
|
150
|
+
resp = session.post(url,
|
151
|
+
data=data,
|
152
|
+
cookies=self.cookie,
|
153
|
+
headers=self.header,
|
154
|
+
proxies=self.proxy,
|
155
|
+
timeout=self.timeout,
|
156
|
+
verify=self.verify,
|
157
|
+
**kwargs)
|
158
|
+
except Exception as e:
|
159
|
+
logger.log('ERROR', e.args[0])
|
160
|
+
return None
|
161
|
+
if not check:
|
162
|
+
return resp
|
163
|
+
if utils.check_response('POST', resp):
|
164
|
+
return resp
|
165
|
+
return None
|
166
|
+
|
167
|
+
def delete(self, url, check=True, **kwargs):
|
168
|
+
"""
|
169
|
+
Custom delete request
|
170
|
+
|
171
|
+
:param str url: request url
|
172
|
+
:param bool check: check response
|
173
|
+
:param kwargs: other params
|
174
|
+
:return: response object
|
175
|
+
"""
|
176
|
+
session = requests.Session()
|
177
|
+
session.trust_env = False
|
178
|
+
try:
|
179
|
+
resp = session.delete(url,
|
180
|
+
cookies=self.cookie,
|
181
|
+
headers=self.header,
|
182
|
+
proxies=self.proxy,
|
183
|
+
timeout=self.timeout,
|
184
|
+
verify=self.verify,
|
185
|
+
**kwargs)
|
186
|
+
except Exception as e:
|
187
|
+
logger.log('ERROR', e.args[0])
|
188
|
+
return None
|
189
|
+
if not check:
|
190
|
+
return resp
|
191
|
+
if utils.check_response('DELETE', resp):
|
192
|
+
return resp
|
193
|
+
return None
|
194
|
+
|
195
|
+
def get_header(self):
|
196
|
+
"""
|
197
|
+
Get request header
|
198
|
+
|
199
|
+
:return: header
|
200
|
+
"""
|
201
|
+
headers = utils.gen_fake_header()
|
202
|
+
if isinstance(headers, dict):
|
203
|
+
self.header = headers
|
204
|
+
return headers
|
205
|
+
return self.header
|
206
|
+
|
207
|
+
def get_proxy(self, module):
|
208
|
+
"""
|
209
|
+
Get proxy
|
210
|
+
|
211
|
+
:param str module: module name
|
212
|
+
:return: proxy
|
213
|
+
"""
|
214
|
+
if not settings.enable_request_proxy:
|
215
|
+
logger.log('TRACE', f'All modules do not use proxy')
|
216
|
+
return self.proxy
|
217
|
+
if settings.proxy_all_module:
|
218
|
+
logger.log('TRACE', f'{module} module uses proxy')
|
219
|
+
return utils.get_random_proxy()
|
220
|
+
if module in settings.proxy_partial_module:
|
221
|
+
logger.log('TRACE', f'{module} module uses proxy')
|
222
|
+
return utils.get_random_proxy()
|
223
|
+
else:
|
224
|
+
logger.log('TRACE', f'{module} module does not use proxy')
|
225
|
+
return self.proxy
|
226
|
+
|
227
|
+
def match_subdomains(self, resp, distinct=True, fuzzy=True):
|
228
|
+
if not resp:
|
229
|
+
return set()
|
230
|
+
elif isinstance(resp, str):
|
231
|
+
return utils.match_subdomains(self.domain, resp, distinct, fuzzy)
|
232
|
+
elif hasattr(resp, 'text'):
|
233
|
+
return utils.match_subdomains(self.domain, resp.text, distinct, fuzzy)
|
234
|
+
else:
|
235
|
+
return set()
|
236
|
+
|
237
|
+
def collect_subdomains(self, resp):
|
238
|
+
subdomains = self.match_subdomains(resp)
|
239
|
+
self.subdomains.update(subdomains)
|
240
|
+
return self.subdomains
|
241
|
+
|
242
|
+
def save_json(self):
|
243
|
+
"""
|
244
|
+
Save the results of each module as a json file
|
245
|
+
|
246
|
+
:return bool: whether saved successfully
|
247
|
+
"""
|
248
|
+
if not settings.save_module_result:
|
249
|
+
return False
|
250
|
+
logger.log('TRACE', f'Save the subdomain results found by '
|
251
|
+
f'{self.source} module as a json file')
|
252
|
+
path = settings.result_save_dir.joinpath(self.domain, self.module)
|
253
|
+
path.mkdir(parents=True, exist_ok=True)
|
254
|
+
name = self.source + '.json'
|
255
|
+
path = path.joinpath(name)
|
256
|
+
with open(path, mode='w', errors='ignore') as file:
|
257
|
+
result = {'domain': self.domain,
|
258
|
+
'name': self.module,
|
259
|
+
'source': self.source,
|
260
|
+
'elapse': self.elapse,
|
261
|
+
'find': len(self.subdomains),
|
262
|
+
'subdomains': list(self.subdomains),
|
263
|
+
'infos': self.infos}
|
264
|
+
json.dump(result, file, ensure_ascii=False, indent=4)
|
265
|
+
return True
|
266
|
+
|
267
|
+
def gen_result(self):
|
268
|
+
"""
|
269
|
+
Generate results
|
270
|
+
"""
|
271
|
+
logger.log('DEBUG', f'Generating final results')
|
272
|
+
if not len(self.subdomains): # 该模块一个子域都没有发现的情况
|
273
|
+
logger.log('DEBUG', f'{self.source} module result is empty')
|
274
|
+
result = {'id': None,
|
275
|
+
'alive': None,
|
276
|
+
'request': None,
|
277
|
+
'resolve': None,
|
278
|
+
'url': None,
|
279
|
+
'subdomain': None,
|
280
|
+
'port': None,
|
281
|
+
'level': None,
|
282
|
+
'cname': None,
|
283
|
+
'ip': None,
|
284
|
+
'public': None,
|
285
|
+
'cdn': None,
|
286
|
+
'status': None,
|
287
|
+
'reason': None,
|
288
|
+
'title': None,
|
289
|
+
'banner': None,
|
290
|
+
'header': None,
|
291
|
+
'history': None,
|
292
|
+
'response': None,
|
293
|
+
'ip_times': None,
|
294
|
+
'cname_times': None,
|
295
|
+
'ttl': None,
|
296
|
+
'cidr': None,
|
297
|
+
'asn': None,
|
298
|
+
'org': None,
|
299
|
+
'addr': None,
|
300
|
+
'isp': None,
|
301
|
+
'resolver': None,
|
302
|
+
'module': self.module,
|
303
|
+
'source': self.source,
|
304
|
+
'elapse': self.elapse,
|
305
|
+
'find': None}
|
306
|
+
self.results.append(result)
|
307
|
+
else:
|
308
|
+
for subdomain in self.subdomains:
|
309
|
+
url = 'http://' + subdomain
|
310
|
+
level = subdomain.count('.') - self.domain.count('.')
|
311
|
+
info = self.infos.get(subdomain)
|
312
|
+
if info is None:
|
313
|
+
info = dict()
|
314
|
+
cname = info.get('cname')
|
315
|
+
ip = info.get('ip')
|
316
|
+
ip_times = info.get('ip_times')
|
317
|
+
cname_times = info.get('cname_times')
|
318
|
+
ttl = info.get('ttl')
|
319
|
+
if isinstance(cname, list):
|
320
|
+
cname = ','.join(cname)
|
321
|
+
ip = ','.join(ip)
|
322
|
+
ip_times = ','.join([str(num) for num in ip_times])
|
323
|
+
cname_times = ','.join([str(num) for num in cname_times])
|
324
|
+
ttl = ','.join([str(num) for num in ttl])
|
325
|
+
result = {'id': None,
|
326
|
+
'alive': info.get('alive'),
|
327
|
+
'request': info.get('request'),
|
328
|
+
'resolve': info.get('resolve'),
|
329
|
+
'url': url,
|
330
|
+
'subdomain': subdomain,
|
331
|
+
'port': 80,
|
332
|
+
'level': level,
|
333
|
+
'cname': cname,
|
334
|
+
'ip': ip,
|
335
|
+
'public': info.get('public'),
|
336
|
+
'cdn': info.get('cdn'),
|
337
|
+
'status': None,
|
338
|
+
'reason': info.get('reason'),
|
339
|
+
'title': None,
|
340
|
+
'banner': None,
|
341
|
+
'header': None,
|
342
|
+
'history': None,
|
343
|
+
'response': None,
|
344
|
+
'ip_times': ip_times,
|
345
|
+
'cname_times': cname_times,
|
346
|
+
'ttl': ttl,
|
347
|
+
'cidr': info.get('cidr'),
|
348
|
+
'asn': info.get('asn'),
|
349
|
+
'org': info.get('org'),
|
350
|
+
'addr': info.get('addr'),
|
351
|
+
'isp': info.get('isp'),
|
352
|
+
'resolver': info.get('resolver'),
|
353
|
+
'module': self.module,
|
354
|
+
'source': self.source,
|
355
|
+
'elapse': self.elapse,
|
356
|
+
'find': len(self.subdomains)}
|
357
|
+
self.results.append(result)
|
358
|
+
|
359
|
+
def save_db(self):
|
360
|
+
"""
|
361
|
+
Save module results into the database
|
362
|
+
"""
|
363
|
+
logger.log('DEBUG', f'Saving results to database')
|
364
|
+
lock.acquire()
|
365
|
+
db = Database()
|
366
|
+
db.create_table(self.domain)
|
367
|
+
db.save_db(self.domain, self.results, self.source)
|
368
|
+
db.close()
|
369
|
+
lock.release()
|