Flask-Hidden-Service :
Flask-Hidden-Service is a small project that tries to make creating Hidden Services using Flask easier, it uses Stem , a Python controller library for Tor . In this script, Stem routes the flask application's page over tor to create a so called "Tor Hidden Service", these services can only be reached with the Tor Browser or any requesting tool using a tor proxy.
This script is still experimental and i cannot give any promise that it will work 100% fine, so do not rely on it not to leak.
This script takes the desired Tor Control Port and if chosen, generates a custom torrc file, which contains the following :
- Control Port
- Socks Port ( automatically generated by default )
- Cookie Authentication
- Run Type ( Daemon )
- Hashed Control Password ( will be auto generated )
To keep the flask-hidden-service-apps clean, you can import the script by importing the hidden_service.py
file.
This can be done by adding the following line in the import section of your program : from hidden_service import run_hidden_service
.
- To Install the requirements for the script, execute:
pip install -r requirements.txt
Most Important Detail :
In a normal flask-app you start the website by adding app.run()
to the end of the program.
Instead of doing that, you use the function provided by hidden_services called run_hidden_service and give it the
Required data :
- control_port = [PORT_YOU_CHOSE]
- application = [THE_VAR_OF_YOUR_APP] ( example : app from the code
app = Flask(__name__)
)
Optional Data :
- verbose =
True
orFalse
( this will turn the print functions of the script on or off ) - leave_address_alive =
True
orFalse
(if this is option isTrue
the onion address will be saved and reused if the same control_port or hidden_dir_name gets selected again,⚠️ the same hidden_dir_name must be used if it was used before⚠️ ) - socks_port = [CUSTOM_SOCKS_PORT] (
control_port + 1
by default ) - flask_port = [CUSTOM_FLASK_PORT] (
control_port + 2
by default ) - torrc_file =
True
orFalse
( this will turn the generation of a torrc file on or off, it is off by default ) - tor_password = [CUSTOM_TOR_PASSWORD] ( if not specified, the password will be automatically generated )
- hidden_dir_name = [CUSTOM_NAME] ( will set a custom name for the directory generated in
/tmp
) - show_requests =
True
orFalse
( this will turn the logging of requests to the website on or off )