ice1x / yobotor

YouTube Views through the Tor
10 stars 6 forks source link

Add Tor launcher #2

Open ice1x opened 6 years ago

ice1x commented 6 years ago

I still not able to launch Tor automatically. Tor should be launched manually before the script, something related to port number or something like that.

absingh31 commented 6 years ago

Importing Stem libraries

from stem import Signal from stem.control import Controller import socks, socket

Initiating Connection

with Controller.from_port(port=9051) as controller: controller.authenticate("your hash password") controller.signal(Signal.NEWNYM)

TOR SETUP GLOBAL Vars

SOCKS_PORT = 9050 # TOR proxy port that is default from torrc, change to whatever torrc is configured to socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", SOCKS_PORT) socket.socket = socks.socksocket

Perform DNS resolution through the socket

def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]

socket.getaddrinfo = getaddrinfo

absingh31 commented 6 years ago

Add these above lines to your script after installing tor and you're good to go