> 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-python-to-normal-bash-linux.md).

# 从 Python 逃逸到普通 Bash

我们现在已经可以像你一样访问服务器 `daniel` 使用与数据库关联的直通密码（例如， **drupal4hawk**）。执行连接命令：

```bash
ssh daniel@10.10.10.182
```

密码： **drupal4hawk**

登录后，我们会直接进入 Python 解释器。

<figure><img src="/files/6aae5275d7c525489cc02dc5505b51ea31fc5c10" alt=""><figcaption></figcaption></figure>

要返回到正常的 Bash shell，我们可以使用 Python 的 `os` 模块来执行 Bash 命令。步骤如下：

1. 导入模块 `os` :

   ```python
   import os
   ```
2. 运行 Bash shell：

   ```python
   os.system('/bin/bash')
   ```

这将使你能够从 Python 解释器访问普通的 Bash shell。

<figure><img src="/files/3d7ac6e76c26cf9a08b7bf47fd66537b690f16c5" 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-python-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.
