-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathheaders.py
54 lines (50 loc) · 2.16 KB
/
headers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import app.subprocessors as subprocessors
log = logging.getLogger(__name__)
common_headers = []
with open('common/headers.txt', 'r', encoding='utf-8') as common_headers_file:
for line in common_headers_file:
common_headers.append(line.strip())
common_headers_file.close()
def main(siterequest, doshodan=True, docensys=True, dobedge=True, dozoome=True, dofofa=True):
data = {
'etag': None,
'server': None,
'cookies': [],
'interesting_headers': []
}
for hedr in siterequest.headers:
if hedr.lower() not in common_headers:
log.info('interesting header: "' + hedr + ': ' + siterequest.headers[hedr] + '"')
if hedr.lower() == 'set-cookie':
data['cookies'].append(siterequest.headers[hedr])
continue
if hedr.lower() == 'etag' or hedr.lower() == 'e-tag':
if siterequest.headers[hedr].startswith('W/'):
log.warning('the etag found is tagged as a weak validator')
data['etag'] = siterequest.headers[hedr].replace('W/', '').strip('"')
else:
data['etag'] = siterequest.headers[hedr].strip('"')
continue
if hedr.lower() == 'server':
data['server'] = siterequest.headers[hedr]
continue
data['interesting_headers'].append(hedr + ':' + siterequest.headers[hedr])
else:
log.debug('header: ' + hedr + ' ' + siterequest.headers[hedr])
if 'cf-mitigated' in data['interesting_headers'] and 'cloudflare' in data['server'].lower():
log.warning('requests are likely getting challenged by cloudflare!')
if data['etag'] is not None:
if doshodan:
subprocessors.query_shodan(data['etag'])
if docensys:
subprocessors.query_censys(data['etag'])
if dobedge:
subprocessors.query_binaryedge(data['etag'])
if dozoome:
subprocessors.query_zoomeye(data['etag'])
if dofofa:
subprocessors.query_fofa('header=' + str(data['etag']))
return data