-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
150 lines (131 loc) · 5.28 KB
/
test.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
import api
import subprocess
from slide3 import Slide3
import requests
import time
def main():
slide3 = Slide3()
cmd0 = "node -e \"require('./hack/rt.js').rt()\""
print(cmd0)
rt = subprocess.run(cmd0, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
(challenge, gt) = api.register()
print(challenge)
print(gt)
cmd1 = "node -e \"require('./hack/w.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
print(cmd1)
w = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
(c, s) = api.get_c_s(challenge, gt, w)
cmd2 = "node -e \"require('./hack/ww.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
print(cmd2)
w = subprocess.run(cmd2, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
api.get_type(challenge, gt, w)
(challenge, bg_url, slice_url) = api.get_new_challenge_bg_slice(challenge, gt)
dis = slide3.calculated_distance(bg_url, slice_url)
print(dis)
cmd3 = "node -e \"require('./hack/www.js').send(" + str(dis) + ",\'" + gt + "\',\'" + challenge + "\'," + str(c) + ",\'" + s + "\',\'"+ rt + "\')\""
print(cmd3)
w = subprocess.run(cmd3, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
time.sleep(2)
res = api.ajax(challenge, gt, w)
print(res)
def main1():
cmd0 = "node -e \"require('./hack/rt.js').rt()\""
print(cmd0)
rt = subprocess.run(cmd0, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
(challenge, gt) = api.register()
cmd1 = "node -e \"require('./hack/w.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
print(cmd1)
w = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
(c, s) = api.get_c_s(challenge, gt, w)
def main2():
slide3 = Slide3()
cmd0 = "node -e \"require('./hack/rt.js').rt()\""
print(cmd0)
rt = subprocess.run(cmd0, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
rt = "380a363aac234049"
challenge = "359ec7be639cc637a4fd42e63e4e469d "
gt = "4d91184f0308d36a3bc4b2b01b845a6b"
c = [12, 58, 98, 36, 43, 95, 62, 15, 12]
s = "64617357"
cmd2 = "node -e \"require('./hack/ww.js').send(\'" + rt + "\')\""
print(cmd2)
w = subprocess.run(cmd2, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
api.get_type(challenge, gt, w)
time.sleep(1)
(challenge, bg_url, slice_url) = api.get_new_challenge_bg_slice(challenge, gt)
dis = slide3.calculated_distance(bg_url, slice_url)
print(dis)
cmd3 = "node -e \"require('./hack/www.js').send(" + str(dis) + ",\'" + gt + "\',\'" + challenge + "\'," + str(c) + ",\'" + s + "\',\'"+ rt + "\')\""
print(cmd3)
w = subprocess.run(cmd3, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
time.sleep(5)
res = api.ajax(challenge, gt, w)
print(res)
def main3():
slide3 = Slide3()
suc = 0
fail = 0
while suc < 100:
print(suc)
print(fail)
cmd0 = "node -e \"require('./hack/rt.js').rt()\""
# print(cmd0)
rt = subprocess.run(cmd0, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
(challenge, gt) = api.register()
# print(challenge)
# print(gt)
# cmd1 = "node -e \"require('./hack/w.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
# print(cmd1)
# w = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
# print(w)
(c, s) = api.get_c_s(challenge, gt, None)
# cmd2 = "node -e \"require('./hack/ww.js').send(\'" + rt + "\')\""
# print(cmd2)
# w = subprocess.run(cmd2, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
# print(w)
api.get_type(challenge, gt, None)
(c, s, challenge, bg_url, slice_url) = api.get_new_c_s_challenge_bg_slice(challenge, gt)
dis = slide3.calculated_distance(bg_url, slice_url)
cmd3 = "node -e \"require('./hack/www.js').send(" + str(dis) + ",\'" + gt + "\',\'" + challenge + "\'," + str(c) + ",\'" + s + "\',\'"+ rt + "\')\""
# print(cmd3)
w = subprocess.run(cmd3, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
time.sleep(0.2)
res = api.ajax(challenge, gt, w)
if res['success'] == 1:
suc += 1
else:
fail += 1
print(suc / (suc + fail))
def main4():
slide3 = Slide3()
cmd0 = "node -e \"require('./hack/rt.js').rt()\""
print(cmd0)
rt = subprocess.run(cmd0, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
(challenge, gt) = api.register()
print(challenge)
print(gt)
cmd1 = "node -e \"require('./hack/w.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
print(cmd1)
w = subprocess.run(cmd1, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
(c, s) = api.get_c_s(challenge, gt, w)
cmd2 = "node -e \"require('./hack/ww.js').send(" + "\'" + gt + "\',\'" + challenge + "\',\'" + rt + "\')\""
print(cmd2)
w = subprocess.run(cmd2, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
print(w)
api.get_type(challenge, gt, None)
(c, s, challenge, bg_url, slice_url) = api.get_new_c_s_challenge_bg_slice(challenge, gt)
dis = slide3.calculated_distance(bg_url, slice_url)
cmd3 = "node -e \"require('./hack/www.js').send(" + str(dis) + ",\'" + gt + "\',\'" + challenge + "\'," + str(c) + ",\'" + s + "\',\'"+ rt + "\')\""
print(cmd3)
w = subprocess.run(cmd3, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
time.sleep(2)
res = api.ajax(challenge, gt, w)
print(res)
if __name__ == '__main__':
main4()