Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
xtekky
GitHub Repository: xtekky/tiktok-viewbot
Path: blob/main/old/main.py
619 views
1
from tls_client import Session
2
from re import findall
3
from PIL import Image
4
from io import BytesIO
5
from requests import get
6
from urllib.parse import unquote
7
from base64 import b64decode
8
from time import sleep, time
9
from colorama import Fore, init; init()
10
from datetime import datetime
11
from json import load
12
13
mode = 'c2VuZF9mb2xsb3dlcnNfdGlrdG9L'
14
15
16
def fmt(string) -> str:
17
return f"{Fore.CYAN}{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} {Fore.BLUE}INFO {Fore.MAGENTA}__main__ -> {Fore.RESET}{string}"
18
19
class Client:
20
def session() -> Session:
21
return Session(client_identifier='chrome110')
22
23
def headers(extra: dict = {}) -> dict:
24
return {
25
**extra,
26
'authority': 'zefoy.com',
27
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
28
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
29
'cache-control': 'no-cache',
30
'cp-extension-installed': 'Yes',
31
'pragma': 'no-cache',
32
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
33
'sec-ch-ua-mobile': '?0',
34
'sec-ch-ua-platform': '"macOS"',
35
'sec-fetch-dest': 'document',
36
'sec-fetch-mode': 'navigate',
37
'sec-fetch-site': 'none',
38
'sec-fetch-user': '?1',
39
'upgrade-insecure-requests': '1',
40
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
41
}
42
43
class Captcha:
44
def __init__(this, client: Session) -> None:
45
this.client = client
46
47
def solve(this) -> None:
48
try:
49
html = str(this.client.get('https://zefoy.com', headers = Client.headers()).text).replace('&', '&')
50
51
captcha_token = findall(r'<input type="hidden" name="(.*)">', html)[0]
52
captcha_url = findall(r'img src="([^"]*)"', html)[0]
53
captcha_token_v2 = findall(r'type="text" maxlength="50" name="(.*)" oninput="this.value', html)[0]
54
55
print(fmt(f'captcha_token: {captcha_token}'))
56
print(fmt(f'captcha_url: {captcha_url}'))
57
58
captcha_image = get('https://zefoy.com' + captcha_url, headers = Client.headers(), cookies=this.client.cookies.get_dict()).content;
59
image = Image.open(BytesIO(captcha_image));image.show()
60
61
captcha_answer = input('solve captcha: ')
62
63
response = this.client.post('https://zefoy.com', headers = Client.headers({"content-type": "application/x-www-form-urlencoded"}), data = {
64
captcha_token_v2: captcha_answer,
65
captcha_token : ""
66
})
67
68
key_1 = findall('(?<=")[a-z0-9]{16}', response.text)[0]
69
70
print(fmt(f'key_1: {key_1}'))
71
72
return key_1
73
74
except Exception as e:
75
print(fmt(f'Failed to solve captcha (zefoy may have blocked you) [{e}]'))
76
return
77
78
class Zefoy:
79
def __init__(this, client: Session) -> None:
80
this.client = client
81
this.key = Captcha(client).solve()
82
this.config = load(open('config.json', 'r'))
83
84
def decode(this, text: str) -> str:
85
return b64decode(unquote(text[::-1])).decode()
86
87
def send(this, token: str, aweme_id: str) -> None:
88
try:
89
payload = f"--tekky\r\nContent-Disposition: form-data; name=\"{token}\"\r\n\r\n{aweme_id}\r\n--tekky--\r\n"
90
response = this.decode(this.client.post("https://zefoy.com/" + mode,
91
data = payload, headers = Client.headers({"content-type": "multipart/form-data; boundary=tekky",})).text.encode())
92
93
if 'views sent' in response:
94
print(fmt(f'views sent to {aweme_id}'))
95
96
else:
97
print(fmt(f'Failed to send views to {aweme_id}'))
98
99
except Exception as e:
100
print(fmt(f'Failed to send views [{e}]'))
101
102
def search(this, link: str) -> None:
103
try:
104
105
payload = f"--tekky\r\nContent-Disposition: form-data; name=\"{this.key}\"\r\n\r\n{link}\r\n--tekky--\r\n"
106
response = this.decode(this.client.post("https://zefoy.com/" + mode,
107
data = payload, headers = Client.headers({"content-type": "multipart/form-data; boundary=tekky",})).text.encode())
108
109
if 'comviews' in response:
110
token, aweme_id = findall(r'name="(.*)" value="(.*)" hidden', response)[0]
111
print(fmt(f'sending to: {aweme_id} | key_2: {token}'))
112
113
sleep(3); this.send(token, aweme_id)
114
115
else:
116
117
timer = findall(r'ltm=(\d*);', response)[0]
118
if int(timer) == 0:
119
return
120
121
print(fmt(f'time to sleep: {timer} '), end="\r")
122
123
start = time()
124
while time() < start + int(timer):
125
126
print(fmt(f'time to sleep: {round((start + int(timer)) - time())} '), end="\r")
127
sleep(1)
128
129
print(fmt(f'sending views... '), end="\r")
130
131
except Exception as e:
132
print(fmt(f'Failed to search link [{e}]'))
133
print(fmt(response))
134
return
135
136
def mainloop(this) -> None:
137
while True:
138
this.search(this.config['link'])
139
sleep(5)
140
141
if __name__ == '__main__':
142
client = Client.session()
143
zefoy = Zefoy(client).mainloop()
144
145
146