Created
August 19, 2017 14:20
-
-
Save 0xbepresent/b81a4ca9903bbfc7aea157b8cd55f932 to your computer and use it in GitHub Desktop.
Python Script to connect to TOR via Stem.
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
""" | |
Python script to connect to TOR via STEM. I also recommend this source https://gist.github.com/KhepryQuixote/46cf4f3b999d7f658853 | |
""" | |
import socks | |
import requests | |
import socket | |
from stem import Signal | |
from stem.control import Controller | |
from stem.util import term | |
def enable_socket(): | |
socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9050) | |
socket.socket = socks.socksocket | |
def main(): | |
with Controller.from_port(port=9051) as controller: | |
controller.authenticate(password="bulapalup4") | |
enable_socket() | |
# Generamos una IP, esto lo puedes poner en un FOR cada X tiempo | |
controller.signal(Signal.NEWNYM) | |
# Requests bajo una IP hidden with TOR | |
print "\nNew TOR connection processed." | |
try: | |
print "Requests se van hacer con la IP {}".format((requests.get('http://icanhazip.com')).content) | |
except: | |
pass | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment