-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcradle.py
245 lines (217 loc) · 10 KB
/
cradle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import random
import time
import os
from faker import Faker
from fake_useragent import UserAgent
import pyderman as dr
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as CO
from selenium.webdriver.firefox.options import Options as FO
from selenium.webdriver.opera.options import Options as OO
class Producer:
def __init__(self):
self.virtual = None
self.lastname = None
self.middlename = None
self.firstname = None
self.sex = None
self.bankname = None
self.purpose = None
self.adress = None
self.agent = None
self.driver = None
def validate_user(self, items):
self.lastname = None
self.middlename = None
self.firstname = None
self.sex = None
for i in items:
if i.endswith('ович') or i.endswith('овна') or i.endswith('евич') or i.endswith('евич'):
self.middlename = i
continue
if i.endswith('ова') or i.endswith('ева'):
self.lastname = i
self.sex = 'female'
continue
if i.endswith('ов') or i.endswith('ев'):
self.lastname = i
self.sex = 'male'
continue
self.firstname = i
# cut 3/4 of all cases because of mostly male audience
if self.sex == 'female' and random.randint(1, 100) >= 20:
return
else:
return self.firstname and self.middlename and self.lastname
def create_useragent(self):
while True:
try:
return UserAgent().random
except:
pass
def create_user(self):
while True:
f = Faker('ru_RU')
i = f.name().split(' ')
if self.validate_user(i):
self.adress = f.address()
break
return self.firstname, self.middlename, self.lastname
def create_driver(self, proxy=None, headless=True):
if self.virtual:
return
if proxy and not isinstance(proxy, str):
with open(os.path.join(os.getcwd(), 'tested_proxies.txt'), encoding="utf-8") as file:
lines = file.read().split()
proxy = random.choice(lines).strip()
choice = random.choice([
['chrome', dr.chrome],
['chrome', dr.chrome],
['chrome', dr.chrome],
# ['firefox', dr.firefox],
# ['opera', dr.opera],
# dr.phantomjs
])
path = dr.install(browser=choice[1], file_directory='src/lib/', verbose=True, chmod=True, overwrite=False,
version=None, filename=None, return_info=False)
if choice[0] == 'chrome':
options = CO()
if proxy:
webdriver.DesiredCapabilities.CHROME['proxy'] = {
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy,
"proxyType": "MANUAL",
}
elif choice[0] == 'firefox':
options = FO()
if proxy:
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy,
"proxyType": "MANUAL",
}
elif choice[0] == 'opera':
options = OO()
if proxy:
webdriver.DesiredCapabilities.OPERA['proxy'] = {
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy,
"proxyType": "MANUAL",
}
# opera_profile = '/Users/antonkurenkov/Proj/pbot/archive'
# opera_profile = ' /Users/antonkurenkov/Library/Application Support/com.operasoftware.Opera'
# options.add_argument('user-data-dir=' + opera_profile)
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-infobars")
options.add_argument("--disable-extensions")
# options.add_argument('--remote-debugging-port=9222')
# options.add_argument("--disable-setuid-sandbox")
# options.add_experimental_option('useAutomationExtension', False)
# options.add_experimental_option('excludeSwitches', ['enable-logging'])
if random.randint(0, 100) >= 30:
# random device; mostly pc
self.agent = self.create_useragent()
options.add_argument(f'--user-agent={self.agent}')
if random.randint(0, 100) >= 30:
options.add_argument('--start-maximized')
elif random.randint(0, 100) >= 30:
options.add_argument("window-size=1920,1080")
elif random.randint(0, 100) >= 30:
options.add_argument("window-size=1024,768")
else:
# mobile device
dims = (
(360, 640), (375, 667), (414, 896), (360, 780), (360, 760),
(375, 812), (360, 720), (414, 736), (412, 846), (360, 740),
(412, 892), (412, 869), (393, 851), (412, 732), (320, 568),
(720, 1280), (1080, 1920), (360, 800), (320, 570), (1080, 2340))
size = random.choice(dims)
options.add_argument(f"window-size={size[0]},{size[1]}")
with open('agents_m', encoding="utf-8") as file:
self.agent = random.choice(file.read().split('\n'))
options.add_argument(f'--user-agent={self.agent}')
options.headless = headless
if choice[0] == 'chrome':
self.driver = webdriver.Chrome(options=options, executable_path=path)
elif choice[0] == 'firefox':
self.driver = webdriver.Firefox(options=options, executable_path=path)
elif choice[0] == 'opera':
self.driver = webdriver.Opera(options=options, executable_path=path)
def produce_data(self):
with open(os.path.join(os.getcwd(), 'userdata', 'banknames.txt'), encoding="utf-8") as file:
# with open('/Users/antonkurenkov/Proj/pbot/userdata/banknames.txt') as file:
self.bankname = random.choice(file.read().split('\n'))
with open(os.path.join(os.getcwd(), 'userdata', 'purposes.txt'), encoding="utf-8") as file:
# with open('/Users/antonkurenkov/Proj/pbot/userdata/purposes.txt') as file:
self.purpose = random.choice(file.read().split('\n'))
obligatory_block = {
'Name': f'{self.lastname} {self.firstname} {self.middlename}',
'PersonalAcc': ''.join([str(random.randint(0, 9)) for _ in range(20)]),
'BankName': self.bankname,
'BIC': ''.join([str(random.randint(0, 9)) for _ in range(9)]),
'CorrespAcc': random.choice(['0', ''.join([str(random.randint(0, 9)) for _ in range(20)])])
}
optional_block = {
'Sum': str((random.randint(1, 100) * 1000) + (random.randint(1, 100) * 100 if random.choice([True, False, False, False]) else 0)),
'Purpose': self.purpose,
'FirstName': self.create_user()[0],
'MiddleName': self.create_user()[1],
'LastName': self.create_user()[2],
'PayeeINN': ''.join([str(random.randint(0, 9)) for _ in range(12)]),
'KPP': ''.join([str(random.randint(0, 9)) for _ in range(9)]),
'PayerAdress': self.adress
}
return obligatory_block, optional_block
@staticmethod
def get_redirected_url():
def num_postfix():
return f'{"".join([random.choice(letters) for _ in range(random.randint(1, 5))])}={"".join([random.choice(nums) for _ in range(random.randint(1, 10))])}'
def letter_postfix():
return f'{"".join([random.choice(letters) for _ in range(random.randint(1, 5))])}={"".join([random.choice(arr) for _ in range(random.randint(5, 36))])}'
letters = 'abcdefghijklmnopqrstuvwxyz'
letters_upper = 'abcdefghijklmnopqrstuvwxyz'.upper()
nums = '0123456789'
uu = '_-'
arr = letters + letters_upper + nums + uu
fake_args = '&'.join([random.choice([num_postfix, letter_postfix])() for _ in range(random.randint(1, 3))])
data_dict = {
'social': [
f'https://vk.com/away.php?utf={random.randint(1, 3)}&to=https%3A%2F%2Fwww.payqrcode.ru',
f'https://vk.com/away.php?utf={random.randint(1, 3)}&to=https%3A%2F%2Fwww.payqrcode.ru',
f'https://vk.com/away.php?utf={random.randint(1, 3)}&to=https%3A%2F%2Fwww.payqrcode.ru',
f'https://vk.com/away.php?utf={random.randint(1, 3)}&to=https%3A%2F%2Fwww.payqrcode.ru',
f'https://vk.com/away.php?utf={random.randint(1, 3)}&to=https%3A%2F%2Fwww.payqrcode.ru',
f'https://www.payqrcode.ru/?lr={random.randint(1, 4)}&redircnt={"".join([str(random.randint(1, 9)) for _ in range(10)])}.{random.randint(1, 9)}',
f'https://www.payqrcode.ru/?fbclid={"".join([random.choice(arr) for _ in range(63)])}',
f'https://www.payqrcode.ru/?{fake_args}'
],
'direct': [
'https://payqrcode.ru',
'https://payqrcode.ru',
'https://www.payqrcode.ru',
'https://www.payqrcode.ru',
'https://www.payqrcode.ru/',
'https://www.payqrcode.ru/index',
'https://www.payqrcode.ru/index',
# 'http://www.payqrcode.ru',
# 'http://www.payqrcode.ru/index',
# 'http://payqrcode.ru',
# 'http://payqrcode.ru/index',
]
}
source = data_dict[random.choice(list(data_dict.keys()))]
return random.choice(source)
if __name__ == '__main__':
p = Producer()
p.create_user()
p.create_driver(proxy=True)
# required_block, optional_block = p.produce_data()
p.driver.get('https://api.ipify.org?format=json')
time.sleep(10)
print(p.driver.title)
p.driver.quit()