├── .gitignore
├── run.py
├── app
├── __init__.py
├── templates
│ ├── base.html
│ └── index.html
└── views.py
├── screenshots
└── front.png
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.pyo
3 | app.db
4 | search.db
5 | flask
6 |
7 |
--------------------------------------------------------------------------------
/run.py:
--------------------------------------------------------------------------------
1 | #!flask/bin/python
2 | from app import app
3 | app.run(debug=True)
4 |
--------------------------------------------------------------------------------
/app/__init__.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 |
3 | app = Flask(__name__)
4 |
5 | from app import views
--------------------------------------------------------------------------------
/screenshots/front.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/satwikkansal/tor-hidden-service-python/HEAD/screenshots/front.png
--------------------------------------------------------------------------------
/app/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ title }}
4 |
5 |
6 |
7 | {{ title }}
8 |
9 | {% with messages = get_flashed_messages() %}
10 | {% if messages %}
11 |
12 | {% for message in messages %}
13 | - {{ message }}
14 | {% endfor %}
15 |
16 | {% endif %}
17 | {% endwith %}
18 | {% block content %}{% endblock %}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 | {% extends "base.html" %}
3 |
4 | {% block content %}
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 | {% for post in posts %}
20 |
21 | At [{{ post.time }}], {{ post.author.nickname }} says: {{ post.body }}
22 |
23 | {% endfor %}
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/app/views.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import random
3 |
4 | from flask import render_template, redirect, request
5 | from app import app
6 |
7 | posts = []
8 |
9 | @app.route('/')
10 | @app.route('/index')
11 | def index():
12 | return render_template('index.html',
13 | title='Voice of the Internet!',
14 | posts=posts)
15 |
16 |
17 | @app.route('/submit', methods=['POST'])
18 | def submit_textarea():
19 | post_content = request.form["text"]
20 |
21 | nickname = request.form["nick"]
22 | if not nickname:
23 | nickname = "Anon" + str(random.randint(100000, 999999))
24 |
25 | posts.append(
26 | {
27 | 'author': {'nickname': nickname},
28 | 'body': post_content,
29 | 'time': datetime.datetime.now().strftime('%H:%M:%S')
30 | })
31 |
32 | return redirect('/index')
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Satwik Kansal
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # tor-hidden-service-python
2 |
3 | > A simple boilerplate of creating a `.onion` website for Tor using Flask and Python.
4 |
5 | ## Table of Contents
6 |
7 | - [Instructions](#instructions)
8 | - [Screenshots](#screenshots)
9 | - [Contributing](#contributing)
10 | - [License](#license)
11 |
12 | ## Instructions
13 |
14 | - Download Tor browser from the official site ([link](https://www.torproject.org/download/download))
15 |
16 | - Configure your hidden service.
17 | + Go to the Tor browser directory.
18 | + Open the "torrc" file in an editor. (Probably located in `Browser/TorBrowser/Data/Tor` directory)
19 | + Add the following lines to the file
20 | ```
21 | HiddenServiceDir /any/path/where/you/want/config/to/be/stored
22 | HiddenServicePort 80 127.0.0.1:5000
23 | ```
24 | + Save and close the file.
25 |
26 | - Clone this repository in your local system
27 | ```sh
28 | $ git clone https://github.com/satwikkansal/tor-hidden-service-python.git
29 | $ cd tor-hidden-service
30 | ```
31 |
32 | - Install the pypi requirements
33 | ```sh
34 | $ pip -r requirements.txt
35 | ```
36 |
37 | - Run the server
38 | ```sh
39 | $ python run.py
40 | ```
41 |
42 | - Launch the Tor Browser
43 |
44 | - Copy the url generated in the `hostname` file
45 | ```sh
46 | $ cat /path/to/config/directory/hostname
47 | >>> some-obfuscated-url.onion
48 | ```
49 |
50 | - Open this copied url in the Tor Browser and it should work :tada:
51 |
52 |
53 | ## Screenshots
54 |
55 | 
56 |
57 |
58 | ## Contributing
59 |
60 | All patches welcome!
61 |
62 |
63 | ## License
64 |
65 | MIT License - see the [LICENSE](https://github.com/satwikkansal/tor-hidden-service-python/blob/master/LICENSE) file for details.
66 |
--------------------------------------------------------------------------------