-
Notifications
You must be signed in to change notification settings - Fork 5
/
bot-proxy.py
421 lines (330 loc) · 16.1 KB
/
bot-proxy.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
import os
import sys
import time
import requests
from requests.auth import HTTPProxyAuth
from colorama import *
from datetime import datetime
import json
import random
red = Fore.LIGHTRED_EX
yellow = Fore.LIGHTYELLOW_EX
green = Fore.LIGHTGREEN_EX
black = Fore.LIGHTBLACK_EX
blue = Fore.LIGHTBLUE_EX
white = Fore.LIGHTWHITE_EX
reset = Style.RESET_ALL
# Get the directory where the script is located
script_dir = os.path.dirname(os.path.realpath(__file__))
# Construct the full paths to the files
data_file = os.path.join(script_dir, "data-proxy.json")
class Tomarket:
def __init__(self):
self.line = white + "~" * 50
self.banner = f"""
{blue}Smart Airdrop {white}Tomarket Auto Claimer
t.me/smartairdrop2120
"""
# Clear the terminal
def clear_terminal(self):
# For Windows
if os.name == "nt":
_ = os.system("cls")
# For macOS and Linux
else:
_ = os.system("clear")
def headers(self):
return {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Cache-Control": "no-cache",
"Origin": "https://mini-app.tomarket.ai",
"Pragma": "no-cache",
"Priority": "u=1, i",
"Referer": "https://mini-app.tomarket.ai/",
"Sec-Ch-Ua": '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": '"Windows"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
}
def proxies(self, proxy_info):
return {"http": f"{proxy_info}", "https": f"{proxy_info}"}
def check_ip(self, proxy_info):
url = "https://api.ipify.org?format=json"
proxies = self.proxies(proxy_info=proxy_info)
# Parse the proxy credentials if present
if "@" in proxy_info:
proxy_credentials = proxy_info.split("@")[0]
proxy_user = proxy_credentials.split(":")[1]
proxy_pass = proxy_credentials.split(":")[2]
auth = HTTPProxyAuth(proxy_user, proxy_pass)
else:
auth = None
try:
response = requests.get(url=url, proxies=proxies, auth=auth)
response.raise_for_status() # Raises an error for bad status codes
return response.json().get("ip")
except requests.exceptions.RequestException as e:
print(f"IP check failed: {e}")
return None
def login(self, data, proxy_info):
url = f"https://api-web.tomarket.ai/tomarket-game/v1/user/login"
headers = self.headers()
payload = {
"init_data": data,
"invite_code": "",
}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def balance(self, token, proxy_info):
url = f"https://api-web.tomarket.ai/tomarket-game/v1/user/balance"
headers = self.headers()
headers["Authorization"] = token
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, proxies=proxies)
return response
def start_farming(self, token, proxy_info):
url = "https://api-web.tomarket.ai/tomarket-game/v1/farm/start"
headers = self.headers()
headers["Authorization"] = token
payload = {"game_id": "53b22103-c7ff-413d-bc63-20f6fb806a07"}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def end_farming(self, token, proxy_info):
url = "https://api-web.tomarket.ai/tomarket-game/v1/farm/claim"
headers = self.headers()
headers["Authorization"] = token
payload = {"game_id": "53b22103-c7ff-413d-bc63-20f6fb806a07"}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def check_in(self, token, proxy_info):
url = "https://api-web.tomarket.ai/tomarket-game/v1/daily/claim"
headers = self.headers()
headers["Authorization"] = token
payload = {"game_id": "fa873d13-d831-4d6f-8aee-9cff7a1d0db1"}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def start_game(self, token, proxy_info):
url = "https://api-web.tomarket.ai/tomarket-game/v1/game/play"
headers = self.headers()
headers["Authorization"] = token
payload = {"game_id": "59bcd12e-04e2-404c-a172-311a0084587d"}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def claim_game(self, token, point, proxy_info):
url = "https://api-web.tomarket.ai/tomarket-game/v1/game/claim"
headers = self.headers()
headers["Authorization"] = token
payload = {"game_id": "59bcd12e-04e2-404c-a172-311a0084587d", "points": point}
data = json.dumps(payload)
headers["Content-Length"] = str(len(data))
headers["Content-Type"] = "application/json"
proxies = self.proxies(proxy_info=proxy_info)
response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
return response
def log(self, msg):
now = datetime.now().isoformat(" ").split(".")[0]
print(f"{black}[{now}]{reset} {msg}{reset}")
def parse_proxy_info(self, proxy_info):
try:
stripped_url = proxy_info.split("://", 1)[-1]
credentials, endpoint = stripped_url.split("@", 1)
user_name, password = credentials.split(":", 1)
ip, port = endpoint.split(":", 1)
return {"user_name": user_name, "pass": password, "ip": ip, "port": port}
except:
return None
def main(self):
while True:
self.clear_terminal()
print(self.banner)
accounts = json.load(open(data_file, "r"))["accounts"]
num_acc = len(accounts)
self.log(self.line)
self.log(f"{green}Numer of account: {white}{num_acc}")
end_at_list = []
for no, account in enumerate(accounts):
self.log(self.line)
self.log(f"{green}Account number: {white}{no+1}/{num_acc}")
data = account["acc_info"]
proxy_info = account["proxy_info"]
parsed_proxy_info = self.parse_proxy_info(proxy_info)
if parsed_proxy_info is None:
self.log(
f"{red}Check proxy format: {white}http://user:pass@ip:port"
)
break
ip_adress = parsed_proxy_info["ip"]
self.log(f"{green}Input IP Address: {white}{ip_adress}")
ip = self.check_ip(proxy_info=proxy_info)
self.log(f"{green}Actual IP Address: {white}{ip}")
# Login
try:
login = self.login(data=data, proxy_info=proxy_info).json()
token = login["data"]["access_token"]
if token:
user_info = (
self.balance(token=token, proxy_info=proxy_info)
.json()
.get("data")
)
current_time = user_info["timestamp"]
balance = user_info["available_balance"]
self.log(f"{green}Balance: {white}{balance}")
check_in = self.check_in(
token=token, proxy_info=proxy_info
).json()
if check_in["status"] == 200:
self.log(f"{green}Check in successful")
else:
self.log(f"{yellow}Checked in already")
if "farming" not in user_info.keys():
self.log(f"{yellow}Farming not started yet")
start_farming = self.start_farming(
token=token, proxy_info=proxy_info
)
if start_farming.status_code == 200:
self.log(f"{green}Start farming successful")
user_info = (
self.balance(token=token, proxy_info=proxy_info)
.json()
.get("data")
)
else:
self.log(f"{red}Start farming failed")
end_farming_time = user_info["farming"]["end_at"]
if current_time > end_farming_time:
end_farming = self.end_farming(
token=token, proxy_info=proxy_info
)
if end_farming.status_code == 200:
self.log(f"{green}End farming successful")
user_info = (
self.balance(token=token, proxy_info=proxy_info)
.json()
.get("data")
)
balance = user_info["available_balance"]
self.log(f"{green}Current balance: {white}{balance}")
time.sleep(10)
start_farming = self.start_farming(
token=token, proxy_info=proxy_info
)
if start_farming.status_code == 200:
self.log(f"{green}Start farming successful")
user_info = (
self.balance(token=token, proxy_info=proxy_info)
.json()
.get("data")
)
end_farming_time = user_info["farming"]["end_at"]
else:
self.log(f"{red}Start farming failed")
else:
self.log(f"{red}End farming failed")
else:
self.log(f"{yellow}Not time to claim yet")
readable_time = datetime.fromtimestamp(
end_farming_time
).strftime("%Y-%m-%d %H:%M:%S")
self.log(f"{green}Farm end at: {white}{readable_time}")
end_at_list.append(end_farming_time)
# Play game
available_tickets = user_info["play_passes"]
if available_tickets > 0:
self.log(
f"{green}Available tickets: {white}{available_tickets}"
)
while True:
self.log(f"{yellow}Start playing game")
start_game = self.start_game(
token=token, proxy_info=proxy_info
)
if start_game.status_code == 200:
self.log(f"{yellow}Playing game in 30s...")
time.sleep(30)
point = random.randint(500, 600)
claim_game = self.claim_game(
token=token, point=point, proxy_info=proxy_info
)
if claim_game.status_code == 200:
user_info = (
self.balance(
token=token, proxy_info=proxy_info
)
.json()
.get("data")
)
balance = user_info["available_balance"]
self.log(
f"{green}Current balance: {white}{balance}"
)
tickets_left = user_info["play_passes"]
self.log(
f"{green}Tickets left: {white}{tickets_left}"
)
if tickets_left == 0:
break
else:
self.log(f"{red}Claim point from game failed")
else:
self.log(f"{red}Start game failed")
else:
self.log(f"{yellow}No available game tickets")
else:
self.log(f"{red}Token not found!!!")
except Exception as e:
self.log(f"{red}Get auth data error!!!")
print()
if end_at_list:
now = datetime.now().timestamp()
wait_times = [end_at - now for end_at in end_at_list if end_at > now]
if wait_times:
wait_time = min(wait_times) + 30
else:
wait_time = 15 * 60
else:
wait_time = 15 * 60
wait_hours = int(wait_time // 3600)
wait_minutes = int((wait_time % 3600) // 60)
wait_seconds = int(wait_time % 60)
wait_message_parts = []
if wait_hours > 0:
wait_message_parts.append(f"{wait_hours} hours")
if wait_minutes > 0:
wait_message_parts.append(f"{wait_minutes} minutes")
if wait_seconds > 0:
wait_message_parts.append(f"{wait_seconds} seconds")
wait_message = ", ".join(wait_message_parts)
self.log(f"{yellow}Wait for {wait_message}!")
time.sleep(wait_time)
if __name__ == "__main__":
try:
tomarket = Tomarket()
tomarket.main()
except KeyboardInterrupt:
sys.exit()