Python Forum

Full Version: TOR
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have code for create account with different IPs through TOR, but I want to add TOR to another script.

Script for create account worked.

This is just part of the script

def create_account(username, password):
    #set up profile for proxy
    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.socks", '127.0.0.1')
    profile.set_preference("network.proxy.socks_port", 9050)
    profile.set_preference("network.proxy.socks_remote_dns", True)
    profile.update_preferences()
    browser = webdriver.Firefox(firefox_profile=profile)
def main():
    os.system('clear')
    #run account generator for each user in list
    created = open(createdUserNamePasswordFile, 'a')
    creds = [cred.strip() for cred in open(userNamePasswordFile).readlines()]
    for cred in creds:
        username, password = cred.split(':')
        print('[+] creating account for %s with password %s' % (username,password))
        account_created = create_account(username, password)
        print('[+] restarting tor for a new ip address...')
        os.system('service tor restart')
        if account_created:
            print('[+] writing name:password to created names...')
            created.write(username + ':' + password + '\n')
            print('[+] deleting name:password from original file...')
            lines = [line.strip() for line in open(userNamePasswordFile).readlines()]
            f = open(userNamePasswordFile, 'w')
            for line in lines:
                if (line != cred):
                    f.write(line + "\n")
            f.close()
        else:
            print('[-] name not recorded due to captcha issue')
        time.sleep(2)
        os.system('clear')
    created.close()

    
main()
How to add TOR to new script which is not for creating accounts?
Hi,

PM Sent!

Regards,
Norman F.