--- title: 'Forward Proxy using TOR' disqus: hackmd --- Forward Proxy using TOR === ## Table of Contents [TOC] ## Descriptions ### Forward Proxy A forward proxy is an intermediate connection point at a network's edge that is regulates outbound traffic according to preset policies in shred networks. ![](https://i.imgur.com/SANvSDi.png) *source: [www.imperva.com](https://www.imperva.com/learn/performance/reverse-proxy/)* **Why I want to use TOR Proxy?** If you need a way to use the TOR network with your current browser (not using TOR Browser) or you need to connect a number of computers maintaining theor ### TOR ![](https://i.imgur.com/uPEMYeO.png) Tor is short for The Union Router and was initially a worldwide network of servers developed with the U.S. Navy that enabled people to browse the internet anonymously. Now, it's a non-profit organization whose main purpose is the research and development of online privacy tools. **WHAT IS TOR IS GOOD FOR?** Tor is useful for anyone who wants to keep their internet activities out of the hands of advertisers, ISPs, and websites. That includes people getting around cencorship restrictions in their country, people looking to hide their IP address, or anyone else who doesn't want their browsing habits linked to them. *source: [lifehacker.com](https://lifehacker.com/what-is-tor-and-should-i-use-it-1527891029#:~:text=Tor%20is%20useful%20for%20anyone,browsing%20habits%20linked%20to%20them.)* Installation --- 1. Install TOR ``` sudo apt-get update sudo apt-get upgrade sudo apt-get install tor ### Check the service service tor status ``` 2. Configure TOR The configuration file for TOR located in `/etc/tor/torrc` Let's backup the copy and edit the configuration: ``` sudo cp /etc/tor/torrc /etc/tor/torrc.backup sudo vi /etc/tor/torrc ``` The configuration for this setup should include: ``` SocksPort 192.168.1.100:9050 SocksPolicy accept 192.168.1.0/24 RunAsDaemon 1 DataDirectory /var/lib/tor ``` > NB: In this setup, our Proxy IP is 192.168.1.100 and Port 9050. remember to edit this part. 3. Connect to TOR Proxy On MAC OS, you could configure on network setting: ![](https://i.imgur.com/A8nDoYq.png) On Widows may looks like this: ![](https://i.imgur.com/du9JGhG.png) 4. Checking After the configuration has been done, you could try to open this url https://check.torproject.org/?lang=en and it will show whether or not you successfully connected with TOR network. ![](https://i.imgur.com/YTcucbN.png) ## Docker Setup Besides to install the Proxy directly on a single machine, you could also install it inside docker container. The steps are the same. Here the link for the docker image (example): https://hub.docker.com/repository/docker/bennoli13/fwd_proxy ### Run Docker Proxy ``` sudo docker run -ti -p 9050:9050 bennoli13/fwd_proxy {container_id}:/# service tor start ``` ### Bug If you find out that you cannot run the command `service tor stop` or `service tor restart`, please use `kill` instead: ``` {container_id}:/# ps -aux | grep tor {container_id}:/# kill {PID} ``` ## ExitNodes You could configure ExitNode to force TOR network use specific exit nodes. By default, TOR randomly chooses which exit node to use when browsing the internet. If you know exactly which exit node you would like to use, you can define it by adding its specific IP or identity fingerprint or you could set it to use exit nodes only in a specific country. All can be configured in TOR configuration file. **Using IP Address** ``` ExitNodes 176.10.99.202 ``` **Using fingerprint** ``` ExitNodes 19B6F025B4580795FBD9F3ED3C6574CDAF979A2F ``` **Using a specific country** ``` ExitNodes {TW} StrictNodes 1 ``` **Using multiple countries** ``` ExitNodes {TW},{ID},{TH} StrictNodes 1 ``` Source: https://communitydocs.accessnow.org/147-Tor_force_exit_nodes.html ### TOR ExitNodes Countries List ```gherkin= Country Code ASCENSION ISLAND {ac} AFGHANISTAN {af} ALAND {ax} ALBANIA {al} ALGERIA {dz} ANDORRA {ad} ANGOLA {ao} ANGUILLA {ai} ANTARCTICA {aq} ANTIGUA AND BARBUDA {ag} ARGENTINA REPUBLIC {ar} ARMENIA {am} ARUBA {aw} AUSTRALIA {au} AUSTRIA {at} AZERBAIJAN {az} BAHAMAS {bs} BAHRAIN {bh} BANGLADESH {bd} BARBADOS {bb} BELARUS {by} BELGIUM {be} BELIZE {bz} BENIN {bj} BERMUDA {bm} BHUTAN {bt} BOLIVIA {bo} BOSNIA AND HERZEGOVINA {ba} BOTSWANA {bw} BOUVET ISLAND {bv} BRAZIL {br} BRITISH INDIAN OCEAN TERR {io} BRITISH VIRGIN ISLANDS {vg} BRUNEI DARUSSALAM {bn} BULGARIA {bg} BURKINA FASO {bf} BURUNDI {bi} CAMBODIA {kh} CAMEROON {cm} CANADA {ca} CAPE VERDE {cv} CAYMAN ISLANDS {ky} CENTRAL AFRICAN REPUBLIC {cf} CHAD {td} CHILE {cl} PEOPLE'S REPUBLIC OF CHINA {cn} CHRISTMAS ISLANDS {cx} COCOS ISLANDS {cc} COLOMBIA {co} COMORAS {km} CONGO {cg} CONGO (DEMOCRATIC REPUBLIC) {cd} COOK ISLANDS {ck} COSTA RICA {cr} COTE D IVOIRE {ci} CROATIA {hr} CUBA {cu} CYPRUS {cy} CZECH REPUBLIC {cz} DENMARK {dk} DJIBOUTI {dj} DOMINICA {dm} DOMINICAN REPUBLIC {do} EAST TIMOR {tp} ECUADOR {ec} EGYPT {eg} EL SALVADOR {sv} EQUATORIAL GUINEA {gq} ESTONIA {ee} ETHIOPIA {et} FALKLAND ISLANDS {fk} FAROE ISLANDS {fo} FIJI {fj} FINLAND {fi} FRANCE {fr} FRANCE METROPOLITAN {fx} FRENCH GUIANA {gf} FRENCH POLYNESIA {pf} FRENCH SOUTHERN TERRITORIES {tf} GABON {ga} GAMBIA {gm} GEORGIA {ge} GERMANY {de} GHANA {gh} GIBRALTER {gi} GREECE {gr} GREENLAND {gl} GRENADA {gd} GUADELOUPE {gp} GUAM {gu} GUATEMALA {gt} GUINEA {gn} GUINEA-BISSAU {gw} GUYANA {gy} HAITI {ht} HEARD & MCDONALD ISLAND {hm} HONDURAS {hn} HONG KONG {hk} HUNGARY {hu} ICELAND {is} INDIA {in} INDONESIA {id} IRAN, ISLAMIC REPUBLIC OF {ir} IRAQ {iq} IRELAND {ie} ISLE OF MAN {im} ISRAEL {il} ITALY {it} JAMAICA {jm} JAPAN {jp} JORDAN {jo} KAZAKHSTAN {kz} KENYA {ke} KIRIBATI {ki} KOREA, DEM. PEOPLES REP OF {kp} KOREA, REPUBLIC OF {kr} KUWAIT {kw} KYRGYZSTAN {kg} LAO PEOPLE'S DEM. REPUBLIC {la} LATVIA {lv} LEBANON {lb} LESOTHO {ls} LIBERIA {lr} LIBYAN ARAB JAMAHIRIYA {ly} LIECHTENSTEIN {li} LITHUANIA {lt} LUXEMBOURG {lu} MACAO {mo} MACEDONIA {mk} MADAGASCAR {mg} MALAWI {mw} MALAYSIA {my} MALDIVES {mv} MALI {ml} MALTA {mt} MARSHALL ISLANDS {mh} MARTINIQUE {mq} MAURITANIA {mr} MAURITIUS {mu} MAYOTTE {yt} MEXICO {mx} MICRONESIA {fm} MOLDAVA REPUBLIC OF {md} MONACO {mc} MONGOLIA {mn} MONTENEGRO {me} MONTSERRAT {ms} MOROCCO {ma} MOZAMBIQUE {mz} MYANMAR {mm} NAMIBIA {na} NAURU {nr} NEPAL {np} NETHERLANDS ANTILLES {an} NETHERLANDS, THE {nl} NEW CALEDONIA {nc} NEW ZEALAND {nz} NICARAGUA {ni} NIGER {ne} NIGERIA {ng} NIUE {nu} NORFOLK ISLAND {nf} NORTHERN MARIANA ISLANDS {mp} NORWAY {no} OMAN {om} PAKISTAN {pk} PALAU {pw} PALESTINE {ps} PANAMA {pa} PAPUA NEW GUINEA {pg} PARAGUAY {py} PERU {pe} PHILIPPINES (REPUBLIC OF THE) {ph} PITCAIRN {pn} POLAND {pl} PORTUGAL {pt} PUERTO RICO {pr} QATAR {qa} REUNION {re} ROMANIA {ro} RUSSIAN FEDERATION {ru} RWANDA {rw} SAMOA {ws} SAN MARINO {sm} SAO TOME/PRINCIPE {st} SAUDI ARABIA {sa} SCOTLAND {uk} SENEGAL {sn} SERBIA {rs} SEYCHELLES {sc} SIERRA LEONE {sl} SINGAPORE {sg} SLOVAKIA {sk} SLOVENIA {si} SOLOMON ISLANDS {sb} SOMALIA {so} SOMOA,GILBERT,ELLICE ISLANDS {as} SOUTH AFRICA {za} SOUTH GEORGIA, SOUTH SANDWICH ISLANDS {gs} SOVIET UNION {su} SPAIN {es} SRI LANKA {lk} ST. HELENA {sh} ST. KITTS AND NEVIS {kn} ST. LUCIA {lc} ST. PIERRE AND MIQUELON {pm} ST. VINCENT & THE GRENADINES {vc} SUDAN {sd} SURINAME {sr} SVALBARD AND JAN MAYEN {sj} SWAZILAND {sz} SWEDEN {se} SWITZERLAND {ch} SYRIAN ARAB REPUBLIC {sy} TAIWAN {tw} TAJIKISTAN {tj} TANZANIA, UNITED REPUBLIC OF {tz} THAILAND {th} TOGO {tg} TOKELAU {tk} TONGA {to} TRINIDAD AND TOBAGO {tt} TUNISIA {tn} TURKEY {tr} TURKMENISTAN {tm} TURKS AND CALCOS ISLANDS {tc} TUVALU {tv} UGANDA {ug} UKRAINE {ua} UNITED ARAB EMIRATES {ae} UNITED KINGDOM (no new registrations) {gb} UNITED KINGDOM {uk} UNITED STATES {us} UNITED STATES MINOR OUTL.IS. {um} URUGUAY {uy} UZBEKISTAN {uz} VANUATU {vu} VATICAN CITY STATE {va} VENEZUELA {ve} VIET NAM {vn} VIRGIN ISLANDS (USA) {vi} WALLIS AND FUTUNA ISLANDS {wf} WESTERN SAHARA {eh} YEMEN {ye} ZAMBIA {zm} ZIMBABWE {zw} ``` ###### tags: `information` `Documentation`