How To Anonymize Your cURL Requests Using Tor

Posted on December 9, 2011

Note: This post assumes that you already have Tor installed and configured on your server. If not, visit the Tor Project Homepage for instructions on how to set it up.

I love writing web crawlers and data aggregators in PHP. They say knowledge is power, and I find it exciting to write applications that allow you to gather up as much knowledge as possible. Sometimes, though, you want to gather your data without revealing your identity to your target. This can be for both good and bad reasons, but let’s assume it is for a good reason that you need to keep hidden. The Tor Project is a great way to accomplish this task. Tor allows you to anonymously browse the web, and you can configure the applications on your computer to run through the Tor network. The script below outlines the process it takes to randomly refresh your IP address on Tor, and then run a cURL request through your local Tor proxy, providing a unique identity and anonymity every time you run the script.

For this particular example, I am sending a request to to demonstrate the changing IP address. If you have a greater understanding of cURL, there are many more steps that can be taken to mask your identity as well, but I won’t go into that here.

  • George Garchagudashvili

    Very helpful, thank you so much

  • Andreas Søvik Nilsen

    Yeah, thanks! Really helped! :)

    • Zachary Flower

      You’re welcome!

  • Mr Roboto
  • Kevin Steger

    Is there a way to determine from Tor what exit node was used? e.g. if I have exitnodes {US,CA} is there a way to tell which country exit it went through?