def torLoop(): try: GenTorAddress() torAddress() except KeyboardInterrupt: lenwork = len(working) lennot = len(notworking) print('\nWorking ' + str(lenwork)) print('Not Working ' + str(lennot)) TorProxy.torClose() exit()
def torAddress(): try: TorProxy.torConnect(host) TorProxy.torWget(host, host + '.txt') TorProxy.torClose() working.append([host]) except TorProxy.socks.Socks5Error: print TorProxy.socks.Socks5Error print '\n' notworking.append([host]) TorProxy.torClose() torLoop() except Exception as e: TorProxy.UnknownError()
def TestTorService(): try: testSite = "http://3g2upl4pq6kufc4m.onion" TorProxy.torConnect(testSite)#Test connection TorProxy.readHost(testSite)#read the host #myData = TorProxy.data#This is the result of connecting with urllib2 myData = TorProxy.data.read(15) if myData == '<!DOCTYPE html>': print('Connected to DuckDuckGo') TorProxy.torClose() exit() else: print('Connected but not DuckDuckGo?') TorProxy.torClose() exit() except TorProxy.socks.Socks5Error: print TorProxy.socks.Socks5Error TorProxy.torClose() exit() except Exception as e: TorProxy.UnknownError() exit()