-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
392 lines (332 loc) · 18.3 KB
/
bot.py
File metadata and controls
392 lines (332 loc) · 18.3 KB
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
from aiohttp import ClientResponseError, ClientSession, ClientTimeout, BasicAuth
from aiohttp_socks import ProxyConnector
from fake_useragent import FakeUserAgent
from datetime import datetime, timezone
from colorama import *
import asyncio, random, json, pytz, re, os
wib = pytz.timezone('Asia/Jakarta')
class Dawn:
def __init__(self) -> None:
self.BASE_API = "https://api.dawninternet.com"
self.HEADERS = {}
self.proxies = []
self.proxy_index = 0
self.account_proxies = {}
self.user_ids = {}
self.session_tokens = {}
def clear_terminal(self):
os.system('cls' if os.name == 'nt' else 'clear')
def log(self, message):
print(
f"{Fore.CYAN + Style.BRIGHT}╭─[{datetime.now().astimezone(wib).strftime('%x %X %Z')}]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} ─ {Style.RESET_ALL}{message}"
f"\n{Fore.CYAN + Style.BRIGHT}╰─⋆ {Fore.MAGENTA}DAWN-BOT BY DROPSTERMIND{Style.RESET_ALL}",
flush=True
)
def welcome(self):
print(
f"""
{Fore.GREEN + Style.BRIGHT}╔══════════════════════════════════════════════════════════════╗
{Fore.GREEN + Style.BRIGHT}║ ║
{Fore.GREEN + Style.BRIGHT}║ ██████╗ █████╗ ██╗ ██╗███╗ ██╗ ║
{Fore.GREEN + Style.BRIGHT}║ ██╔══██╗██╔══██╗██║ ██║████╗ ██║ ║
{Fore.GREEN + Style.BRIGHT}║ ██║ ██║███████║██║ █╗ ██║██╔██╗ ██║ ║
{Fore.GREEN + Style.BRIGHT}║ ██║ ██║██╔══██║██║███╗██║██║╚██╗██║ ║
{Fore.GREEN + Style.BRIGHT}║ ██████╔╝██║ ██║╚███╔███╔╝██║ ╚████║ ║
{Fore.GREEN + Style.BRIGHT}║ ╚═════╝ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═══╝ ║
{Fore.GREEN + Style.BRIGHT}║ ║
{Fore.BLUE + Style.BRIGHT}║ 🚀 AUTO VALIDATOR BOT ACTIVATED 🚀 ║
{Fore.GREEN + Style.BRIGHT}║ ║
{Fore.YELLOW + Style.BRIGHT}║ ✦ DAWN-BOT BY DROPSTERMIND ✦ ║
{Fore.GREEN + Style.BRIGHT}║ ║
{Fore.GREEN + Style.BRIGHT}╚══════════════════════════════════════════════════════════════╝{Style.RESET_ALL}
"""
)
def format_seconds(self, seconds):
hours, remainder = divmod(seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}"
def load_accounts(self):
filename = "tokens.json"
try:
if not os.path.exists(filename):
self.log(f"{Fore.RED}❌ File {filename} Not Found{Style.RESET_ALL}")
return
with open(filename, 'r') as file:
data = json.load(file)
if isinstance(data, list):
return data
return []
except json.JSONDecodeError:
return []
async def load_proxies(self):
filename = "proxy.txt"
try:
if not os.path.exists(filename):
self.log(f"{Fore.RED + Style.BRIGHT}❌ File {filename} Not Found{Style.RESET_ALL}")
return
with open(filename, 'r') as f:
self.proxies = [line.strip() for line in f.read().splitlines() if line.strip()]
if not self.proxies:
self.log(f"{Fore.RED + Style.BRIGHT}❌ No Proxies Found{Style.RESET_ALL}")
return
self.log(
f"{Fore.GREEN + Style.BRIGHT}📊 Proxies Total : {Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT}{len(self.proxies)}{Style.RESET_ALL}"
)
except Exception as e:
self.log(f"{Fore.RED + Style.BRIGHT}❌ Failed To Load Proxies: {e}{Style.RESET_ALL}")
self.proxies = []
def check_proxy_schemes(self, proxies):
schemes = ["http://", "https://", "socks4://", "socks5://"]
if any(proxies.startswith(scheme) for scheme in schemes):
return proxies
return f"http://{proxies}"
def get_next_proxy_for_account(self, account):
if account not in self.account_proxies:
if not self.proxies:
return None
proxy = self.check_proxy_schemes(self.proxies[self.proxy_index])
self.account_proxies[account] = proxy
self.proxy_index = (self.proxy_index + 1) % len(self.proxies)
return self.account_proxies[account]
def rotate_proxy_for_account(self, account):
if not self.proxies:
return None
proxy = self.check_proxy_schemes(self.proxies[self.proxy_index])
self.account_proxies[account] = proxy
self.proxy_index = (self.proxy_index + 1) % len(self.proxies)
return proxy
def build_proxy_config(self, proxy=None):
if not proxy:
return None, None, None
if proxy.startswith("socks"):
connector = ProxyConnector.from_url(proxy)
return connector, None, None
elif proxy.startswith("http"):
match = re.match(r"http://(.*?):(.*?)@(.*)", proxy)
if match:
username, password, host_port = match.groups()
clean_url = f"http://{host_port}"
auth = BasicAuth(username, password)
return None, clean_url, auth
else:
return None, proxy, None
raise Exception("Unsupported Proxy Type.")
def mask_account(self, account):
if "@" in account:
local, domain = account.split('@', 1)
mask_account = local[:3] + '*' * 3 + local[-3:]
return f"{mask_account}@{domain}"
def print_message(self, email, proxy, color, message):
self.log(
f"{Fore.CYAN + Style.BRIGHT}👤 Account:{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} {self.mask_account(email)} {Style.RESET_ALL}"
f"{Fore.MAGENTA + Style.BRIGHT} • {Style.RESET_ALL}"
f"{Fore.CYAN + Style.BRIGHT}🌐 Proxy: {Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT}{proxy}{Style.RESET_ALL}"
f"{Fore.MAGENTA + Style.BRIGHT} • {Style.RESET_ALL}"
f"{Fore.CYAN + Style.BRIGHT}📊 Status:{Style.RESET_ALL}"
f"{color + Style.BRIGHT} {message} {Style.RESET_ALL}"
)
def print_question(self):
while True:
try:
print(f"\n{Fore.WHITE + Style.BRIGHT}╭─{Fore.CYAN} PROXY CONFIGURATION {Fore.WHITE}─{'─'*40}╮")
print(f"{Fore.WHITE + Style.BRIGHT}│ {Fore.GREEN}1.{Style.RESET_ALL} {Fore.WHITE}Run With Proxy{Style.RESET_ALL}")
print(f"{Fore.WHITE + Style.BRIGHT}│ {Fore.GREEN}2.{Style.RESET_ALL} {Fore.WHITE}Run Without Proxy{Style.RESET_ALL}")
print(f"{Fore.WHITE + Style.BRIGHT}╰{'─'*60}╯")
proxy_choice = int(input(f"\n{Fore.BLUE + Style.BRIGHT}🎯 Choose [1/2] → {Style.RESET_ALL}").strip())
if proxy_choice in [1, 2]:
proxy_type = (
"With" if proxy_choice == 1 else
"Without"
)
print(f"\n{Fore.GREEN + Style.BRIGHT}✅ {proxy_type} Proxy Selected{Style.RESET_ALL}")
break
else:
print(f"\n{Fore.RED + Style.BRIGHT}❌ Please enter either 1 or 2{Style.RESET_ALL}")
except ValueError:
print(f"\n{Fore.RED + Style.BRIGHT}❌ Invalid input. Enter a number (1 or 2){Style.RESET_ALL}")
rotate_proxy = False
if proxy_choice == 1:
while True:
rotate_proxy = input(f"\n{Fore.BLUE + Style.BRIGHT}🔄 Rotate Invalid Proxy? [y/n] → {Style.RESET_ALL}").strip()
if rotate_proxy in ["y", "n"]:
rotate_proxy = rotate_proxy == "y"
break
else:
print(f"\n{Fore.RED + Style.BRIGHT}❌ Invalid input. Enter 'y' or 'n'{Style.RESET_ALL}")
return proxy_choice, rotate_proxy
async def check_connection(self, email: str, proxy_url=None):
connector, proxy, proxy_auth = self.build_proxy_config(proxy_url)
try:
async with ClientSession(connector=connector, timeout=ClientTimeout(total=10)) as session:
async with session.get(url="https://api.ipify.org?format=json", proxy=proxy, proxy_auth=proxy_auth) as response:
response.raise_for_status()
return True
except (Exception, ClientResponseError) as e:
self.print_message(email, proxy, Fore.RED, f"❌ Connection Failed: {Fore.YELLOW+Style.BRIGHT}{str(e)}")
return None
async def user_point(self, email: str, proxy_url=None, retries=5):
url = f"{self.BASE_API}/point?user_id={self.user_ids[email]}"
headers = {
**self.HEADERS[email],
"Authorization": f"Bearer {self.session_tokens[email]}"
}
for attempt in range(retries):
connector, proxy, proxy_auth = self.build_proxy_config(proxy_url)
try:
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session:
async with session.get(url=url, headers=headers, proxy=proxy, proxy_auth=proxy_auth) as response:
if response.status == 401:
self.print_message(email, proxy, Fore.RED, f"❌ GET Earning Failed: {Fore.YELLOW+Style.BRIGHT}Token Expired")
return None
response.raise_for_status()
return await response.json()
except (Exception, ClientResponseError) as e:
if attempt < retries - 1:
await asyncio.sleep(5)
continue
self.print_message(email, proxy, Fore.RED, f"❌ GET Earning Failed: {Fore.YELLOW+Style.BRIGHT}{str(e)}")
return None
async def extension_ping(self, email: str, timestamp: str, proxy_url=None, retries=5):
url = f"{self.BASE_API}/ping?role=extension"
data = json.dumps({
"user_id": self.user_ids[email],
"extension_id": "fpdkjdnhkakefebpekbdhillbhonfjjp",
"timestamp": timestamp
})
headers = {
**self.HEADERS[email],
"Authorization": f"Bearer {self.session_tokens[email]}",
"Content-Length": str(len(data)),
"Content-Type": "application/json"
}
for attempt in range(retries):
connector, proxy, proxy_auth = self.build_proxy_config(proxy_url)
try:
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session:
async with session.post(url=url, headers=headers, data=data, proxy=proxy, proxy_auth=proxy_auth) as response:
if response.status == 401:
self.print_message(email, proxy, Fore.RED, f"❌ PING Failed: {Fore.YELLOW+Style.BRIGHT}Token Expired")
return None
elif response.status == 429:
self.print_message(email, proxy, Fore.RED, f"❌ PING Failed: {Fore.YELLOW+Style.BRIGHT}Too Many Requests")
return None
response.raise_for_status()
return await response.json()
except (Exception, ClientResponseError) as e:
if attempt < retries - 1:
await asyncio.sleep(5)
continue
self.print_message(email, proxy, Fore.RED, f"❌ PING Failed: {Fore.YELLOW+Style.BRIGHT}{str(e)}")
return None
async def process_check_connection(self, email: str, use_proxy: bool, rotate_proxy: bool):
while True:
proxy = self.get_next_proxy_for_account(email) if use_proxy else None
is_valid = await self.check_connection(email, proxy)
if is_valid:
return True
if rotate_proxy:
proxy = self.rotate_proxy_for_account(email)
await asyncio.sleep(1)
async def process_user_earning(self, email: str, use_proxy: bool):
while True:
proxy = self.get_next_proxy_for_account(email) if use_proxy else None
user = await self.user_point(email, proxy)
if user:
node_points = user.get("points", 0)
referral_points = user.get("referral_points", 0)
total_points = node_points + referral_points
self.print_message(email, proxy, Fore.WHITE, f"💰 Earning {total_points} PTS")
await asyncio.sleep(5 * 60)
async def process_send_keepalive(self, email: str, use_proxy: bool):
while True:
proxy = self.get_next_proxy_for_account(email) if use_proxy else None
await asyncio.sleep(3)
print(
f"{Fore.CYAN + Style.BRIGHT}╭─[{datetime.now().astimezone(wib).strftime('%x %X %Z')}]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} ─ {Style.RESET_ALL}"
f"{Fore.BLUE + Style.BRIGHT}⏳ Waiting 10 minutes for next ping...{Style.RESET_ALL}"
f"\n{Fore.CYAN + Style.BRIGHT}╰─⋆ {Fore.MAGENTA}DAWN-BOT BY DROPSTERMIND{Style.RESET_ALL}",
end="\r",
flush=True
)
await asyncio.sleep(10 * 60)
timestamp = datetime.now(timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z")
keepalive = await self.extension_ping(email, timestamp, proxy)
if keepalive:
message = keepalive.get("message")
self.print_message(email, proxy, Fore.GREEN, "✅ PING Success "
f"{Fore.MAGENTA + Style.BRIGHT}•{Style.RESET_ALL}"
f"{Fore.CYAN + Style.BRIGHT} Message: {Style.RESET_ALL}"
f"{Fore.BLUE + Style.BRIGHT}{message}{Style.RESET_ALL}"
)
async def process_accounts(self, email: str, use_proxy: bool, rotate_proxy: bool):
is_valid = await self.process_check_connection(email, use_proxy, rotate_proxy)
if is_valid:
tasks = [
asyncio.create_task(self.process_user_earning(email, use_proxy)),
asyncio.create_task(self.process_send_keepalive(email, use_proxy))
]
await asyncio.gather(*tasks)
async def main(self):
try:
accounts = self.load_accounts()
if not accounts:
self.log(f"{Fore.RED + Style.BRIGHT}❌ No Accounts Loaded{Style.RESET_ALL}")
return
proxy_choice, rotate_proxy = self.print_question()
self.clear_terminal()
self.welcome()
self.log(
f"{Fore.GREEN + Style.BRIGHT}📦 Account's Total: {Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT}{len(accounts)}{Style.RESET_ALL}"
)
use_proxy = True if proxy_choice == 1 else False
if use_proxy:
await self.load_proxies()
self.log(f"{Fore.CYAN + Style.BRIGHT}🚀 Starting Bot Operations...{Style.RESET_ALL}")
tasks = []
for idx, account in enumerate(accounts, start=1):
if account:
email = account["email"]
user_id = account["userId"]
session_token = account["sessionToken"]
if not "@" in email or not user_id or not session_token:
self.log(
f"{Fore.CYAN + Style.BRIGHT}👤 Account: {Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT}{idx}{Style.RESET_ALL}"
f"{Fore.MAGENTA + Style.BRIGHT} • {Style.RESET_ALL}"
f"{Fore.CYAN + Style.BRIGHT}📊 Status:{Style.RESET_ALL}"
f"{Fore.RED + Style.BRIGHT} ❌ Invalid Account Data {Style.RESET_ALL}"
)
continue
self.HEADERS[email] = {
"Accept": "*/*",
"Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
"Origin": "chrome-extension://fpdkjdnhkakefebpekbdhillbhonfjjp",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": FakeUserAgent().random
}
self.user_ids[email] = user_id
self.session_tokens[email] = session_token
tasks.append(asyncio.create_task(self.process_accounts(email, use_proxy, rotate_proxy)))
await asyncio.gather(*tasks)
except Exception as e:
self.log(f"{Fore.RED+Style.BRIGHT}💥 Error: {e}{Style.RESET_ALL}")
raise e
if __name__ == "__main__":
try:
bot = Dawn()
asyncio.run(bot.main())
except KeyboardInterrupt:
print(
f"\n{Fore.CYAN + Style.BRIGHT}╭─[{datetime.now().astimezone(wib).strftime('%x %X %Z')}]{Style.RESET_ALL}"
f"{Fore.WHITE + Style.BRIGHT} ─ {Style.RESET_ALL}"
f"{Fore.RED + Style.BRIGHT}🛑 BOT STOPPED BY USER{Style.RESET_ALL}"
f"\n{Fore.CYAN + Style.BRIGHT}╰─⋆ {Fore.MAGENTA}DAWN-BOT BY DROPSTERMIND{Style.RESET_ALL}"
)