Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
xtekky
GitHub Repository: xtekky/tiktok-viewbot
Path: blob/main/old/v1/to update/mobile/mobile_script.py
621 views
1
#!/usr/local/bin/python
2
# -*- coding: utf-8 -*-
3
4
VIDEO = "7126536525008882949" #video id
5
6
import requests, time, random, bs4, sys, re, base64, urllib.parse
7
8
9
class Main:
10
def __init__(self):
11
12
self.url = "https://zefoy.com/"
13
self.session = requests.session()
14
15
def solve_captcha(self, sessid):
16
try:
17
# -- get captcha image --
18
response = self.session.get(
19
self.url + "a1ef290e2636bf553f39817628b6ca49.php",
20
headers={
21
"origin": "https://zefoy.com",
22
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
23
"x-requested-with": "XMLHttpRequest",
24
"cookie": f"PHPSESSID={sessid}",
25
},
26
params={
27
"_CAPTCHA": "",
28
"t": f"{round(random.random(), 8)} {int(time.time())}",
29
},
30
)
31
32
json_data = {
33
"requests": [{
34
"image": {
35
"content": str(base64.b64encode(response.content).decode())
36
},
37
"features": [{"type": "TEXT_DETECTION"}]
38
}]
39
}
40
41
req = requests.post(
42
url = 'https://content-vision.googleapis.com/v1/images:annotate',
43
headers = {
44
'x-origin': 'https://explorer.apis.google.com',
45
},
46
params = {
47
'alt': 'json',
48
'key': 'AIzaSyAa8yy0GdcGPHdtD083HiGGx_S0vMPScDM',
49
},
50
json = json_data
51
)
52
53
captcha_answer = req.json()['responses'][0]["textAnnotations"][0]["description"]
54
55
if captcha_answer == "" or captcha_answer is None:
56
self.solve_captcha(sessid)
57
58
captcha_answer = re.compile('[^a-zA-Z]').sub('', captcha_answer).lower()
59
60
# submit response
61
_response = self.session.post(
62
self.url,
63
data={
64
"captcha_secure": captcha_answer,
65
"r75619cf53f5a5d7aa6af82edfec3bf0": "",
66
},
67
headers={
68
"cookie": f"PHPSESSID={sessid}",
69
"origin": "https://zefoy.com",
70
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
71
"x-requested-with": "XMLHttpRequest",
72
},
73
)
74
alpha_key = re.findall('(?<=")[a-z0-9]{16}', _response.text)[0]
75
print(f"Solved captcha ! | {captcha_answer}")
76
77
return alpha_key
78
79
except Exception as e:
80
print(f"Error: {e}")
81
print("Captcha Invalid | Check access to Zefoy | xtekky.com may be down")
82
self.solve_captcha(sessid)
83
84
def get_sessid(self):
85
sessid = self.session.get(
86
self.url,
87
headers={
88
"origin": "https://zefoy.com",
89
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
90
"x-requested-with": "XMLHttpRequest",
91
},
92
).cookies.values()[0]
93
return sessid
94
95
def decrypt(self, data):
96
return base64.b64decode(urllib.parse.unquote(data[::-1])).decode()
97
98
def decrypt_timer(self, data):
99
# decrypted = base64.b64decode(urllib.parse.unquote(data[::-1])).decode()
100
if len(re.findall(" \d{3}", data)) != 0:
101
timer = re.findall(" \d{3}", data)[0]
102
else:
103
timer = data.split("= ")[1].split("\n")[0]
104
105
return int(timer)
106
107
def views_loop(self, sessid, alpha_key):
108
while True:
109
time.sleep(2)
110
111
request = self.session.post(
112
self.url + "c2VuZC9mb2xsb3dlcnNfdGlrdG9V",
113
headers={
114
"cookie": f"PHPSESSID={sessid}",
115
"origin": "https://zefoy.com",
116
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
117
"x-requested-with": "XMLHttpRequest",
118
},
119
data={alpha_key: f"https://www.tiktok.com/@onlp/video/{VIDEO}"},
120
)
121
decryped_answer = self.decrypt(request.text)
122
123
if "This service is currently not working" in decryped_answer:
124
print("Views not available in the moment")
125
input()
126
sys.exit()
127
128
elif "Server too busy" in decryped_answer:
129
print("Server busy ! (waiting 10s)")
130
time.sleep(10)
131
continue
132
133
elif "function updatetimer()" in decryped_answer:
134
print("\r", end="")
135
timer = self.decrypt_timer(decryped_answer)
136
137
print(f"Timer: {timer} (not animated)")
138
time.sleep(timer)
139
140
print(f"Sending views ...")
141
continue
142
143
soup = bs4.BeautifulSoup(decryped_answer, "html.parser")
144
try:
145
beta_key = soup.find("input", {"type": "text"}).get("name")
146
except:
147
input(decryped_answer)
148
sys.exit()
149
150
time.sleep(1)
151
152
start = time.time()
153
send_views = requests.post(
154
self.url + "c2VuZC9mb2xsb3dlcnNfdGlrdG9V",
155
headers={
156
"cookie": f"PHPSESSID={sessid}",
157
"origin": "https://zefoy.com",
158
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
159
"x-requested-with": "XMLHttpRequest",
160
},
161
data={beta_key: VIDEO},
162
)
163
latency = round(time.time() - start, 2)
164
if latency > 3:
165
print(f"Sent views [id={VIDEO}]")
166
167
decrypted_response = self.decrypt(send_views.text)
168
169
if "Too many requests. Please slow down." in decrypted_response:
170
print("Ratelimited")
171
time.sleep(120)
172
continue
173
174
timer = self.decrypt_timer(decrypted_response)
175
176
print(f"Timer: {timer} (not animated")
177
time.sleep(timer)
178
179
print(f"Sending views ...")
180
181
def main(self):
182
sessid = self.get_sessid()
183
print(f"Sessid: {sessid}")
184
alpha_key: str = self.solve_captcha(sessid)
185
print("\n" + f"Alpha Key: {alpha_key.upper()}")
186
187
self.views_loop(sessid, alpha_key)
188
189
190
if __name__ == "__main__":
191
Main().main()
192
193