Skip to content

Commit ffd8f2f

Browse files
committed
refactor(host_info): remove unused CDN configurations and optimize header retrieval
1 parent 22433c6 commit ffd8f2f

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

bugscanx/modules/others/host_info.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class HostScanner:
3939
"headers": ["cdn-pullzone", "cdn-uid", "cdn-requestid", "cdn-cache", "cdn-zone", "bunnycdn-cache-tag"],
4040
"cname": ["b-cdn.net"]
4141
},
42-
"KeyCDN": {
43-
"headers": ["x-edge-location", "server-keycdn"],
44-
"cname": ["kxcdn.com"]
45-
},
4642
"Sucuri": {
4743
"headers": ["x-sucuri-id", "x-sucuri-cache", "x-sucuri-block", "server-sucuri"],
4844
"cname": ["sucuri.net"]
@@ -55,10 +51,6 @@ class HostScanner:
5551
"headers": ["x-cf-", "server-cachefly"],
5652
"cname": ["cachefly.net"]
5753
},
58-
"CDN77": {
59-
"headers": ["x-77-", "server-cdn77"],
60-
"cname": ["cdn77.net", "cdn77.org"]
61-
},
6254
"Alibaba": {
6355
"headers": ["ali-cdn-", "x-oss-", "server-tengine"],
6456
"cname": ["alikunlun.com", "alicdn.com"]
@@ -74,6 +66,7 @@ def __init__(self, host, protocol="https", method_list=None):
7466
self.protocol = protocol
7567
self.url = f"{protocol}://{host}"
7668
self.method_list = method_list
69+
self.http_headers = {}
7770

7871
def get_ips(self):
7972
try:
@@ -105,8 +98,11 @@ def get_cdn(self):
10598
try:
10699
detected_cdns = set()
107100

108-
response = requests.get(self.url, timeout=5)
109-
headers = {k.lower(): v.lower() for k, v in response.headers.items()}
101+
if self.http_headers:
102+
headers = {k.lower(): v.lower() for k, v in self.http_headers.items()}
103+
else:
104+
response = requests.get(self.url, timeout=5)
105+
headers = {k.lower(): v.lower() for k, v in response.headers.items()}
110106

111107
cnames = self.get_cname_records()
112108

@@ -145,6 +141,9 @@ def check_method(method):
145141

146142
for future in as_completed(futures):
147143
method, status_code, headers = future.result()
144+
145+
if method == "GET" and status_code > 0 and 'error' not in headers:
146+
self.http_headers = headers
148147

149148
status_desc = http.client.responses.get(status_code, 'Unknown Status Code')
150149
print(f"\n[bold yellow]Method: {method}[/bold yellow] | [bold magenta]Status: {status_code} {status_desc}[/bold magenta]")
@@ -188,12 +187,11 @@ def parse_cert_field(field):
188187
print(f"[bold red] Error getting SSL info: {e}[/bold red]")
189188

190189
def scan(self):
191-
192190
if not self.get_ips():
193191
return
194192

195-
self.get_cdn()
196193
self.get_http_info()
194+
self.get_cdn()
197195
self.get_sni_info()
198196

199197

0 commit comments

Comments
 (0)