· 4 years ago · May 30, 2021, 09:42 PM
1from selenium import webdriver
2from random import randint
3from random import choice
4from datetime import date
5from nickname_generator import generate
6import requests
7import string
8import time
9import names
10import os
11import re
12
13def Find(string):
14 # findall() has been used
15 # with valid conditions for urls in string
16 url = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\), ]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', string)
17 return url
18
19def generateUser():
20 #generates random username/password
21 username = names.get_first_name()
22 username += ''.join(generate())
23 password = 'espantoso'
24
25 return username, password
26
27def createAccount(username, password):
28 profile = webdriver.FirefoxProfile()
29 profile.set_preference("network.proxy.type", 1)
30 profile.set_preference("network.proxy.socks", '127.0.0.1')
31 profile.set_preference("network.proxy.socks_port", 9050)
32 profile.set_preference("network.proxy.socks_remote_dns", True)
33 profile.set_preference("browser.privatebrowsing.autostart", True)
34 profile.update_preferences()
35 driver = webdriver.Firefox(firefox_profile=profile)
36 emailDriver = webdriver.Firefox(firefox_profile=profile)
37 try:
38 print('Creating account with username: ' + username + ' and password: ' + password + '...')
39
40 print('Clearing all cookies...')
41 driver.delete_all_cookies()
42
43 print('Setting up anonymous web identity...')
44 driver.get("https://old.reddit.com/register")
45
46 print('Entering in username...')
47 time.sleep(randint(1,5))
48 driver.find_element_by_id('user_reg').click()
49 driver.find_element_by_id('user_reg').send_keys(username)
50
51 print('Entering in password...')
52 time.sleep(randint(1,5))
53 driver.find_element_by_id('passwd_reg').click()
54 driver.find_element_by_id('passwd_reg').send_keys(password)
55
56 print('Entering in password...')
57 time.sleep(randint(1,5))
58 driver.find_element_by_id('passwd2_reg').click()
59 driver.find_element_by_id('passwd2_reg').send_keys(password)
60
61 print('Retreiving email...')
62 emailDriver.get('https://getnada.com')
63 email = emailDriver.find_element_by_xpath('/html/body/div[1]/div/div/div/div[2]/div/div[1]/div/div/p/span[1]/a').text
64
65 print('Entering email...')
66 driver.find_element_by_id('email_reg').send_keys(email)
67
68 print('Solving captcha...')
69 time.sleep(randint(10,15))
70 apiKey = 'eeef19bf29988bcd3d9138196dd04d07' #Add your API key here!
71 siteKey = '6LeTnxkTAAAAAN9QEuDZRpn90WwKk_R1TRW_g-JC'
72 pageUrl = 'https://old.reddit.com/register'
73 requestUrl = 'https://2captcha.com/in.php?key='+apiKey+'&method=userrecaptcha&googlekey='+siteKey+'&pageurl='+pageUrl
74 print('Requesting 2captcha API...')
75 resp = requests.get(requestUrl)
76 if(resp.text[0:2] != 'OK'):
77 print('Service error has occured. Error code: '+resp.text)
78 return
79 captchaId = resp.text[3:]
80 print('Submitted request successfully, waiting for 30 seconds until requesting return...')
81 time.sleep(30)
82 returnUrl = 'https://2captcha.com/res.php?key='+apiKey+'&action=get&id='+captchaId
83 print('Requesting return...')
84 resp = requests.get(returnUrl)
85 if resp.text == 'CAPCHA_NOT_READY':
86 while resp.text == 'CAPCHA_NOT_READY':
87 print('Captcha is not ready, requesting again in 5 seconds...')
88 time.sleep(5)
89 resp = requests.get(returnUrl)
90 elif resp.text[0:5] == 'ERROR':
91 print('Service error has occured. Error code: '+resp.text)
92 return
93 ansToken = resp.text[3:]
94 if ansToken == 'OR_CAPCHA_UNSOLVABLE':
95 print('Service error has occured. Error code: '+resp.text)
96 return
97 print('Answer token recieved: '+ansToken)
98
99 captchaInput = driver.find_element_by_id('g-recaptcha-response')
100 driver.execute_script("arguments[0].setAttribute('style','visibility:visible;');", captchaInput)
101 captchaInput.send_keys(ansToken)
102
103 print('Submitting token')
104 driver.find_element_by_xpath('/html/body/div[3]/div/div/div[1]/form/div[8]/button').click()
105 time.sleep(randint(4,5))
106 driver.get('https://old.reddit.com/prefs/apps/')
107 time.sleep(randint(1,5))
108 driver.find_element_by_xpath('//*[@id="create-app-button"]').click()
109 time.sleep(randint(1,5))
110 driver.find_element_by_name('name').click()
111 driver.find_element_by_name('name').send_keys('apfel')
112 time.sleep(randint(1,5))
113 driver.find_element_by_xpath('/html/body/div[3]/div[3]/form/table/tbody/tr[4]/td[1]/label').click()
114 time.sleep(randint(1,5))
115 driver.find_element_by_name('redirect_uri').click()
116 driver.find_element_by_name('redirect_uri').send_keys('http://localhost:8080')
117 time.sleep(randint(1,5))
118 driver.find_element_by_xpath('/html/body/div[3]/div[3]/form/button').click()
119 time.sleep(randint(1,5))
120 secret = driver.find_element_by_xpath('/html/body/div[3]/div[2]/ul/li/div[2]/h3[2]').text
121 secret_id = driver.find_element_by_xpath('/html/body/div[3]/div[2]/ul/li/div[4]/div[1]/form/table/tbody/tr[1]/td').text
122
123 print('Writing account info to file...')
124 with open('accounts.out', 'a') as fout:
125 fout.write(username+'\n'+secret+'\n'+secret_id+'\n')
126
127 print('Successfully created account!')
128 driver.delete_all_cookies()
129 print('Clearing cookies...')
130 time.sleep(5)
131 driver.close()
132 emailDriver.close()
133 return
134 except:
135 print('Error. Trying again...')
136 driver.close()
137 emailDriver.close()
138 time.sleep(5)
139 createAccount(username, password)
140 return
141
142def main():
143 times = int(input('Enter number of accounts. \n'))
144 for i in range(times):
145 os.system('sudo -u root service tor restart')
146 username, password = generateUser()
147 createAccount(username, password)
148 print('System cooldown')
149 time.sleep(10)
150main()