How To: Using Tor From The Command Line

If you’re going to be doing work in the “dark web”, it’ll be useful to understand how to quickly and easily run commands via Tor.

First, assuming you’re using Linux, install Tor:

sudo apt install tor

Next, edit /etc/tor/torrc:

sudo vi /etc/tor/torrc

Find the line containing the following:

#ControlPort 9051

…and uncomment it.

Next, find the following line:

#CookieAuthentication 1

Uncomment it, and change 1 to 0.

Finally, restart the tor service:

sudo /etc/init.d/tor restart

Now, you can test to see if things are working as expected. Check your current ip:

curl ifconfig.me

…and compare the result to the following:

torify curl ifconfig.me 2>/dev/null

The torify command can be used to run any command through tor. The redirect to /dev/null is used because torify generates a handful of warnings on some platforms.

If all goes well, you should see the IP address you’re getting after going through Tor. If not, try restarting the tor service again.

Now, you’re ready to perform whatever tasks you need to from the shell, via Tor.

If you want to force Tor to generate a new circuit, and thus a new IP, use the following command:

echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051

After sending the NEWNYM signal, using the torify’d curl command above should yield a new IP address.

HowToHuntBlue TeamRed Team