-
-
Save tonythere/402c3a744274709bb2e3 to your computer and use it in GitHub Desktop.
TOR ip renew script using pytorctl https://github.com/aaronsw/pytorctl which is a python based module to interact with the Tor Controller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment