2023-06-06 22:57:49 +00:00
# Python Internal Read Gadgets
< details >
2023-12-30 20:49:23 +00:00
< summary > < strong > Learn AWS hacking from zero to hero with< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > !< / strong > < / summary >
2023-06-06 22:57:49 +00:00
2023-12-30 20:49:23 +00:00
Other ways to support HackTricks:
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS** ](https://github.com/sponsors/carlospolop )!
2023-06-06 22:57:49 +00:00
* Get the [**official PEASS & HackTricks swag** ](https://peass.creator-spring.com )
2023-12-30 20:49:23 +00:00
* Discover [**The PEASS Family** ](https://opensea.io/collection/the-peass-family ), our collection of exclusive [**NFTs** ](https://opensea.io/collection/the-peass-family )
2024-02-06 03:10:38 +00:00
* **Join the** 💬 [**Discord group** ](https://discord.gg/hRep4RUj7f ) or the [**telegram group** ](https://t.me/peass ) or **follow** us on **Twitter** 🐦 [**@hacktricks_live** ](https://twitter.com/hacktricks_live )**.**
2023-12-30 20:49:23 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) and [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github repos.
2023-06-06 22:57:49 +00:00
< / details >
## Basic Information
Different vulnerabilities such as [**Python Format Strings** ](bypass-python-sandboxes/#python-format-string ) or [**Class Pollution** ](class-pollution-pythons-prototype-pollution.md ) might allow you to **read python internal data but won't allow you to execute code** . Therefore, a pentester will need to make the most of these read permissions to **obtain sensitive privileges and escalate the vulnerability** .
### Flask - Read secret key
The main page of a Flask application will probably have the ** `app` ** global object where this **secret is configured** .
```python
app = Flask(__name__, template_folder='templates')
app.secret_key = '(:secret:)'
```
2024-02-10 17:52:19 +00:00
**ghItlh** vItlhutlh ** 'ejwI'** **ghItlh** ** [Bypass Python sandboxes page ](bypass-python-sandboxes/ )** **gadget** ** 'e'** **access** ** 'e'** **object** ** 'e'**.
2023-06-06 22:57:49 +00:00
2024-02-10 17:52:19 +00:00
**'ejwI'** **vulnerability** ** 'e'** **python file** ** 'e'** **vItlhutlh** **gadget** ** 'e'** **files** ** 'e'** **traverse** ** 'e'** **main** ** 'e'** ** 'ej** ** 'e'** **global object `app.secret_key`** ** 'e'** **access** ** 'e'** **Flask secret key** ** 'ej** ** 'e'** ** [escalate privileges ](../../network-services-pentesting/pentesting-web/flask.md#flask-unsign )** ** 'e'**.
2023-06-06 22:57:49 +00:00
2024-02-10 17:52:19 +00:00
**payload** ** 'e'** ** 'ej** ** [writeup** ** 'e'** ** 'e'** ** (https://ctftime.org/writeup/36082)]**:
2023-06-06 22:57:49 +00:00
{% code overflow="wrap" %}
```python
__init__.__globals__.__loader__.__init__.__globals__.sys.modules.__main__.app.secret_key
```
{% endcode %}
2024-02-10 17:52:19 +00:00
**app.secret_key** (app-ghItlh) **ghItlh** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.secret_key** (app-ghItlh) **app.s
2023-06-06 22:57:49 +00:00
```python
{ua.__class__.__init__.__globals__[t].sys.modules[werkzeug.debug]._machine_id}
{ua.__class__.__init__.__globals__[t].sys.modules[werkzeug.debug].uuid._node}
```
{% hint style="warning" %}
2024-02-10 17:52:19 +00:00
Qapla'! Qa'vIn ** `app.py` ** **server local path** **ghItlh** **web page** **error** **ghItlh** **path** .
2023-06-06 22:57:49 +00:00
{% endhint %}
2024-02-10 17:52:19 +00:00
**vulnerability** **python file** **vIlegh** **Flask trick** **previous** **access** **objects** .
2023-06-06 22:57:49 +00:00
< details >
2023-12-30 20:49:23 +00:00
< summary > < strong > Learn AWS hacking from zero to hero with< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > !< / strong > < / summary >
2023-06-06 22:57:49 +00:00
2024-02-10 17:52:19 +00:00
**HackTricks** **support** **ways** :
2023-12-30 20:49:23 +00:00
2024-02-10 17:52:19 +00:00
* **company advertised** **HackTricks** **download HackTricks** **PDF** [**SUBSCRIPTION PLANS** ](https://github.com/sponsors/carlospolop ) **Check** !
* **official PEASS & HackTricks swag** [**Get** ](https://peass.creator-spring.com )
* **The PEASS Family** [**Discover** ](https://opensea.io/collection/the-peass-family ) **exclusive NFTs** [**collection** ](https://opensea.io/collection/the-peass-family ) **our** **Check**
* **Join** 💬 [**Discord group** ](https://discord.gg/hRep4RUj7f ) **telegram group** [**follow** ](https://t.me/peass ) **Twitter** 🐦 [**@hacktricks_live** ](https://twitter.com/hacktricks_live )**.**
* **Share** **hacking tricks** **submitting PRs** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) **HackTricks Cloud** [**github repos** ](https://github.com/carlospolop/hacktricks-cloud ).
2023-06-06 22:57:49 +00:00
< / details >