Created
September 8, 2020 06:29
-
-
Save maximousblk/2f7cb476a528e23a717093cd9cd22560 to your computer and use it in GitHub Desktop.
Revisions
-
maximousblk created this gist
Sep 8, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,138 @@ # Host your own Tor hidden service! A super simple guide to spinning up a Tor hidden service. [[tl;dr]](#tldr) Ubuntu 20.04 LTS was used for the making of this guide. ### Install Tor you can install Tor using the following command ```sh sudo apt install torbrowser-launcher ``` This package includes everything you need to run a Tor hidden service and to browse them. If you're running this on a server and don't need the browser, you can install the standalone Tor daemon using the following command ```sh sudo apt install tor ``` ### Config you need to look for a `torrc` file which will most probably be in the `/etc/tor` directory. open it in an editor. you'll need to use `sudo` because it is a protected file. ```sh #nano sudo nano /etc/tor/torrc #vim sudo vim /etc/tor/torrc ``` Look for the following lines. ```conf ############### This section is just for location-hidden services ### ## Once you have configured a hidden service, you can look at the ## contents of the file ".../hidden_service/hostname" for the address ## to tell people. ## ## HiddenServicePort x y:z says to redirect requests on port x to the ## address y:z. #HiddenServiceDir /var/lib/tor/hidden_service/ #HiddenServicePort 80 127.0.0.1:80 ``` you need to uncomment these lines and update accordingly ```conf HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:PORT ``` Where `PORT` is the port number on which your application is accessible on the localhost. For this guide, we're going to use a simple directory listing server. If you have NodeJS installed, you can use the following command to start the server. ```sh npx serve -l 5000 ``` Alternatively, if you have Python 3 installed, you can use the following command to start a python http server. ```sh python3 -m http.server --bind 127.0.0.1 5000 ``` So our `torrc` file now looks like following ```conf HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:5000 ``` ### Start Tor Now that everything is configured, you can start the Tor service by using the following command. ```sh sudo tor ``` Upon starting tor for the first time, a new `.onion` address will be generated for you. you can get the address using the following command ```sh sudo cat /var/lib/tor/hidden_service/hostname ``` If you've changed the `HiddenServiceDir` setting in the `torrc` file, you can find the hostname in `<HiddenServiceDir>/hostname` file. Anyone can now visit this address using Tor Browser to use your website. ## tl;dr This is a pretty short guide though. But anyways... **Install Tor** ```sh sudo apt install tor ``` **Config** ```sh echo -e "HiddenServiceDir /var/lib/tor/hidden_service/\nHiddenServicePort 80 127.0.0.1:5000" | sudo tee -a /etc/tor/torrc ``` **Start server** ```sh # NodeJS npx serve -l 5000 # Python 3 python3 -m http.server --bind 127.0.0.1 5000 ``` **Start Tor** ```sh sudo tor ``` **Get hostname** ```sh sudo cat /var/lib/tor/hidden_service/hostname ``` And just like that, your web app is deployed on Tor. Now get off my lawn ι(`ロ´)ノ