forked from OlympicCode/vHackOSBot-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
1041 lines (892 loc) · 46.1 KB
/
utils.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
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
#!/usr/bin/python2.7
# -*- coding: utf-8
import base64
import hashlib
import time
import requests
from requests.exceptions import ReadTimeout
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import ssl
import logging
import json
import ruamel.yaml as yaml
from ruamel.yaml.scalarstring import SingleQuotedScalarString, DoubleQuotedScalarString
import sys
import os
import platform
import io
import logging
import coloredlogs
import datetime
import random
from coloredterm import colored
from time import gmtime, strftime
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
from terminaltables import AsciiTable, SingleTable
from sys import stdout
import re
try:
import fcntl
import termios
windows = False
except:
windows = True
import time
import contextlib
#logger = logging.getLogger(__name__)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
@contextlib.contextmanager
def raw_mode(file):
if windows is False:
old_attrs = termios.tcgetattr(file.fileno())
new_attrs = old_attrs[:]
new_attrs[3] = new_attrs[3] & ~(termios.ECHO | termios.ICANON)
try:
termios.tcsetattr(file.fileno(), termios.TCSADRAIN, new_attrs)
yield
finally:
termios.tcsetattr(file.fileno(), termios.TCSADRAIN, old_attrs)
def set_default(obj):
if isinstance(obj, set):
return list(obj)
raise TypeError
USER_AGENT = ['Dalvik/2.1.0 (Linux; U; Android 5.0.1; GT-I9508V Build/LRX22C)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.1; MX4 Build/LRX22C)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; D5322 Build/19.3.A.0.472)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; D816w Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; HTC D816v Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; HTC E9pw Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; HTC M8t Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; HTC One M8s Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; LG-F320L Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; Letv X500 Build/DBXCNOP5500912251S)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; Nexus 5 Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0.2; SM-N9005 Build/LRX22G)',
'Dalvik/2.1.0 (Linux; U; Android 5.0; ASUS_Z00ADB Build/LRX21V)',
'Dalvik/2.1.0 (Linux; U; Android 5.0; Nexus 5 Build/LPX13D)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1 Build/LYZ28N)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; 2014811 MIUI/6.1.26)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; A0001 Build/LMY47V)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; A0001 Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D5833 Build/23.4.A.1.232)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; GT-I9152 Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; LG-D802 Build/LMY48W)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; MI 2 Build/LMY48B)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; MI 2SC Build/LMY47V)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; MI 3 Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; Mi-4c MIUI/6.1.14)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; NX403A Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; ONE A2001 Build/LMY47V)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; R7Plusm Build/LMY47V)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; Redmi Note 2 Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-J3109 Build/LMY47X)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-N9200 Build/LMY47X)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; Sparkle V Build/LMY47V)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; Xperia Z2 Build/LMY48Y)',
'Dalvik/2.1.0 (Linux; U; Android 5.1.1; titan Build/LMY48W)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; HTC M9w Build/LMY47O)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; HTC One M9 Build/LMY47O)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; LG-H818 Build/LMY47D)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; MX5 Build/LMY47I)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; XT1060 Build/LPA23.12-39.7)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; XT1085 Build/LPE23.32-53)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; m1 note Build/LMY47D)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; m2 Build/LMY47D)',
'Dalvik/2.1.0 (Linux; U; Android 5.1; m2 note Build/LMY47D)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; 2014813 Build/MMB29U)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; A0001 Build/MMB29M)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; ASUS_Z00A Build/MMB29T)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; MI 4LTE Build/MMB29M)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Mi-4c Build/MMB29U)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Moto G 2014 Build/MMB29M)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Moto G 2014 LTE Build/MMB29T)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 4 Build/MMB29M)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 5 Build/MMB29K)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Sensation Build/MMB29U)',
'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Z1 Build/MMB29T)',
'Dalvik/2.1.0 (Linux; U; Android 6.0; MI 2 Build/MRA58K)',
'Dalvik/2.1.0 (Linux; U; Android 6.0; MI 2A Build/MRA58K)',
'Dalvik/2.1.0 (Linux; U; Android 6.0; Moto G 2014 Build/MDB08M)',
'Dalvik/2.1.0 (Linux; U; Android 6.0; XT1097 Build/MPE24.49-18)']
class Utils:
def __init__(self):
self.platform = platform.system()
self.request = None
self.secret = "aeffI"
self.url = "https://api.vhack.cc/mobile/36/"
self.Configuration = self.readConfiguration()
self.numberLoop = 0
self.account_info = None
self.login = "0"
try:
self.username = str(self.Configuration["username"]).lstrip()
self.password = str(self.Configuration["password"]).lstrip()
self.debug = self.Configuration["debug"]
self.show_info = self.Configuration["show_info"]
self.sync_mobile = self.Configuration["sync_mobile"]
self.attack_mode = self.Configuration["attack_mode"]
self.update = self.Configuration["update"]
self.msgremotelog = self.Configuration["msgLog"]
self.timesleep = self.Configuration["timeSleep"]
self.errorTime = self.Configuration["errorTime"]
self.version = self.Configuration["version"]
except KeyError as e:
print("Error Configuration {}".format(e))
sys.exit()
if self.username is None or self.password is None:
print("please Change Username/Password to config.yml")
sys.exit()
self.user_agent = self.generateUA(self.username + self.password)
self.all_data = [
['Console Log vHackOS - by vBlackOut [https://github.com/vBlackOut]']]
try:
if self.sync_mobile:
self.generateConfiguration(
uID=self.Configuration["uID"], accessToken=self.Configuration["accessToken"])
else:
self.generateConfiguration()
except TypeError:
self.generateConfiguration()
try:
self.accessToken = self.Configuration["accessToken"]
if self.accessToken == "":
self.accessToken = None
except:
self.accessToken = None
try:
self.uID = self.Configuration["uID"]
if self.uID == "":
self.uID = None
except KeyError:
self.uID = None
def check_version(self):
r = requests.get("https://raw.githubusercontent.com/OlympicCode/vHackOSBot-Python/master/config.yml")
for line in r.iter_lines():
if "version:" in str(line):
version = str(line).split(":")[1].replace("'", "")
break
if version.lstrip() != str(self.version.lstrip()):
print("Please update your bot on github.")
exit(1)
def readConfiguration(self):
# open configuration
with open("config.yml", 'r') as stream:
try:
Configuration = yaml.load(stream, Loader=yaml.RoundTripLoader)
except yaml.YAMLError as exc:
self.viewsPrint("ErrorConfiguration", "{} [{}]".format(
"Error in your config.yml please check in", exc))
sys.exit()
if Configuration:
return Configuration
def result(self, result, code):
self.viewsPrint(
"showResult", "Error: {} code: {}".format(result, code))
def viewsPrint(self, condition, Msg):
if condition == "ErrorRequest":
self.add_error()
if self.Configuration["debug"]:
print(self.printConsole("\033[0;103m\033[1;30mOutputBot: {} - {}\033[0m".format(
strftime("%Y-%m-%d %H:%M:%S", gmtime()), Msg)))
else:
return self.OutputTable("OutputBot: {} - {}".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), colored(condition, self.printConsole(Msg)).autocolored()), 2)
if condition in self.Configuration["show_info"] or "All" in self.Configuration["show_info"]:
if "!{}".format(condition) in self.Configuration["show_info"]:
pass
else:
if self.Configuration["debug"]:
print(self.printConsole("\033[0;103m\033[1;30mOutputBot: {} - {}\033[0m".format(
strftime("%Y-%m-%d %H:%M:%S", gmtime()), Msg)))
else:
return self.OutputTable("OutputBot: {} - {}".format(strftime("%Y-%m-%d %H:%M:%S", gmtime()), colored(condition, self.printConsole(Msg)).autocolored()), 2)
def exploit(self):
try:
return self.exploits
except:
return 0
def account(self):
time.sleep(random.uniform(0.2, 0.5))
try:
return self.requestStringNowait("update.php", uID=self.uID, accesstoken=self.accessToken)
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection")
self.generateConfiguration(errorTime=int(time.time()))
return None
def OutputTable(self, msg, select_tables):
if self.numberLoop < 6:
self.numberLoop = self.numberLoop + 1
else:
self.numberLoop = 0
if len(self.all_data) > 6:
del self.all_data[-6]
self.all_data.append([msg])
data = self.all_data
if select_tables == 1:
table = AsciiTable(data)
print(table.table)
elif select_tables == 2:
try:
self.account_info = self.requestString(
"update.php", accesstoken=self.Configuration["accessToken"])
self.exploits = int(self.account_info["exploits"])
progress = round(
int(self.account_info["exp"])) / round(int(self.account_info["expreq"]))
self.account_info["money"] = '{:0,}'.format(
int(self.account_info["money"]))
self.account_info["netcoins"] = '{:0,}'.format(
int(self.account_info["netcoins"]))
account_information = [["your account information", "update information"],
["{0}: {1}\n{2}: {3}\n{4}: {5}\n{6}: {7}\n{8}: {9}\n{10}: {11}".format("Your exploits ", self.exploits,
"Your spam ", self.account_info[
"spam"],
"Your network speed ", self.account_info[
"inet"],
"Your money ", self.account_info[
"money"],
"Your IP ", self.account_info[
"ipaddress"],
"Your netcoins ", self.account_info["netcoins"]),
"{}: {}\n{}: {}\n{}: {}\n{}: {}\n{}: {}, XP({}%)".format("Your SDK ", self.account_info["sdk"],
"Your Firewall ", self.account_info[
"fw"],
"Your Antivirus ", self.account_info[
"av"],
"Your BruteForce ", self.account_info[
"brute"],
"Your level ", self.account_info["level"], round(progress * 100, 1))]]
except (KeyError, requests.exceptions.ReadTimeout):
account_information = [
["your account information", "update information"], ["Error", "Error"]]
table1 = SingleTable(data)
table2 = SingleTable(account_information)
time.sleep(random.uniform(0.1, 0.3))
if self.platform == "Linux":
print("\033[H\033[J")
else:
os.system('cls')
req_version = (3, 0)
cur_version = sys.version_info
# for windows Try to print tables else pass python 2
try:
print(table1.table)
print(table2.table)
if windows is False:
sys.stdout.write("""\nCMD: [m] Get Miner info
[a] Get All applications
[q] Quit Program
Waiting for user input : """)
with raw_mode(sys.stdin):
try:
if cur_version <= req_version:
while True:
ch = sys.stdin.read(1)
if ch == "a":
p = Player(self)
getTask = self.requestString(
"tasks.php", accesstoken=self.Configuration["accessToken"])
sdk = p.getHelperApplication()[
"SDK"]["level"]
ipsp = p.getHelperApplication()[
"IPSP"]["level"]
bp = p.getHelperApplication()[
"BP"]["level"]
brute = p.getHelperApplication()[
"BRUTE"]["level"]
spam = p.getHelperApplication()[
"SPAM"]["level"]
fw = p.getHelperApplication()[
"FW"]["level"]
av = p.getHelperApplication()[
"AV"]["level"]
sys.stdout.write("\n \
SDK: {} \
IPSP: {}\n \
Bank Protect: {} \
BruteForce: {}\n \
SPAM: {} \
Firewall: {}\n \
Antivirus: {}".format(sdk, ipsp, bp, brute, spam, fw, av))
time.sleep(0.5)
if ch == "m":
self.minefinish = int(
self.account_info['minerLeft'])
sys.stdout.write(
"\nminerLeft {} in secondes".format(self.minefinish))
sys.stdout.write("\nwaiting until {} --- {}".format(self.tuntin(
self.minefinish), datetime.timedelta(seconds=(self.minefinish))))
time.sleep(1)
if ch == "q":
sys.stdout.write(
"\nok ok, good bye ;)\n")
sys.exit()
else:
while True:
ch = sys.stdin.read(1)
if ch == "a":
p = Player(self)
getTask = self.requestString(
"tasks.php", accesstoken=self.Configuration["accessToken"])
sdk = p.getHelperApplication()[
"SDK"]["level"]
ipsp = p.getHelperApplication()[
"IPSP"]["level"]
bp = p.getHelperApplication()[
"BP"]["level"]
brute = p.getHelperApplication()[
"BRUTE"]["level"]
spam = p.getHelperApplication()[
"SPAM"]["level"]
fw = p.getHelperApplication()[
"FW"]["level"]
av = p.getHelperApplication()[
"AV"]["level"]
sys.stdout.write("\n \
SDK: {} \
IPSP: {}\n \
Bank Protect: {} \
BruteForce: {}\n \
SPAM: {} \
Firewall: {}\n \
Antivirus: {}".format(sdk, ipsp, bp, brute, spam, fw, av))
time.sleep(0.5)
if str(ch) == "m":
self.minefinish = int(
self.account_info['minerLeft'])
sys.stdout.write(
"\nminerLeft {} in secondes".format(self.minefinish))
sys.stdout.write("\nwaiting until {} --- {}".format(self.tuntin(
self.minefinish), datetime.timedelta(seconds=(self.minefinish))))
time.sleep(1)
if ch == "q":
sys.stdout.write(
"\nok ok, good bye ;)\n")
sys.exit()
break
except (KeyboardInterrupt, EOFError):
pass
except IOError as e:
pass
def tuntin(self, secs):
st = (datetime.datetime.now() + datetime.timedelta(seconds=300))
return st.strftime('%H:%M:%S')
def getPlatform(self):
return self.platform
def printConsole(self, txt):
if self.platform == "Linux":
return txt
else:
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
return ansi_escape.sub('', txt)
def generateConfiguration(self, uID=False, accessToken=False, errorTime=False):
# append uID/accessToken and other param in new configuration file.
self.Configuration['username'] = self.username
self.Configuration['password'] = self.password
self.Configuration['debug'] = self.debug
self.Configuration['show_info'] = self.show_info
self.Configuration['sync_mobile'] = self.sync_mobile
self.Configuration['attack_mode'] = self.attack_mode
self.Configuration['update'] = self.update
self.Configuration["msgLog"] = self.msgremotelog
self.Configuration["timeSleep"] = self.timesleep
self.Configuration["version"] = self.version
if errorTime is not False:
self.Configuration["errorTime"] = errorTime
else:
self.Configuration["errorTime"] = None
# delete old file
# os.remove("config.yml")
try:
self.Configuration['uID'] = uID
except KeyError:
self.Configuration['uID'] = self.uID
try:
self.Configuration['accessToken'] = accessToken
except KeyError:
self.Configuration['accessToken'] = self.accessToken
if not self.Configuration['accessToken'] and not self.Configuration['uID']:
self.request = requests.Session()
self.request.headers.update({'User-agent': self.user_agent})
url = 'login.php'
url_login = self.Login(url, self.username, self.password)
try:
result = self.request.get(url_login, timeout=5, verify=False)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection '{}'".format(url))
sys.exit()
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
sys.exit()
except requests.exceptions.ConnectionError:
self.viewsPrint(
"ErrorRequest", "Request Timeout... Connection Error '{}'".format(url))
sys.exit()
result.encoding = 'UTF-8'
parseJson = result.json()
check_return_server = self.CheckServerError(parseJson)
if check_return_server:
print("Server Error: [{}] {}".format(
check_return_server[0], check_return_server[1]))
return False
self.accessToken = str(parseJson["accesstoken"])
self.uID = int(parseJson["uid"].encode("UTF-8"))
self.Configuration.yaml_add_eol_comment(
"# < Your Username Account", 'username', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Your Password Account\n\n", 'password', column=5)
self.Configuration.yaml_add_eol_comment(
"# < debug mode\n\n", 'debug', column=5)
self.Configuration.yaml_add_eol_comment(
"# < show the return bot print information\n\n", 'show_info', column=5)
self.Configuration.yaml_add_eol_comment(
"# < If your are uID and accessToken and your phone bot use configuration for login please replace your uid and accesstoken sync to phone. (Recommended OFF)\n\n", 'sync_mobile', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Automatically added uID for your account don't change /!\\", 'uID', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Automatically added accessToken for your account don't change /!\\", 'accessToken', column=5)
try:
# for python 3
with io.open('config.yml', 'w+') as outfile:
yaml.dump(self.Configuration, stream=outfile, default_flow_style=False,
Dumper=yaml.RoundTripDumper, indent=4, block_seq_indent=1)
except:
# for python 2
with io.open('config.yml', 'wb') as outfile:
yaml.dump(self.Configuration, stream=outfile, default_flow_style=False,
Dumper=yaml.RoundTripDumper, indent=4, block_seq_indent=1)
self.request = None
else:
self.Configuration.yaml_add_eol_comment(
"# < Your Username Account", 'username', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Tour Password Account\n\n", 'password', column=5)
self.Configuration.yaml_add_eol_comment(
"# < debug mode dev online\n\n", 'debug', column=5)
self.Configuration.yaml_add_eol_comment(
"# < show the return bot print information\n\n", 'show_info', column=5)
self.Configuration.yaml_add_eol_comment(
"# < If your are uID and accessToken and your phone bot use configuration for login please replace your uid and accesstoken sync to phone. (Recommended OFF)\n\n", 'sync_mobile', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Automatically added uID for your account don't change /!\\", 'uID', column=5)
self.Configuration.yaml_add_eol_comment(
"# < Automatically added accessToken for your account don't change /!\\", 'accessToken', column=5)
try:
# for python 3
with io.open('config.yml', 'w+') as outfile:
yaml.dump(self.Configuration, stream=outfile, default_flow_style=False,
Dumper=yaml.RoundTripDumper, indent=4, block_seq_indent=1)
except:
# for python 2
with io.open('config.yml', 'wb') as outfile:
yaml.dump(self.Configuration, stream=outfile, default_flow_style=False,
Dumper=yaml.RoundTripDumper, indent=4, block_seq_indent=1)
def add_error(self):
self.remove_error()
with open("config.yml", "a") as file:
file.write("errorTime: {}".format(int(time.time()) + 600))
def remove_error(self):
with open('config.yml', 'r+') as f:
f.seek(0, os.SEEK_END)
while f.tell() and f.read(1) != '\n':
f.seek(-2, os.SEEK_CUR)
f.truncate()
def generateUA(self, identifier):
pick = int(self.md5hash(identifier), 16)
user_agents = tuple(USER_AGENT)
return user_agents[pick % len(user_agents)]
def getTime(self):
return int(round(time.time()))
def md5hash(self, txt):
m = hashlib.md5()
m.update(txt.encode('utf-8'))
return m.hexdigest()
def generateUser(self, bArr):
b64 = base64.urlsafe_b64encode(bArr.encode('UTF-8')).decode('ascii')
return b64.replace("=", "")
def Login(self, php, username, password):
passmd5 = self.md5hash(password)
jsonString = {'username': username, 'password': passmd5}
jsonString = json.dumps(jsonString, separators=(',', ':'))
str8 = self.md5hash("{}{}{}".format(jsonString, jsonString,
self.md5hash(jsonString)))
return "{}{}?user={}&pass={}".format(self.url, php,
self.generateUser(jsonString), str8)
def generateURL(self, uid, php, **kwargs):
jsonString = kwargs
jsonString.update(
{'uid': str(self.uID), 'accesstoken': str(self.accessToken)})
jsonString.pop("debug", None)
jsonString = json.dumps(jsonString, default=set_default)
str8 = self.md5hash("{}{}{}".format(jsonString, jsonString,
self.md5hash(jsonString)))
return "{}{}?user={}&pass={}".format(self.url, php, self.generateUser(jsonString), str8)
def CheckServerError(self, code_return):
try:
code_return = code_return["result"]
except (TypeError, IndexError):
code_return = "0"
t = None
if code_return == u"5":
t = (5, "Check your Internet Connection.")
elif code_return == u"2":
t = (8, "User/Password wrong!")
elif code_return == u"10":
t = (10, "API is updated.")
elif code_return == u"15":
t = (10, "You are banned sorry :(")
elif code_return == u"99":
t = (99, "Server is down for Maintenance, please be patient.")
return t
def requestString(self, php, **kwargs):
# print("Request: {}, {}".format(php, self.uID))
self.user_agent = self.generateUA(
"test{}test".format(random.randint(1, 9999)))
try:
if kwargs["debug"] is True:
time.sleep(self.timesleep)
http_client.HTTPConnection.debuglevel = 0
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logger = logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
coloredlogs.install(level='DEBUG')
coloredlogs.install(level='DEBUG', logger=requests_log)
except KeyError:
kwargs["debug"] = self.debug
if kwargs["debug"] is True:
time.sleep(self.timesleep)
http_client.HTTPConnection.debuglevel = 0
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logger = logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
coloredlogs.install(level='DEBUG')
coloredlogs.install(level='DEBUG', logger=requests_log)
time.sleep(random.uniform(0.5, 1))
i = 0
while True:
if i > 10:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
sys.exit()
try:
self.uID
self.accessToken
self.request
self.sync_mobile
except AttributeError:
print("\nError - Your account blocked. please wait")
try:
error_time = self.errorTime - int(time.time())
except:
error_time = 600
if error_time > 0:
for remaining in range(error_time, 0, -1):
sys.stdout.write("\r")
sys.stdout.write(
"{:2d} seconds remaining. number retry ({})".format(remaining, i))
sys.stdout.flush()
time.sleep(1)
self.add_error()
self.remove_error()
i = i + 1
python = sys.executable
os.execl(python, python, * sys.argv)
return False
if self.uID is None or self.accessToken is None or self.request is None and self.sync_mobile is False:
# connect login.
self.request = requests.Session()
self.request.headers.update({'User-agent': self.user_agent})
url_login = self.Login(
'login.php', self.username, self.password)
try:
time.sleep(self.timesleep)
result = self.request.get(
url_login, timeout=5, verify=False)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint("ErrorRequest", "Request Timeout... Connection Error '{}' with code: [{}]".format(
'login.php', url_login.status_code))
result.encoding = 'UTF-8'
parseJson = result.json()
check_return_server = self.CheckServerError(parseJson)
if check_return_server:
print("Server Error: [{}] {}".format(
check_return_server[0], check_return_server[1]))
return False
self.accessToken = str(parseJson["accesstoken"])
self.uID = int(parseJson["uid"].encode("UTF-8"))
global login
self.login = "1"
self.generateConfiguration(self.uID, self.accessToken)
# Create First request.
try:
result = self.request.get(self.generateURL(
self.uID, php, **kwargs), timeout=5)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint("ErrorRequest", "Request Timeout... Connection Error '{}' with code: [{}]".format(
php, url_login.status_code))
if kwargs["debug"] is True:
logging.info(result.json())
elif self.uID is not None or self.accessToken is not None:
#request = requests.Session()
if not self.request:
self.request = requests.Session()
self.request.headers.update({'User-agent': self.user_agent})
if self.sync_mobile is True:
if self.login is "0":
self.login = "1"
self.request.get(self.generateURL(
self.uID, 'update.php', accesstoken=self.accessToken, lang="fr", lastread="0"), timeout=3)
# return just request don't login before.
try:
result = self.request.get(self.generateURL(
self.uID, php, **kwargs), timeout=5)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"BadRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint(
"BadRequest", "Request Timeout... Connection Error '{}'".format(php))
result.encoding = 'UTF-8'
try:
parseJson = result.json()
result = True
except ValueError:
self.viewsPrint(
"ErrorJson", "Closing bot upon bad request...")
time.sleep(5)
try:
self.accessToken = str(parseJson["accesstoken"])
except (KeyError, UnboundLocalError):
pass
i = i + 1
if kwargs["debug"] is True:
logging.info(parseJson)
if result:
break
if parseJson["result"] is not None or len(parseJson) > 1:
return parseJson
else:
self.viewsPrint(
"BadRequest", "/!\ Block Script your credential as changed")
exit(1)
def requestStringNowait(self, php, **kwargs):
# print("Request: {}, {}".format(php, self.uID))
self.user_agent = self.generateUA("testtest")
try:
if kwargs["debug"] is True:
http_client.HTTPConnection.debuglevel = 0
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logger = logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
coloredlogs.install(level='DEBUG')
coloredlogs.install(level='DEBUG', logger=requests_log)
except KeyError:
kwargs["debug"] = self.debug
if kwargs["debug"] is True:
http_client.HTTPConnection.debuglevel = 0
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logger = logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
coloredlogs.install(level='DEBUG')
coloredlogs.install(level='DEBUG', logger=requests_log)
i = 0
while True:
if i > 10:
break
if self.uID is None or self.accessToken is None or self.request is None and self.sync_mobile is False:
# connect login.
self.request = requests.Session()
self.request.headers.update({'User-agent': self.user_agent})
url_login = self.Login(
'login.php', self.username, self.password)
try:
result = self.request.get(
url_login, timeout=3, verify=False)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint("ErrorRequest", "Request Timeout... Connection Error '{}' with code: [{}]".format(
'login.php', url_login.status_code))
result.encoding = 'UTF-8'
parseJson = result.json()
check_return_server = self.CheckServerError(parseJson)
if check_return_server:
print("Server Error: [{}] {}".format(
check_return_server[0], check_return_server[1]))
return False
self.accessToken = str(parseJson["accesstoken"])
self.uID = int(parseJson["uid"].encode("UTF-8"))
global login
self.login = "1"
self.generateConfiguration(self.uID, self.accessToken)
# Create First request.
try:
result = self.request.get(self.generateURL(
self.uID, php, **kwargs), timeout=5)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint("ErrorRequest", "Request Timeout... Connection Error '{}' with code: [{}]".format(
php, url_login.status_code))
if kwargs["debug"] is True:
logging.info(result.json())
elif self.uID is not None or self.accessToken is not None:
#request = requests.Session()
if not self.request:
self.request = requests.Session()
self.request.headers.update({'User-agent': self.user_agent})
if self.sync_mobile is True:
if self.login is "0":
self.login = "1"
self.request.get(self.generateURL(
self.uID, 'update.php', accesstoken=self.accessToken, lang="fr", lastread="0"), timeout=3)
# return just request don't login before.
try:
result = self.request.get(self.generateURL(
self.uID, php, **kwargs), timeout=5)
except requests.exceptions.ConnectTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ReadTimeout:
self.viewsPrint(
"ErrorRequest", "Request Timeout... TimeOut connection {}".format(php))
except requests.exceptions.ConnectionError:
self.viewsPrint("ErrorRequest", "Request Timeout... Connection Error '{}' with code: [{}]".format(
php, url_login.status_code))
result.encoding = 'UTF-8'
try:
parseJson = result.json()
except:
time.sleep(random.uniform(0.5, 1.5))
result = self.request.get(self.generateURL(
self.uID, php, **kwargs), timeout=5)
result.encoding = 'UTF-8'
parseJson = result.json()
try:
self.accessToken = str(parseJson["accesstoken"])
except (KeyError, UnboundLocalError):
pass
i = i + 1
if kwargs["debug"] is True:
logging.info(result.json())
return parseJson
class Player():
def __init__(self, ut):
self.ut = ut
self.Configuration = self.ut.readConfiguration()
self.getStore = self.ut.requestString("store.php",
accesstoken=self.Configuration["accessToken"], lang="en")
def getApplication(self):
Dict_request = self.getStore["apps"]
ApplicationCount = []
for ApplicationUp in enumerate(Dict_request):
Application = {}
try:
Application["baseprice"] = ApplicationUp[1]["baseprice"]
Application["level"] = ApplicationUp[1]["level"]
Application["price"] = ApplicationUp[1]["price"]
Application["factor"] = ApplicationUp[1]["factor"]
Application["maxlvl"] = ApplicationUp[1]["maxlvl"]
Application["running"] = ApplicationUp[1]["running"]
Application["appid"] = ApplicationUp[1]["appid"]
Application["require"] = ApplicationUp[1]["require"]
except KeyError as e:
Application["baseprice"] = None
Application["level"] = ApplicationUp[1]["level"]
Application["price"] = ApplicationUp[1]["price"]
Application["factor"] = None
Application["maxlvl"] = ApplicationUp[1]["maxlvl"]
Application["running"] = None
Application["appid"] = ApplicationUp[1]["appid"]
Application["require"] = ApplicationUp[1]["require"]
ApplicationCount.append(Application)
return ApplicationCount
def getHelperApplication(self):
Application = self.getApplication()
FinalApplication = {}
for allApplication in Application:
# antivirus
if int(allApplication["appid"]) == 1:
FinalApplication["AV"] = allApplication
# firewall
if int(allApplication["appid"]) == 2:
FinalApplication["FW"] = allApplication
# spam
if int(allApplication["appid"]) == 3:
FinalApplication["SPAM"] = allApplication
# brute force
if int(allApplication["appid"]) == 4:
FinalApplication["BRUTE"] = allApplication
# banque protecte
if int(allApplication["appid"]) == 5:
FinalApplication["BP"] = allApplication