/
xm_register.py
290 lines (263 loc) · 12.2 KB
/
xm_register.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# -*- coding: utf-8 -*-
# @Time : 2018/8/24 11:34
# @Author : ZKL
import uiautomator2 as u2
from public.Swipeclass import Swipeclass
from public.Hproseclass import Hproseclass
import time, sys, json, random, pymysql, requests
import urllib.request
import re
import pymysql
db = pymysql.connect(
host='',
user='',
password='',
port=3306,
db='',
use_unicode=True,
charset=''
)
def register():
try:
services = 'ebd4f2f67d83'
start_time = time.time()
d = u2.connect_usb(services)
d.screen_off()
d.screen_on()
time.sleep(1)
swipe = Swipeclass(d)
swipe.swipeUp(d, 0.1)
time.sleep(3)
d.app_start('io.virtualapp')
# d.app_start('com.facebook.katana')
print('正在启动io.virtualapp')
except Exception as e:
print(e)
sys.exit()
time.sleep(5)
print('virtualapp启动成功!')
time.sleep(5)
res = d(resourceId="io.virtualapp:id/item_app_name", text=u"Facebook")
print('一共有%s个设备' %(res.count))
for x in range(1,2):
try:
time.sleep(1)
print('正在启动设备{}'.format(x+1))
d(resourceId="io.virtualapp:id/item_app_name", text=u"Facebook", instance=x).click_exists(timeout=15)
time.sleep(15)
if d(text=u"Continue").exists:
d(text=u"Continue").click_exists(timeout=5)
elif d(text=u"CONTINUE").exists:
d(text=u"CONTINUE").click_exists(timeout=5)
time.sleep(2)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"CREATE NEW FACEBOOK ACCOUNT").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"CREATE NEW FACEBOOK ACCOUNT").click_exists(timeout=15)
else:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Create New Facebook Account").click_exists(timeout=15)
time.sleep(2)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"Join Facebook").exists:
d(text=u"Next").click_exists(timeout=5)
else:
d(scrollable=True).scroll.to(text="Next")
d(text=u"Next").click_exists(timeout=5)
time.sleep(3)
first_name = rdm(1, 2)
last_name = rdm(2, 3)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"First Name").exists:
print("First name ....")
d(resourceId="com.facebook.katana:id/(name removed)", className="android.widget.EditText").send_keys(last_name)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", className="android.widget.EditText", instance=1).send_keys(first_name)
d(text="Next").click_exists(timeout=5)
time.sleep(2)
name = last_name+first_name
if d(text="What's Your Birthday?").exists:
print("Birthday......")
number = random.randint(1989, 1998)
# number = 指定年份
print('出生年份随机数为{}'.format(number))
time.sleep(0.5)
while True:
# 出生日期的年份
year_number = int(
d(className="android.widget.LinearLayout").child(className="android.widget.NumberPicker",instance=2).child(className="android.widget.EditText").get_text())
print(year_number)
if year_number == number:
print('已选定指定年份!')
break
if year_number > number:
d.double_click(0.681, 0.28)
time.sleep(0.5)
elif year_number < number:
d.double_click(0.677, 0.492)
time.sleep(0.5)
time.sleep(1.5)
# 长按时间
click_time = round(random.uniform(0.7, 2), 1)
click_time2 = round(random.uniform(0.7, 3.5), 1)
time.sleep(0.25)
# 月份
# 上 下
count_list = [0.285, 0.451]
d.long_click(0.509, random.choice(count_list), click_time)
time.sleep(0.25)
# 日
# 上 下
count2_list = [0.28, 0.447]
d.long_click(0.319, random.choice(count2_list), click_time2)
time.sleep(2)
year = d(className="android.widget.LinearLayout").child(className="android.widget.NumberPicker",
instance=2).child(
className="android.widget.EditText").get_text()
month = d(className="android.widget.LinearLayout").child(className="android.widget.NumberPicker",
instance=0).child(
className="android.widget.EditText").get_text()
day = d(className="android.widget.LinearLayout").child(className="android.widget.NumberPicker",
instance=1).child(
className="android.widget.EditText").get_text()
birthday = str(year) + '年'+ str(month) + '月'+str(day) + '日'
time.sleep(2)
d(text="Next").click_exists(timeout=5)
response = requests.get('http://api.codedw.com/api/do.php?action=loginIn&name=meyou2&password=131liuhan!')
time.sleep(5)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Female").click_exists(timeout=5)
d(text="Next").click_exists(timeout=5)
time.sleep(3)
phone = getphone()
if phone.isdigit():
print()
print('设备%s 手机号 %s' % (x, phone))
else:
time.sleep(3)
phone = getphone()
print(phone)
print("Phone / Email input ....")
d(resourceId="com.facebook.katana:id/(name removed)", className="android.widget.EditText").send_keys(phone)
time.sleep(2)
d(text="Next").click_exists(timeout=5)
time.sleep(2)
password = rdm(8)
d(resourceId="com.facebook.katana:id/(name removed)", className="android.widget.EditText").send_keys(password)
print(password)
time.sleep(2)
d(text="Next").click_exists(timeout=5)
time.sleep(2)
if d(text=u"Finish Signing Up").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Sign Up").click_exists(timeout=5)
time.sleep(20)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"Save Password").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Save Password").click(timeout=30)
code = getcode(phone)
print(code)
with open('record.txt', 'a', encoding='utf-8') as f:
f.write('\n')
f.write("设备{}第{}个 账号:{} 密码:{} 验证码:{} 生日:{}".format(services, x+1, phone, password, code, birthday))
f.write('\n')
cursor = db.cursor()
insert_sql = "INSERT INTO meu_xiaomi(series, mobile, position, password, name, birthday)VALUE('{}', '{}', '{}', '{}', '{}', '{}')".format(services, phone, x+1, password, name, birthday)
cursor.execute(insert_sql)
db.commit()
time.sleep(8)
d.app_stop('com.facebook.katana')
time.sleep(2)
d.app_stop('io.virtualapp')
time.sleep(2)
d.app_start('io.virtualapp')
time.sleep(3)
d(resourceId="io.virtualapp:id/item_app_name", text=u"Facebook", instance=x).click_exists(timeout=15)
time.sleep(5)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"Save Password").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Save Password").click_exists(timeout=15)
time.sleep(15)
d(resourceId="io.virtualapp:id/item_app_name", text=u"Facebook", instance=x).click()
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"Skip").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Skip").click_exists(timeout=5)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Done").click_exists(timeout=5)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Confirmation code").send_keys(code)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Confirm").click()
time.sleep(5)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"OK").click()
while True:
d.click(0.123, 0.152)
time.sleep(2)
if d(resourceId="com.facebook.katana:id/(name removed)", text=u"Continue").exists:
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Continue").click()
break
d.click(0.863, 0.149)
time.sleep(2)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Confirmation code").send_keys(code)
time.sleep(2)
d(resourceId="com.facebook.katana:id/(name removed)", text=u"Confirm").click()
time.sleep(8)
print('设备{}第{}个注册成功!'.format(services, x + 1))
time.sleep(2)
d.press('back')
time.sleep(2)
d.press('back')
time.sleep(2)
except Exception as e:
print("{}设备出错".format(services))
print(e)
continue
def getphone():
get_url = 'http://api.codedw.com/api/do.php?action=getPhone&token=xxxx&sid=xxxx'
req = urllib.request.urlopen(get_url)
print(req)
ret = req.read()
ret = ret.decode("UTF-8")
print(ret)
data = ret.split('|')
return data[1]
def getcode(phone):
time.sleep(5)
phone = str(phone)
for i in range(10):
get_url = "http://api.codedw.com/api/do.php?action=getMessage&token=xxxx&sid=xxxx&phone=%s"% (phone)
req = urllib.request.urlopen(get_url)
ret = req.read()
ret = ret.decode("UTF-8")
print(ret)
data = ret.split('|')
code = False
if data[0] == '1':
code = data[1]
print(code)
code = re.sub("\D", "", code)
break
else:
time.sleep(5)
return code
def rdm(num=6, ty=1):
salt = ''
if ty == 1:
seed = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ"
sa = []
for i in range(num):
sa.append(random.choice(seed))
salt = ''.join(sa)
elif ty == 2:
index = random.randint(0, 80)
seed = ['Molly', 'Amy', 'Claire', 'Emily', 'Katie', 'Medeline', 'Katelyn',
'Emma', 'Abigail', 'Carly', 'Jenna', 'Heather', 'Katherine', 'Caitlin',
'Kaitlin', 'Holly', 'Allison', 'Kaitlyn', 'Hannah', 'Kathryn', 'sarah',
'emily', 'jessica', 'lauren', 'ashley', 'amanda', 'megan', 'samantha',
'hannah', 'rachel', 'nicole', 'taylor', 'elizabeth', 'katherine', 'madison',
'jennifer', 'alexandra', 'brittany', 'danielle', 'rebecca', 'macy', 'maggie',
'mandy', 'mango', 'mani', 'maple', 'margie', 'marsha', 'maria', 'mary', 'may',
'maya', 'megan', 'melissa', 'michelle', 'miki', 'mimi', 'mona', 'sally', 'sammi',
'sandra', 'sandy', 'selina', 'sara', 'sarah', 'serena', 'shadow', 'sharon', 'sheila',
'sherry', 'shirley', 'sky', 'sophie', 'stella', 'stephanie', 'stephy', 'jade', 'janice',
'jannet', 'janny', 'jasmine']
sa = seed[index]
salt = ''.join(sa)
elif ty == 3:
index = random.randint(0, 12)
seed = ['Richardson', 'Churchill', 'Johnson', 'Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Miller', 'Davis', 'Martinson', 'Anderson', 'Wilson']
sa = seed[index]
salt = ''.join(sa)
return salt
register()