-
-
Save xserveraws/3fc6fdd21a2a8cdb5b9c35fe6b16abe8 to your computer and use it in GitHub Desktop.
Revisions
-
DusanMadar revised this gist
Oct 3, 2022 . 1 changed file with 2 additions and 2 deletions.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 @@ -158,13 +158,13 @@ root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ fail ] ``` Privoxy is unable to start, let's inspect logs. ```console root@ff788ea93ee0:/# cat /var/log/privoxy/logfile 2019-07-21 09:16:58.278 7f9c2c0e30c0 Fatal error: can't bind to ::1:8118: No such file or directory ``` The message means privoxy cannot use `IPv6`. Let's disable listening on an IPv6 address by commenting out the setting. ```console root@ff788ea93ee0:/# sed -i "s/.*\[::1\]:8118/# &/" /etc/privoxy/config ``` -
DusanMadar revised this gist
Dec 6, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -179,7 +179,7 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ 176.10.99.200 ``` ### 12. Change and check Tor IP with Python3 ```console root@75f6721089f2:/# pip3 install requests==2.26.0 root@75f6721089f2:/# python3 -
DusanMadar revised this gist
Dec 5, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -1,6 +1,6 @@ # A step-by-step guide how to use Python with Tor and Privoxy Latest revision: 2021-12-05. Tested on **Ubuntu 18.04 Docker container**. The Dockerfile is a single line `FROM ubuntu:18.04`. Alternatively, you can simply run `docker run -it ubuntu:18.04 bash`. -
DusanMadar revised this gist
Dec 5, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -2,7 +2,7 @@ Latest revision: 2021-12-05 Tested on **Ubuntu 18.04 Docker container**. The Dockerfile is a single line `FROM ubuntu:18.04`. Alternatively, you can simply run `docker run -it ubuntu:18.04 bash`. NOTE: stopping services didn't work for me for some reason. That's why there is `kill $(pidof <service name>)` after each failed `service <service name> stop` to kill it. -
DusanMadar revised this gist
Dec 5, 2021 . 1 changed file with 2 additions and 0 deletions.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 @@ -1,5 +1,7 @@ # A step-by-step guide how to use Python with Tor and Privoxy Latest revision: 2021-12-05 Tested on Ubuntu 18.04 Docker container. The Dockerfile is a single line `FROM ubuntu:18.04`. Alternatively, you can simply run `docker run -it ubuntu:18.04 bash`. NOTE: stopping services didn't work for me for some reason. That's why there is `kill $(pidof <service name>)` after each failed `service <service name> stop` to kill it. -
DusanMadar revised this gist
Dec 5, 2021 . 1 changed file with 10 additions and 2 deletions.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 @@ -33,6 +33,8 @@ This guide is basically a compilation of all the resources listed below. ```console root@75f6721089f2:/# apt update root@75f6721089f2:/# apt install -y tor root@75f6721089f2:/# tor --version Tor version 0.3.2.10 (git-0edaa32732ec8930). root@75f6721089f2:/# service tor status * cannot read PID file /var/run/tor/tor.pid ``` @@ -119,6 +121,10 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ### 10. Change (with Python3) and check Tor IP ```console root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# python3 --version Python 3.6.9 root@75f6721089f2:/# pip3 --version pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6) root@75f6721089f2:/# pip3 install stem==1.8.0 root@75f6721089f2:/# python3 ``` @@ -141,6 +147,8 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ Now that it's clear Tor is configured and works properly we can include `privoxy` to the loop. ```console root@75f6721089f2:/# apt install -y privoxy root@75f6721089f2:/# privoxy --version Privoxy version 3.0.26 (https://www.privoxy.org/) root@75f6721089f2:/# service privoxy status * privoxy is not running root@75f6721089f2:/# echo "forward-socks5t / 127.0.0.1:9050 ." >> /etc/privoxy/config @@ -171,7 +179,7 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ ### 12. Change and check Tor IP solely with Python3 ```console root@75f6721089f2:/# pip3 install requests==2.26.0 root@75f6721089f2:/# python3 ``` ```python @@ -201,7 +209,7 @@ root@75f6721089f2:/# python3 ### 13. [bonus] Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ```console root@75f6721089f2:/# pip3 install toripchanger==1.1.3 root@75f6721089f2:/# python3 ``` ```python -
DusanMadar revised this gist
Dec 5, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -119,7 +119,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ### 10. Change (with Python3) and check Tor IP ```console root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem==1.8.0 root@75f6721089f2:/# python3 ``` ```python -
DusanMadar revised this gist
Mar 26, 2020 . 1 changed file with 6 additions and 2 deletions.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 @@ -19,9 +19,13 @@ This guide is basically a compilation of all the resources listed below. ## Related * Other awesome open-source projects * [Tor and Privoxy (web proxy configured to route through tor) Docker container](https://github.com/dperson/torproxy) * [Rotating TOR proxy with Docker](https://github.com/mattes/rotating-proxy) * Mine * [A step-by-step guide how to use Tor without Authentication](https://gist.github.com/DusanMadar/c1155329cf6a71e4346cae271a2eafd3) * [TorIpChanger - Python powered way to get a unique Tor IP](https://github.com/DusanMadar/TorIpChanger) ## Steps -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 4 additions and 0 deletions.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 @@ -187,6 +187,10 @@ root@75f6721089f2:/# python3 >>> response = requests.get('http://icanhazip.com/', proxies={'http': '127.0.0.1:8118'}) >>> response.text.strip() '87.118.92.43' >>> >>> response = requests.get('https://api.myip.com/', proxies={'https': '127.0.0.1:8118'}) >>> response.json() {"ip": "87.118.92.43", "country": "Germany", "cc": "DE"} >>> ``` -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 3 additions and 1 deletion.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 @@ -117,6 +117,8 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem root@75f6721089f2:/# python3 ``` ```python >>> from stem import Signal >>> from stem.control import Controller >>> @@ -126,7 +128,7 @@ root@75f6721089f2:/# python3 ... >>> ``` ```console root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.107.81.233 ``` -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 15 additions and 17 deletions.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 @@ -34,7 +34,7 @@ root@75f6721089f2:/# service tor status ``` ### 2. Start Tor and check it's running ```console root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] root@75f6721089f2:/# service tor status @@ -43,14 +43,14 @@ root@75f6721089f2:/# service tor status ### 3. Try to Authenticate with nc (Netcat) It's not possible to connect as `ControlPort` is not set yet. ```console root@75f6721089f2:/# apt install -y netcat root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 (UNKNOWN) [127.0.0.1] 9051 (?) : Connection refused ``` ### 4. Stop/kill Tor, set ControlPort and start Tor again ```console root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -63,15 +63,15 @@ root@75f6721089f2:/# service tor start ### 5. Try to Authenticate with nc again It's possible to connect but Authentication fails. ```console root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Wrong length on authentication cookie. ``` ### 6. Stop/kill Tor, set and check `HashedControlPassword` then start Tor again Make sure that you have something like `HashedControlPassword 16:ED2893D8EC97801C60DF4A72249CBCCD8B97B3B01A15C923DC49A0E500` (actual password hash can/will differ) in `/etc/tor/torrc`. ```console root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -85,7 +85,7 @@ root@75f6721089f2:/# service tor start ### 7. Try to Authenticate with nc again Authentication passes with a correct password. ```console # NOTE Use Ctrl+C to exit. root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Password did not match HashedControlPassword *or* authentication cookie. @@ -94,7 +94,7 @@ root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"' | nc 127.0.0.1 9051 ``` ### 8. Check your public IP and currently used Tor ip ```console root@75f6721089f2:/# apt install -y curl root@75f6721089f2:/# curl http://icanhazip.com/ 89.196.159.79 @@ -103,7 +103,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 9. Change and check Tor IP ```console root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 250 OK 250 OK @@ -113,12 +113,10 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 10. Change (with Python3) and check Tor IP ```console root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem root@75f6721089f2:/# python3 >>> from stem import Signal >>> from stem.control import Controller >>> @@ -135,7 +133,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ### 11. Install privoxy and check traffic is routed through Tor Now that it's clear Tor is configured and works properly we can include `privoxy` to the loop. ```console root@75f6721089f2:/# apt install -y privoxy root@75f6721089f2:/# service privoxy status * privoxy is not running @@ -145,18 +143,18 @@ root@75f6721089f2:/# service privoxy start ``` Privoxy is unable to start, lets inspect logs. ```console root@ff788ea93ee0:/# cat /var/log/privoxy/logfile 2019-07-21 09:16:58.278 7f9c2c0e30c0 Fatal error: can't bind to ::1:8118: No such file or directory ``` The message means privoxy cannot use `IPv6`. Lets disable listening on an IPv6 address by commenting out the setting. ```console root@ff788ea93ee0:/# sed -i "s/.*\[::1\]:8118/# &/" /etc/privoxy/config ``` Now we should be able to start and use privoxy ```console root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ OK ] root@75f6721089f2:/# torify curl http://icanhazip.com/ @@ -166,7 +164,7 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ ``` ### 12. Change and check Tor IP solely with Python3 ```console root@75f6721089f2:/# pip3 install requests root@75f6721089f2:/# python3 ``` @@ -192,7 +190,7 @@ root@75f6721089f2:/# python3 ### 13. [bonus] Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ```console root@75f6721089f2:/# pip3 install toripchanger root@75f6721089f2:/# python3 ``` -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -26,7 +26,7 @@ This guide is basically a compilation of all the resources listed below. ## Steps ### 1. Install and check Tor status ```console root@75f6721089f2:/# apt update root@75f6721089f2:/# apt install -y tor root@75f6721089f2:/# service tor status -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -166,7 +166,7 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ ``` ### 12. Change and check Tor IP solely with Python3 ``` root@75f6721089f2:/# pip3 install requests root@75f6721089f2:/# python3 ``` -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -192,7 +192,7 @@ root@75f6721089f2:/# python3 ### 13. [bonus] Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ``` root@75f6721089f2:/# pip3 install toripchanger root@75f6721089f2:/# python3 ``` -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 18 additions and 25 deletions.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 @@ -26,15 +26,15 @@ This guide is basically a compilation of all the resources listed below. ## Steps ### 1. Install and check Tor status ``` root@75f6721089f2:/# apt update root@75f6721089f2:/# apt install -y tor root@75f6721089f2:/# service tor status * cannot read PID file /var/run/tor/tor.pid ``` ### 2. Start Tor and check it's running ``` root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] root@75f6721089f2:/# service tor status @@ -43,14 +43,14 @@ root@75f6721089f2:/# service tor status ### 3. Try to Authenticate with nc (Netcat) It's not possible to connect as `ControlPort` is not set yet. ``` root@75f6721089f2:/# apt install -y netcat root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 (UNKNOWN) [127.0.0.1] 9051 (?) : Connection refused ``` ### 4. Stop/kill Tor, set ControlPort and start Tor again ``` root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -63,15 +63,15 @@ root@75f6721089f2:/# service tor start ### 5. Try to Authenticate with nc again It's possible to connect but Authentication fails. ``` root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Wrong length on authentication cookie. ``` ### 6. Stop/kill Tor, set and check `HashedControlPassword` then start Tor again Make sure that you have something like `HashedControlPassword 16:ED2893D8EC97801C60DF4A72249CBCCD8B97B3B01A15C923DC49A0E500` (actual password hash can/will differ) in `/etc/tor/torrc`. ``` root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -85,7 +85,7 @@ root@75f6721089f2:/# service tor start ### 7. Try to Authenticate with nc again Authentication passes with a correct password. ``` # NOTE Use Ctrl+C to exit. root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Password did not match HashedControlPassword *or* authentication cookie. @@ -94,7 +94,7 @@ root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"' | nc 127.0.0.1 9051 ``` ### 8. Check your public IP and currently used Tor ip ``` root@75f6721089f2:/# apt install -y curl root@75f6721089f2:/# curl http://icanhazip.com/ 89.196.159.79 @@ -103,7 +103,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 9. Change and check Tor IP ``` root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 250 OK 250 OK @@ -113,15 +113,12 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 10. Change (with Python3) and check Tor IP ``` root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem root@75f6721089f2:/# python3 ``` ```python >>> from stem import Signal >>> from stem.control import Controller >>> @@ -131,14 +128,14 @@ Type "help", "copyright", "credits" or "license" for more information. ... >>> ``` ``` root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.107.81.233 ``` ### 11. Install privoxy and check traffic is routed through Tor Now that it's clear Tor is configured and works properly we can include `privoxy` to the loop. ``` root@75f6721089f2:/# apt install -y privoxy root@75f6721089f2:/# service privoxy status * privoxy is not running @@ -148,18 +145,18 @@ root@75f6721089f2:/# service privoxy start ``` Privoxy is unable to start, lets inspect logs. ``` root@ff788ea93ee0:/# cat /var/log/privoxy/logfile 2019-07-21 09:16:58.278 7f9c2c0e30c0 Fatal error: can't bind to ::1:8118: No such file or directory ``` The message means privoxy cannot use `IPv6`. Lets disable listening on an IPv6 address by commenting out the setting. ``` root@ff788ea93ee0:/# sed -i "s/.*\[::1\]:8118/# &/" /etc/privoxy/config ``` Now we should be able to start and use privoxy ``` root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ OK ] root@75f6721089f2:/# torify curl http://icanhazip.com/ @@ -174,9 +171,6 @@ root@75f6721089f2:/# pip3 install requests root@75f6721089f2:/# python3 ``` ```python >>> import requests >>> >>> from stem import Signal @@ -198,12 +192,11 @@ Type "help", "copyright", "credits" or "license" for more information. ### 13. [bonus] Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ```bash root@75f6721089f2:/# pip3 install toripchanger root@75f6721089f2:/# python3 ``` ```python >>> from toripchanger import TorIpChanger >>> >>> tor_ip_changer = TorIpChanger(tor_password='my password', tor_port=9051, local_http_proxy='127.0.0.1:8118') -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 2 additions and 1 deletion.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 @@ -130,6 +130,8 @@ Type "help", "copyright", "credits" or "license" for more information. ... controller.signal(Signal.NEWNYM) ... >>> ``` ```bash root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.107.81.233 ``` @@ -166,7 +168,6 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ 176.10.99.200 ``` ### 12. Change and check Tor IP solely with Python3 ```bash root@75f6721089f2:/# pip3 install requests -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 17 additions and 13 deletions.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 @@ -43,14 +43,14 @@ root@75f6721089f2:/# service tor status ### 3. Try to Authenticate with nc (Netcat) It's not possible to connect as `ControlPort` is not set yet. ```bash root@75f6721089f2:/# apt install -y netcat root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 (UNKNOWN) [127.0.0.1] 9051 (?) : Connection refused ``` ### 4. Stop/kill Tor, set ControlPort and start Tor again ```bash root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -63,15 +63,15 @@ root@75f6721089f2:/# service tor start ### 5. Try to Authenticate with nc again It's possible to connect but Authentication fails. ```bash root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Wrong length on authentication cookie. ``` ### 6. Stop/kill Tor, set and check `HashedControlPassword` then start Tor again Make sure that you have something like `HashedControlPassword 16:ED2893D8EC97801C60DF4A72249CBCCD8B97B3B01A15C923DC49A0E500` (actual password hash can/will differ) in `/etc/tor/torrc`. ```bash root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) @@ -85,7 +85,7 @@ root@75f6721089f2:/# service tor start ### 7. Try to Authenticate with nc again Authentication passes with a correct password. ```bash # NOTE Use Ctrl+C to exit. root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Password did not match HashedControlPassword *or* authentication cookie. @@ -94,7 +94,7 @@ root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"' | nc 127.0.0.1 9051 ``` ### 8. Check your public IP and currently used Tor ip ```bash root@75f6721089f2:/# apt install -y curl root@75f6721089f2:/# curl http://icanhazip.com/ 89.196.159.79 @@ -103,7 +103,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 9. Change and check Tor IP ```bash root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 250 OK 250 OK @@ -113,10 +113,12 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ``` ### 10. Change (with Python3) and check Tor IP ```bash root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem root@75f6721089f2:/# python3 ``` ```python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. @@ -134,7 +136,7 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ ### 11. Install privoxy and check traffic is routed through Tor Now that it's clear Tor is configured and works properly we can include `privoxy` to the loop. ```bash root@75f6721089f2:/# apt install -y privoxy root@75f6721089f2:/# service privoxy status * privoxy is not running @@ -144,18 +146,18 @@ root@75f6721089f2:/# service privoxy start ``` Privoxy is unable to start, lets inspect logs. ```bash root@ff788ea93ee0:/# cat /var/log/privoxy/logfile 2019-07-21 09:16:58.278 7f9c2c0e30c0 Fatal error: can't bind to ::1:8118: No such file or directory ``` The message means privoxy cannot use `IPv6`. Lets disable listening on an IPv6 address by commenting out the setting. ```bash root@ff788ea93ee0:/# sed -i "s/.*\[::1\]:8118/# &/" /etc/privoxy/config ``` Now we should be able to start and use privoxy ```bash root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ OK ] root@75f6721089f2:/# torify curl http://icanhazip.com/ @@ -166,9 +168,11 @@ root@75f6721089f2:/# curl -x 127.0.0.1:8118 http://icanhazip.com/ ### 12. Change and check Tor IP solely with Python3 ```bash root@75f6721089f2:/# pip3 install requests root@75f6721089f2:/# python3 ``` ```python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 2 additions and 2 deletions.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 @@ -26,15 +26,15 @@ This guide is basically a compilation of all the resources listed below. ## Steps ### 1. Install and check Tor status ```bash root@75f6721089f2:/# apt update root@75f6721089f2:/# apt install -y tor root@75f6721089f2:/# service tor status * cannot read PID file /var/run/tor/tor.pid ``` ### 2. Start Tor and check it's running ```bash root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] root@75f6721089f2:/# service tor status -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 3 additions and 0 deletions.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 @@ -5,6 +5,9 @@ Tested on Ubuntu 18.04 Docker container. The Dockerfile is a single line `FROM u NOTE: stopping services didn't work for me for some reason. That's why there is `kill $(pidof <service name>)` after each failed `service <service name> stop` to kill it. ## References This guide is basically a compilation of all the resources listed below. * [How to request new TOR identity in terminal](https://stackoverflow.com/q/16987518/4183498) * [How to anonymize the programs from your terminal with torify](https://linuxaria.com/howto/how-to-anonymize-the-programs-from-your-terminal-with-torify) * [How To: Using Tor From The Command Line](https://justhackerthings.com/post/using-tor-from-the-command-line/) -
DusanMadar revised this gist
Jul 21, 2019 . 1 changed file with 30 additions and 26 deletions.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 @@ -1,8 +1,8 @@ # A step-by-step guide how to use Python with Tor and Privoxy Tested on Ubuntu 18.04 Docker container. The Dockerfile is a single line `FROM ubuntu:18.04`. Alternatively, you can simply run `docker run -it ubuntu:18.04 bash`. NOTE: stopping services didn't work for me for some reason. That's why there is `kill $(pidof <service name>)` after each failed `service <service name> stop` to kill it. ## References * [How to request new TOR identity in terminal](https://stackoverflow.com/q/16987518/4183498) @@ -25,58 +25,53 @@ NOTE: stopping services didn't work for me for some reason. That's why there is ### 1. Install and check Tor status ``` root@75f6721089f2:/# apt update root@75f6721089f2:/# apt install -y tor root@75f6721089f2:/# service tor status * cannot read PID file /var/run/tor/tor.pid ``` ### 2. Start Tor and check it's running ``` root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] root@75f6721089f2:/# service tor status * tor is running ``` ### 3. Try to Authenticate with nc (Netcat) It's not possible to connect as `ControlPort` is not set yet. ``` root@75f6721089f2:/# apt install -y netcat root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 (UNKNOWN) [127.0.0.1] 9051 (?) : Connection refused ``` ### 4. Stop/kill Tor, set ControlPort and start Tor again ``` root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) root@75f6721089f2:/# service tor status * tor is not running root@75f6721089f2:/# echo "ControlPort 9051" >> /etc/tor/torrc root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] ``` ### 5. Try to Authenticate with nc again It's possible to connect but Authentication fails. ``` root@75f6721089f2:/# echo -e 'AUTHENTICATE' | nc 127.0.0.1 9051 515 Authentication failed: Wrong length on authentication cookie. ``` ### 6. Stop/kill Tor, set and check `HashedControlPassword` then start Tor again Make sure that you have something like `HashedControlPassword 16:ED2893D8EC97801C60DF4A72249CBCCD8B97B3B01A15C923DC49A0E500` (actual password hash can/will differ) in `/etc/tor/torrc`. ``` root@75f6721089f2:/# service tor stop * Stopping tor daemon... [fail] root@75f6721089f2:/# kill $(pidof tor) root@75f6721089f2:/# echo HashedControlPassword $(tor --hash-password "my password" | tail -n 1) >> /etc/tor/torrc root@75f6721089f2:/# tail -n 2 /etc/tor/torrc ControlPort 9051 @@ -85,7 +80,6 @@ root@75f6721089f2:/# service tor start * Starting tor daemon... [ OK ] ``` ### 7. Try to Authenticate with nc again Authentication passes with a correct password. ``` @@ -96,17 +90,15 @@ root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"' | nc 127.0.0.1 9051 250 OK ``` ### 8. Check your public IP and currently used Tor ip ``` root@75f6721089f2:/# apt install -y curl root@75f6721089f2:/# curl http://icanhazip.com/ 89.196.159.79 root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.220.101.17 ``` ### 9. Change and check Tor IP ``` root@75f6721089f2:/# echo -e 'AUTHENTICATE "my password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 @@ -117,11 +109,9 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.220.101.6 ``` ### 10. Change (with Python3) and check Tor IP ``` root@75f6721089f2:/# apt install -y python3 python3-pip root@75f6721089f2:/# pip3 install stem root@75f6721089f2:/# python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) @@ -139,16 +129,30 @@ root@75f6721089f2:/# torify curl http://icanhazip.com/ 185.107.81.233 ``` ### 11. Install privoxy and check traffic is routed through Tor Now that it's clear Tor is configured and works properly we can include `privoxy` to the loop. ``` root@75f6721089f2:/# apt install -y privoxy root@75f6721089f2:/# service privoxy status * privoxy is not running root@75f6721089f2:/# echo "forward-socks5t / 127.0.0.1:9050 ." >> /etc/privoxy/config root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ fail ] ``` Privoxy is unable to start, lets inspect logs. ``` root@ff788ea93ee0:/# cat /var/log/privoxy/logfile 2019-07-21 09:16:58.278 7f9c2c0e30c0 Fatal error: can't bind to ::1:8118: No such file or directory ``` The message means privoxy cannot use `IPv6`. Lets disable listening on an IPv6 address by commenting out the setting. ``` root@ff788ea93ee0:/# sed -i "s/.*\[::1\]:8118/# &/" /etc/privoxy/config ``` Now we should be able to start and use privoxy ``` root@75f6721089f2:/# service privoxy start * Starting filtering proxy server privoxy [ OK ] root@75f6721089f2:/# torify curl http://icanhazip.com/ -
DusanMadar revised this gist
Jul 15, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -185,7 +185,7 @@ Type "help", "copyright", "credits" or "license" for more information. ``` ### 13. [bonus] Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ``` root@75f6721089f2:/# pip3 install toripchanger root@75f6721089f2:/# python3 -
DusanMadar revised this gist
Nov 14, 2018 . 1 changed file with 0 additions and 5 deletions.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 @@ -192,15 +192,10 @@ root@75f6721089f2:/# python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from toripchanger import TorIpChanger >>> >>> tor_ip_changer = TorIpChanger(tor_password='my password', tor_port=9051, local_http_proxy='127.0.0.1:8118') >>> tor_ip_changer.get_new_ip() '185.24.218.182' >>> ``` -
DusanMadar revised this gist
Nov 14, 2018 . 1 changed file with 5 additions and 0 deletions.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 @@ -192,10 +192,15 @@ root@75f6721089f2:/# python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> >>> from toripchanger import TorIpChanger >>> >>> tor_ip_changer = TorIpChanger(tor_password='my password', tor_port=9051, local_http_proxy='127.0.0.1:8118') >>> tor_ip_changer.get_new_ip() '185.24.218.182' >>> >>> response = requests.get('http://icanhazip.com/', proxies={'http': '127.0.0.1:8118'}) >>> response.text.strip() '185.24.218.182' ``` -
DusanMadar revised this gist
Nov 14, 2018 . 1 changed file with 16 additions and 0 deletions.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 @@ -182,4 +182,20 @@ Type "help", "copyright", "credits" or "license" for more information. >>> response.text.strip() '87.118.92.43' >>> ``` ### 13. Change and check Tor IP with [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ``` root@75f6721089f2:/# pip3 install toripchanger root@75f6721089f2:/# python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from toripchanger import TorIpChanger >>> >>> tor_ip_changer = TorIpChanger(tor_password='my password', tor_port=9051, local_http_proxy='127.0.0.1:8118') >>> tor_ip_changer.get_new_ip() '185.24.218.182' >>> ``` -
DusanMadar revised this gist
Jun 7, 2018 . 1 changed file with 1 addition and 1 deletion.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 @@ -17,7 +17,7 @@ NOTE: stopping services didn't work for me for some reason. That's why there is ## Related * [A step-by-step guide how to use Tor without Authentication](https://gist.github.com/DusanMadar/c1155329cf6a71e4346cae271a2eafd3) * [TorIpChanger - Python powered way to get a unique Tor IP](https://github.com/DusanMadar/TorIpChanger) ## Steps -
DusanMadar revised this gist
Jun 7, 2018 . 1 changed file with 1 addition and 0 deletions.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 @@ -17,6 +17,7 @@ NOTE: stopping services didn't work for me for some reason. That's why there is ## Related * [A step-by-step guide how to use Tor without Authentication](https://gist.github.com/DusanMadar/c1155329cf6a71e4346cae271a2eafd3) * [TorIpChanger](https://github.com/DusanMadar/TorIpChanger) ## Steps -
DusanMadar revised this gist
Jun 7, 2018 . 1 changed file with 1 addition and 0 deletions.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 @@ -9,6 +9,7 @@ NOTE: stopping services didn't work for me for some reason. That's why there is * [How to anonymize the programs from your terminal with torify](https://linuxaria.com/howto/how-to-anonymize-the-programs-from-your-terminal-with-torify) * [How To: Using Tor From The Command Line](https://justhackerthings.com/post/using-tor-from-the-command-line/) * [How to change Tor identity in Python?](https://stackoverflow.com/q/9887505/4183498) * [Make requests using Python over Tor](https://stackoverflow.com/q/30286293/4183498) * [Crawling anonymously with Tor in Python](http://sacharya.com/crawling-anonymously-with-tor-in-python/) * [Alternative link (Gist) for "Crawling anonymously with Tor in Python"](https://gist.github.com/KhepryQuixote/46cf4f3b999d7f658853) * [Tor IP changing and web scraping](https://dm295.blogspot.com/2016/02/tor-ip-changing-and-web-scraping.html) -
DusanMadar revised this gist
Feb 6, 2018 . 1 changed file with 2 additions and 0 deletions.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 @@ -18,6 +18,8 @@ NOTE: stopping services didn't work for me for some reason. That's why there is * [A step-by-step guide how to use Tor without Authentication](https://gist.github.com/DusanMadar/c1155329cf6a71e4346cae271a2eafd3) ## Steps ### 1. Install and check Tor status ``` root@75f6721089f2:/# apt update -
DusanMadar revised this gist
Jan 22, 2018 . 1 changed file with 1 addition and 1 deletion.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 @@ -2,7 +2,7 @@ Tested on Ubuntu 16.04 Docker container. The Dockerfile is a single line `FROM ubuntu:16.04`. NOTE: stopping services didn't work for me for some reason. That's why there is `pidof <service name> | xargs kill` after each failed `service <service name> stop` to kill it. ## References * [How to request new TOR identity in terminal](https://stackoverflow.com/q/16987518/4183498) -
DusanMadar revised this gist
Jan 22, 2018 . 1 changed file with 1 addition and 1 deletion.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 @@ -2,7 +2,7 @@ Tested on Ubuntu 16.04 Docker container. The Dockerfile is a single line `FROM ubuntu:16.04`. NOTE: stopping services for some reason didn't work for me. That's why there is `pidof <service name> | xargs kill` after each failed `service <service name> stop` to kill it. ## References * [How to request new TOR identity in terminal](https://stackoverflow.com/q/16987518/4183498)
NewerOlder