Instantly share code, notes, and snippets.

Embed
What would you like to do?
TOR ip renew script using pytorctl https://github.com/aaronsw/pytorctl which is a python based module to interact with the Tor Controller.
from TorCtl import TorCtl
import urllib2
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
headers={'User-Agent':user_agent}
def request(url):
def _set_urlproxy():
proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
_set_urlproxy()
request=urllib2.Request(url, None, headers)
return urllib2.urlopen(request).read()
def renew_connection():
conn = TorCtl.connect(controlAddr="127.0.0.1", controlPort=9051, passphrase="Password12")
conn.send_signal("NEWNYM")
conn.close()
for i in range(0, 10):
renew_connection()
print request("http://curlmyip.com/")
@arulrajnet

This comment has been minimized.

Copy link
Owner

arulrajnet commented May 3, 2015

For TOR with Privoxy use the docker container

https://registry.hub.docker.com/u/arulrajnet/torprivoxy/

Installation

apt-get install git
apt-get install python-dev python-pip
wget --no-check-certificate https://github.com/aaronsw/pytorctl/archive/master.zip
unzip master.zip
pip install pytorctl-master/

Then to run python tor_ip_renew.py

you can configure the TOR controller password in the above script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment