14 lines
765 B
Python
14 lines
765 B
Python
#!/usr/bin/env python
|
|
import StringIO, socket, urllib, stem.process, socks # SocksiPy module #from stem.util import term
|
|
def readUrl(url):
|
|
try: return urllib.urlopen(url).read()
|
|
except: return "Unable to reach %s" % url
|
|
if __name__ == "__main__":
|
|
SOCKS_PORT = 7000
|
|
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
|
|
socket.socket = socks.socksocket # Set socks proxy and wrap the urllib module
|
|
socket.getaddrinfo = lambda *args: [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))] # Perform DNS resolution through the socket
|
|
tor_process = stem.process.launch_tor_with_config( config = { 'SocksPort': str(SOCKS_PORT) })
|
|
print( readUrl("http://www.hloko3spojxt2inn.onion/") )
|
|
tor_process.kill()
|