How To Access Tor Using Python
Tor (The Onion Router) often associated with the dark web is fundamentally a tool for anonymizing internet activity. Tor was developed by the U.S. Naval Research Laboratory in the 1990s for secure and anonymous communication. The project became open source in 2004 and has since gained popularity among journalists, activists, and individuals seeking privacy.
Tor has been used for both legitimate purposes and crimes. While it provides privacy for journalists and activists, it also enables cybercriminals, peddlers, and others to offer illicit services with significant protection from law enforcement.
Today I am going to write a python script for accessing onion websites through TOR. I expect you are using windows OS for the project.
Requirements :-
- Python Installed
- Tor Expert Bundle. Download according to your system requirements. Mostly x86_64 Alpha
- Requests library
- ```python pip install requests ```
- Next we need socks library for requests. Use the below command for that
- ```python pip install requests[socks] ```
Now once you have got tor expert bundle downloaded. Extract the bundle. There will be two folders inside Tor & Data. Open the Tor folder and start the tor.exe . Once you have started the Tor.exe will start listening on PORT 9050 as a proxy server. We will use this port to access the tor. If you want you can use Tor browser but that uses PORT 9150 as proxy server. We will jump into python script now.
Once the socks5 proxy variables are made we will pass these proxies to the get method for request.
I am providing the full code below. You can make change the PORT 9050 to 9150 if you are using tor browser, and choose your url accordingly.