-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.py
More file actions
2905 lines (2574 loc) · 132 KB
/
app.py
File metadata and controls
2905 lines (2574 loc) · 132 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
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import threading
import jwt
import random
from threading import Thread
import json
import requests
import google.protobuf
from protobuf_decoder.protobuf_decoder import Parser
import json
import datetime
from datetime import datetime
from google.protobuf.json_format import MessageToJson
import my_message_pb2
import data_pb2
import base64
import logging
import re
import socket
from google.protobuf.timestamp_pb2 import Timestamp
import jwt_generator_pb2
import os
import binascii
import sys
import psutil
import MajorLoginRes_pb2
from time import sleep
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import time
import urllib3
from important_zitado import*
from byte import*
# --- START: Added for improved error handling and logging ---
# Configure logging to provide clear information about the bot's status and errors.
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler("bot_activity.log"),
logging.StreamHandler(sys.stdout)
]
)
# --- END: Added for improved error handling and logging ---
tempid = None
sent_inv = False
start_par = False
pleaseaccept = False
nameinv = "none"
idinv = 0
senthi = False
statusinfo = False
tempdata1 = None
tempdata = None
leaveee = False
leaveee1 = False
data22 = None
isroom = False
isroom2 = False
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def encrypt_packet(plain_text, key, iv):
plain_text = bytes.fromhex(plain_text)
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher_text = cipher.encrypt(pad(plain_text, AES.block_size))
return cipher_text.hex()
def gethashteam(hexxx):
a = zitado_get_proto(hexxx)
if not a:
raise ValueError("Invalid hex format or empty response from zitado_get_proto")
data = json.loads(a)
return data['5']['7']
def getownteam(hexxx):
a = zitado_get_proto(hexxx)
if not a:
raise ValueError("Invalid hex format or empty response from zitado_get_proto")
data = json.loads(a)
return data['5']['1']
def get_player_status(packet):
json_result = get_available_room(packet)
parsed_data = json.loads(json_result)
if "5" not in parsed_data or "data" not in parsed_data["5"]:
return "OFFLINE"
json_data = parsed_data["5"]["data"]
if "1" not in json_data or "data" not in json_data["1"]:
return "OFFLINE"
data = json_data["1"]["data"]
if "3" not in data:
return "OFFLINE"
status_data = data["3"]
if "data" not in status_data:
return "OFFLINE"
status = status_data["data"]
if status == 1:
return "SOLO"
if status == 2:
if "9" in data and "data" in data["9"]:
group_count = data["9"]["data"]
countmax1 = data["10"]["data"]
countmax = countmax1 + 1
return f"INSQUAD ({group_count}/{countmax})"
return "INSQUAD"
if status in [3, 5]:
return "INGAME"
if status == 4:
return "IN ROOM"
if status in [6, 7]:
return "IN SOCIAL ISLAND MODE .."
return "NOTFOUND"
def get_idroom_by_idplayer(packet):
json_result = get_available_room(packet)
parsed_data = json.loads(json_result)
json_data = parsed_data["5"]["data"]
data = json_data["1"]["data"]
idroom = data['15']["data"]
return idroom
def get_leader(packet):
json_result = get_available_room(packet)
parsed_data = json.loads(json_result)
json_data = parsed_data["5"]["data"]
data = json_data["1"]["data"]
leader = data['8']["data"]
return leader
def generate_random_color():
color_list = [
"[00FF00][b][c]",
"[FFDD00][b][c]",
"[3813F3][b][c]",
"[FF0000][b][c]",
"[0000FF][b][c]",
"[FFA500][b][c]",
"[DF07F8][b][c]",
"[11EAFD][b][c]",
"[DCE775][b][c]",
"[A8E6CF][b][c]",
"[7CB342][b][c]",
"[FF0000][b][c]",
"[FFB300][b][c]",
"[90EE90][b][c]"
]
random_color = random.choice(color_list)
return random_color
def fix_num(num):
fixed = ""
count = 0
num_str = str(num) # Convert the number to a string
for char in num_str:
if char.isdigit():
count += 1
fixed += char
if count == 3:
fixed += "[c]"
count = 0
return fixed
def fix_word(num):
fixed = ""
count = 0
for char in num:
if char:
count += 1
fixed += char
if count == 3:
fixed += "[c]"
count = 0
return fixed
def check_banned_status(player_id):
url = f"https://bancheck.tsunstudio.pw/bancheck?uid={player_id}"
try:
response = requests.get(url)
if response.status_code == 200:
data = response.json()
# Filter the response to only include the required fields
filtered_data = {
"nickname": data.get("nickname", "N/A"),
"AccountLevel": data.get("AccountLevel", "N/A"),
"status": data.get("status", "N/A"),
"Last_Login": data.get("Last_Login", "N/A")
}
return filtered_data
else:
return {"error": f"Failed to fetch data. Status code: {response.status_code}"}
except Exception as e:
return {"error": str(e)}
# --- START: ADD THIS NEW AND IMPROVED FUNCTION ---
def send_vistttt(uid):
try:
# Step 1: Validate the UID first to avoid unnecessary API calls.
info_response = newinfo(uid)
if info_response.get('status') != "ok":
return (
f"[b][c][FF0000]╔═══════「 ❌ Error ❌ 」═══════╗\n\n"
f"[FFFFFF]Invalid Player ID: [FFFF00]{fix_num(uid)}\n"
f"[FFFFFF]Please check the number and try again.\n\n"
f"[FF0000]╚═══════════════════════════╝"
)
# Get player information from the response
info = info_response['info']
nickname = info.get('AccountName', 'Unknown')
level = info.get('AccountLevel', 0)
likes = info.get('AccountLikes', 0)
region = info.get('AccountRegion', 'Unknown')
# Step 2: Call the new visit API.
api_url = f"https://visit.tsunstudio.pw/pk/{uid}"
response = requests.get(api_url, timeout=15)
# Step 3: Process the API response.
if response.status_code == 200:
data = response.json()
success_count = data.get('success', 0)
if success_count > 0:
# Format a premium success message.
return (
f"[b][c][FF0000]╔═ ✅ Visit Success ✅ ═╗\n\n"
f"[FFFFFF]Successfully sent [FFFF00]{success_count}[FFFFFF] visits to:\n\n"
f"[00BFFF]👤 Nickname: [FFFFFF]{nickname}\n"
f"[00BFFF]🆔 Player ID: [FFFFFF]{fix_num(uid)}\n"
f"[00BFFF]🎖️ Level: [FFFFFF]{level}\n"
f"[00BFFF]❤️ Likes: [FFFFFF]{fix_num(likes)}\n"
f"[00BFFF]🌏 Region: [FFFFFF]{region}\n\n"
f"[FF0000]╚══════════╝"
)
else:
# Handle cases where the API returns a success status but sends 0 visits.
return (
f"[b][c][FF0000]╔═════「 ⚠️ Warning ⚠️ 」═════╗\n\n"
f"[FFFFFF]API call was successful, but no visits\n"
f"[FFFFFF]were sent. This might be a daily limit.\n\n"
f"[FF0000]╚══════════════════════════╝"
)
else:
# Handle API server errors.
return (
f"[b][c][FF0000]╔═══════「 ❌ API Error ❌ 」═══════╗\n\n"
f"[FFFFFF]The visit server returned an error.\n"
f"[FFFFFF]Status Code: [FFFF00]{response.status_code}\n\n"
f"[FF0000]╚════════════════════════════╝"
)
except requests.exceptions.RequestException as e:
# Handle network or connection errors.
return (
f"[b][c][FF0000]╔════「 🔌 Connection Error 🔌 」════╗\n\n"
f"[FFFFFF]Could not connect to the visit API server.\n"
f"[FFFFFF]Please try again later.\n\n"
f"[FF0000]╚══════════════════════════════╝"
)
except Exception as e:
# Handle any other unexpected errors.
logging.error(f"An unexpected error occurred in send_vistttt: {str(e)}")
return (
f"[b][c][FF0000]╔════「 ⚙️ System Error ⚙️ 」════╗\n\n"
f"[FFFFFF]An unexpected error occurred.\n"
f"[FFFFFF]Check the logs for more details.\n\n"
f"[FF0000]╚══════════════════════════╝"
)
# --- END: ADD THIS NEW AND IMPROVED FUNCTION ---
except requests.exceptions.RequestException as e:
# Handle network connection errors.
return (
f"[FF0000]________________________\n"
f"Failed to connect to the server:\n"
f"{str(e)}\n"
f"________________________\n"
)
except Exception as e:
# Handle other potential errors, like JSON parsing issues.
return (
f"[FF0000]________________________\n"
f"An unexpected error occurred: {str(e)}\n"
f"________________________\n"
)
# --- END: ADD THIS NEW FUNCTION ---
def rrrrrrrrrrrrrr(number):
if isinstance(number, str) and '***' in number:
return number.replace('***', '106')
return number
def newinfo(uid):
try:
# The new API URL
url = f"https://ffinfo.tsunstudio.pw/get?uid={uid}"
# Make the request with a timeout to prevent it from hanging
response = requests.get(url, timeout=15)
# A successful request returns status code 200
if response.status_code == 200:
data = response.json()
# Check for a key like 'AccountInfo' to confirm the API returned valid data
if "AccountInfo" in data and data["AccountInfo"]:
# Extract the relevant information from the new API response
account_info = data["AccountInfo"]
account_profile_info = data.get("AccountProfileInfo", {})
guild_info = data.get("GuildInfo", {})
social_info = data.get("SocialInfo", {})
# Create a simplified info dictionary with the required fields
info = {
"AccountName": account_info.get("AccountName", "Unknown"),
"AccountLevel": account_info.get("AccountLevel", 0),
"AccountLikes": account_info.get("AccountLikes", 0),
"AccountRegion": account_info.get("AccountRegion", "Unknown"),
"BrMaxRank": account_profile_info.get("BrMaxRank", 0),
"CsMaxRank": account_profile_info.get("CsMaxRank", 0),
"GuildName": guild_info.get("GuildName", "None"),
"signature": social_info.get("signature", "No signature"),
"accountId": account_info.get("accountId", uid)
}
return {"status": "ok", "info": info}
else:
# This handles cases where the API returns 200 but the ID was invalid
return {"status": "wrong_id"}
else:
logging.error(f"Error: API returned status code {response.status_code} for UID {uid}")
return {"status": "wrong_id"}
except requests.exceptions.RequestException as e:
# Handle network issues like timeouts or connection errors
logging.error(f"Error during newinfo request: {str(e)}")
return {"status": "error", "message": str(e)}
except Exception as e:
# Handle any other unexpected errors
logging.error(f"An unexpected error occurred in newinfo: {str(e)}")
return {"status": "error", "message": str(e)}
import requests
def send_spam(uid):
try:
# First, check the validity of the ID using the newinfo function
info_response = newinfo(uid)
if info_response.get('status') != "ok":
return (
f"[FF0000]-----------------------------------\n"
f"Error in ID: {fix_num(uid)}\n"
f"Please check the number\n"
f"-----------------------------------\n"
)
# Second, send the request to the correct link using the ID
api_url = f"https://spam-free.vercel.app/spam?id={uid}"
response = requests.get(api_url)
# Third, check if the request was successful
if response.status_code == 200:
return (
f"{generate_random_color()}-----------------------------------\n"
f"Friend request sent successfully ✅\n"
f"To: {fix_num(uid)}\n"
f"-----------------------------------\n"
)
else:
return (
f"[FF0000]-----------------------------------\n"
f"Failed to send (Error code: {response.status_code})\n"
f"-----------------------------------\n"
)
except requests.exceptions.RequestException as e:
# Handle network connection errors
return (
f"[FF0000]-----------------------------------\n"
f"Failed to connect to the server:\n"
f"{str(e)}\n"
f"-----------------------------------\n"
)
def attack_profail(player_id):
url = f"https://visit.tsunstudio.pw/pk/{player_id}"
res = requests.get(url)
if res.status_code() == 200:
logging.info("Done-Attack")
else:
logging.error("Fuck-Attack")
def send_likes(uid):
try:
# First, validate the UID using the newinfo function
info_response = newinfo(uid)
if info_response.get('status') != "ok":
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ Invalid Player ID: {fix_num(uid)}\n"
f" Please check the number and try again.\n"
f"________________________"
)
}
# Get player information from the response
info = info_response['info']
player_name = info.get('AccountName', 'Unknown')
# Attempt to connect to the new likes API for the PK server
likes_api_response = requests.get(
f"https://private-like-api.vercel.app/like?uid={uid}&server_name=PK&key=Nilay-Ron",
timeout=15 # Add a timeout to prevent it from hanging
)
# Check if the API request was successful
if likes_api_response.status_code == 200:
api_json_response = likes_api_response.json()
# Extract the nested "response" object
response_data = api_json_response.get('response', {})
# Extract relevant fields
likes_added = response_data.get('LikesGivenByAPI', 0)
likes_before = response_data.get('LikesbeforeCommand', 0)
likes_after = response_data.get('LikesafterCommand', 0)
key_remaining = response_data.get('KeyRemainingRequests', 'N/A')
if likes_added == 0:
# Case: Daily limit reached or no likes added
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ Daily limit for sending likes reached!\n"
f" Try again after 24 hours\n"
f" ❤️ Key Remaining: [00FFFF]{key_remaining}\n"
f"________________________"
)
}
else:
# Case: Success with details
return {
"status": "ok",
"message": (
f"[C][B][00FF00]________________________\n"
f" ✅ Added {likes_added} likes\n"
f" Name: {player_name}\n"
f" Previous Likes: {likes_before}\n"
f" New Likes: {likes_after}\n"
f" ❤️ Key Remaining: [00FFFF]{key_remaining}\n"
f"________________________"
)
}
else:
# Case: General API failure
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ Sending error!\n"
f" Please check the validity of the User ID\n"
f"________________________"
)
}
except requests.exceptions.RequestException:
# Handle network errors (e.g., API is not running)
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ API Connection Failed!\n"
f" Please ensure the API server is running\n"
f"________________________"
)
}
except Exception as e:
# Catch any other unexpected errors
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ An unexpected error occurred: {str(e)}\n"
f"________________________"
)
}
def get_info(uid):
try:
# Call the newinfo function to get player information
info_response = newinfo(uid)
# Check if the API request was successful
if info_response.get('status') == "ok":
info = info_response['info']
# Extract relevant fields from the response
account_name = info.get('AccountName', 'Unknown')
account_level = info.get('AccountLevel', 0)
account_likes = info.get('AccountLikes', 0)
account_region = info.get('AccountRegion', 'Unknown')
br_max_rank = info.get('BrMaxRank', 0)
cs_max_rank = info.get('CsMaxRank', 0)
guild_name = info.get('GuildName', 'None')
signature = info.get('signature', 'No signature')
# Case: Success with player details
return {
"status": "ok",
"message": (
f"[C][B][00FF00]________________________\n"
f" ✅ Player Information\n"
f" Name: {account_name}\n"
f" Level: {account_level}\n"
f" Likes: {account_likes}\n"
f" Region: {account_region}\n"
f" BR Max Rank: {br_max_rank}\n"
f" CS Max Rank: {cs_max_rank}\n"
f" Guild: {guild_name}\n"
f" Signature: {signature}\n"
f"________________________"
)
}
else:
# Case: General API failure
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ Failed to fetch player info!\n"
f" Please check the validity of the User ID\n"
f"________________________"
)
}
except Exception as e:
# Catch any other unexpected errors
return {
"status": "failed",
"message": (
f"[C][B][FF0000]________________________\n"
f" ❌ An unexpected error occurred: {str(e)}\n"
f"________________________"
)
}
def Encrypt(number):
number = int(number) # Convert the number to an integer
encoded_bytes = [] # Create a list to store the encoded bytes
while True: # Loop that continues until the number is fully encoded
byte = number & 0x7F # Extract the least 7 bits of the number
number >>= 7 # Shift the number to the right by 7 bits
if number:
byte |= 0x80 # Set the eighth bit to 1 if the number still contains additional bits
encoded_bytes.append(byte)
if not number:
break # Stop if no additional bits are left in the number
return bytes(encoded_bytes).hex()
def get_random_avatar():
avatar_list = [
'902050001', '902050002', '902050003', '902039016', '902050004',
'902047011', '902047010', '902049015', '902050006', '902049020'
]
random_avatar = random.choice(avatar_list)
return random_avatar
class FF_CLIENT(threading.Thread):
def __init__(self, id, password):
self.id = id
self.password = password
self.key = None
self.iv = None
self.get_tok()
def connect(self, tok, host, port, packet, key, iv):
global clients
clients = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = int(port)
clients.connect((host, port))
clients.send(bytes.fromhex(tok))
while True:
data = clients.recv(9999)
if data == b"":
logging.error("Connection closed by remote host")
break
def get_available_room(input_text):
try:
parsed_results = Parser().parse(input_text)
parsed_results_objects = parsed_results
parsed_results_dict = parse_results(parsed_results_objects)
json_data = json.dumps(parsed_results_dict)
return json_data
except Exception as e:
logging.error(f"error {e}")
return None
def parse_results(parsed_results):
result_dict = {}
for result in parsed_results:
field_data = {}
field_data["wire_type"] = result.wire_type
if result.wire_type == "varint":
field_data["data"] = result.data
if result.wire_type == "string":
field_data["data"] = result.data
if result.wire_type == "bytes":
field_data["data"] = result.data
elif result.wire_type == "length_delimited":
field_data["data"] = parse_results(result.data.results)
result_dict[result.field] = field_data
return result_dict
def dec_to_hex(ask):
ask_result = hex(ask)
final_result = str(ask_result)[2:]
if len(final_result) == 1:
final_result = "0" + final_result
return final_result
def encrypt_message(plaintext):
key = b'Yg&tc%DEuh6%Zc^8'
iv = b'6oyZDr22E3ychjM%'
cipher = AES.new(key, AES.MODE_CBC, iv)
padded_message = pad(plaintext, AES.block_size)
encrypted_message = cipher.encrypt(padded_message)
return binascii.hexlify(encrypted_message).decode('utf-8')
def encrypt_api(plain_text):
plain_text = bytes.fromhex(plain_text)
key = bytes([89, 103, 38, 116, 99, 37, 68, 69, 117, 104, 54, 37, 90, 99, 94, 56])
iv = bytes([54, 111, 121, 90, 68, 114, 50, 50, 69, 51, 121, 99, 104, 106, 77, 37])
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher_text = cipher.encrypt(pad(plain_text, AES.block_size))
return cipher_text.hex()
def extract_jwt_from_hex(hex):
byte_data = binascii.unhexlify(hex)
message = jwt_generator_pb2.Garena_420()
message.ParseFromString(byte_data)
json_output = MessageToJson(message)
token_data = json.loads(json_output)
return token_data
def format_timestamp(timestamp):
return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
# --- START: Modified for improved error handling ---
# This function is now the single point for safely restarting the script.
def restart_program():
logging.warning("Initiating bot restart...")
try:
p = psutil.Process(os.getpid())
# Close open file descriptors
for handler in p.open_files() + p.connections():
try:
os.close(handler.fd)
except Exception as e:
logging.error(f"Failed to close handler {handler.fd}: {e}")
except Exception as e:
logging.error(f"Error during pre-restart cleanup: {e}")
# Replace the current process with a new instance of the script
python = sys.executable
os.execl(python, python, *sys.argv)
# --- END: Modified for improved error handling ---
class FF_CLIENT(threading.Thread):
def __init__(self, id, password):
super().__init__()
self.id = id
self.password = password
self.key = None
self.iv = None
# --- START: Added for periodic restart ---
# Record the start time to track uptime.
self.start_time = time.time()
# --- END: Added for periodic restart ---
self.get_tok()
def parse_my_message(self, serialized_data):
try:
MajorLogRes = MajorLoginRes_pb2.MajorLoginRes()
MajorLogRes.ParseFromString(serialized_data)
key = MajorLogRes.ak
iv = MajorLogRes.aiv
if isinstance(key, bytes):
key = key.hex()
if isinstance(iv, bytes):
iv = iv.hex()
self.key = key
self.iv = iv
logging.info(f"Key: {self.key} | IV: {self.iv}")
return self.key, self.iv
except Exception as e:
logging.error(f"{e}")
return None, None
def nmnmmmmn(self, data):
key, iv = self.key, self.iv
try:
key = key if isinstance(key, bytes) else bytes.fromhex(key)
iv = iv if isinstance(iv, bytes) else bytes.fromhex(iv)
data = bytes.fromhex(data)
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher_text = cipher.encrypt(pad(data, AES.block_size))
return cipher_text.hex()
except Exception as e:
logging.error(f"Error in nmnmmmmn: {e}")
def send_emote(self, target_id, emote_id):
"""
Creates and prepares the packet for sending an emote to a target player.
"""
fields = {
1: 21,
2: {
1: 804266360, # Constant value from original code
2: 909000001, # Constant value from original code
5: {
1: int(target_id),
3: int(emote_id),
}
}
}
packet = create_protobuf_packet(fields).hex()
# The packet type '0515' is used for online/squad actions
header_lenth = len(encrypt_packet(packet, self.key, self.iv)) // 2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
else:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def spam_room(self, idroom, idplayer):
fields = {
1: 78,
2: {
1: int(idroom),
2: "iG:[C][B][FF0000] ꜱꫝᴇᴇᴅ",
4: 330,
5: 6000,
6: 201,
10: int(get_random_avatar()),
11: int(idplayer),
12: 1
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0E15000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "0E1500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "0E150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0E15000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def send_squad(self, idplayer):
fields = {
1: 33,
2: {
1: int(idplayer),
2: "PK",
3: 1,
4: 1,
7: 330,
8: 19459,
9: 100,
12: 1,
16: 1,
17: {
2: 94,
6: 11,
8: "1.109.5",
9: 3,
10: 2
},
18: 201,
23: {
2: 1,
3: 1
},
24: int(get_random_avatar()),
26: {},
28: {}
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def start_autooo(self):
fields = {
1: 9,
2: {
1: 12546809981
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def invite_skwad(self, idplayer):
fields = {
1: 2,
2: {
1: int(idplayer),
2: "PK",
4: 1
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def request_skwad(self, idplayer):
fields = {
1: 33,
2: {
1: int(idplayer),
2: "PK",
3: 1,
4: 1,
7: 330,
8: 19459,
9: 100,
12: 1,
16: 1,
17: {
2: 94,
6: 11,
8: "1.109.5",
9: 3,
10: 2
},
18: 201,
23: {
2: 1,
3: 1
},
24: int(get_random_avatar()),
26: {},
28: {}
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def skwad_maker(self):
fields = {
1: 1,
2: {
2: "\u0001",
3: 1,
4: 1,
5: "en",
9: 1,
11: 1,
13: 1,
14: {
2: 5756,
6: 11,
8: "1.109.5",
9: 3,
10: 2
},
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def changes(self, num):
fields = {
1: 17,
2: {
1: 12546809981,
2: 1,
3: int(num),
4: 62,
5: "\u001a",
8: 5,
13: 329
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4:
final_packet = "05150000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 5:
final_packet = "0515000" + header_lenth_final + self.nmnmmmmn(packet)
return bytes.fromhex(final_packet)
def leave_s(self):
fields = {
1: 7,
2: {
1: 12546809981
}
}
packet = create_protobuf_packet(fields)
packet = packet.hex()
header_lenth = len(encrypt_packet(packet, key, iv))//2
header_lenth_final = dec_to_hex(header_lenth)
if len(header_lenth_final) == 2:
final_packet = "0515000000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 3:
final_packet = "051500000" + header_lenth_final + self.nmnmmmmn(packet)
elif len(header_lenth_final) == 4: