how to automate anonymous surfing with tor and robotframework

If your need is to automate webpage surfing changing everytime (or often) your ip (and with ip, your geographical location), you are in the right place.

You can reach the result using mozilla Firefox,  Tor project and Robot Framework.

Lets split the problem in smaller problems in order to understand it easy.

You need to automate browser behaviour, and robot framework is a good friend to do this. Robot Framework is a fantastic general purporse automation tool that, with a special add on called “Selenium2library”, it can drive the browser.

You also need to change your ip, and you can do it thanks to the Tor Project, with permits to make a chain of connection from your client to the destination webpage, obtaining everytime (or almost very often) a new ip.

Lets start.

Setting up Robot Framework

Due robot framework can be installed simply by pyton pip, the installation process is very similar in every operative system. You need python. Robot Framework support for python3 is not perfect, so use python2. If you are in a linux environment, remember to obtain super user rights (sudo -s).

pip install robotframework

if you obtain warning about the missing of bottlenose, simply pip install bottlenose.

now, open a terminal and you should be able to run “robot” command. In Windows Environment, you maybe need to set the robot.exe executable in the PATH variable to use it easier. Remember to close and open terminal again before try to run robot command, or terminal will not be able to read the new environment path.

Now, robotframework need a driver to drive firefox (or other browsers). The driver used to drive firefox is called gecko driver and you can find here. On Windows, you can simply download the driver.exe and add the folder to the Path. on Linux, you should put the driver in the /bin folder.

Now you have robot framework and the driver installed so robotframework can drive the firefox browser.

Setting up Tor

The easiest way to connect to the TOR network is use the bundle you can download here  . The bundle gives you a working browser (a firefox) already connected to the tor proxy. Now, you might be able to use this firefox with robot framework, but, due i’m not able to use it, i will use a normal firefox connecting to the same tor proxy used by the firefox provided in the bundle.

Setting up firefox to use TOR

How to create a firefox profile to be used with robotframework and tor

How to create a firefox profile to be used with robotframework and tor

Now you firefox needs to connect to the tor proxy in order to use the tor network. This is pretty easy, you simply need to see the connection preferences of the firefox given with the bundle and put in your firefox. Robot Framework will normally create a new clean instance of firefox when you open this browser, so you need to save your firefox connection information to a profile and train robot in order to use it. To create a new firefox profile, simply run “firefox.exe -p” in terminal and create a new profile.  This profil will store the connection settings and it will be saved in a folder (e.g. c:\torff). In this profile, you will set as connection a profile that connect to your tor proxy.

Where to find Tor Network informations

Where to find Tor Network informations

In order to understand what is the right configuration, you can take a look at the firefox provided with the tor bundle. Due the TOR proxy runs in your machine, the host is the loopback ip (127.0.0.1).

 

 

 

 

 

 

 

 

 

How To Check if Firefox is connected to Tor Network

How To Check if Firefox is connected to Tor Network

 

If the configuration is good, opening the tor proxy test page, the tor network will be confirmed.

Configure Robot Framework to use firefox with the right profile

Now, the hardest work is almost done. You simply need to train robotframework in order to open firefox with the previously stored profile, the profile that connect to the tor proxy. At the beginning, simply automate the opening of the test url, and if everything is good, you can start automating the anonimous surfing.

How to use profile in robot framework

How to use profile in robot framework

 

 

 

 

 

 

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *