-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathmain.py
1240 lines (1044 loc) · 52.8 KB
/
main.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
# Made by:
# Original code, updates, and owner: @jeldo
# Proxy support, fork, better UI, and developer: ! max#7948
VERSION = "3.0.1"
import os; os.system("cls" if os.name == "nt" else "clear")
try:
print(f"\x1b[38;5;2mLoading modules...")
import discord
from discord.ext import commands
import aiohttp
import asyncio
import traceback
import ctypes
import json
import time
import uuid
import copy
import datetime
from itertools import cycle
from pick import pick
import rgbprint
import math
import logging
import logging.config
import hashlib
import importlib
try: import rapidjson as json
except ImportError: import json
try: import quart
except ImportError: pass
import subprocess
import re
import random
print(f"\x1b[38;5;2mModules loaded!")
# Import the base extension
# from extensions.base import *
except ModuleNotFoundError:
import os
try:
from pick import pick
install = pick(["Yes", "No"], "Uninstalled modules found, do you want to update?", indicator=">>")[1] == 0
except ModuleNotFoundError:
install = input("Uninstalled modules found, do you want to install them? Y/N\n>> ").lower() == "y"
if install:
print("Required modules not installed, installing now...")
os.system("python -m pip install --upgrade pip")
os.system("pip install aiohttp");os.system("python -m pip install aiohttp");os.system("py -m pip install aiohttp")
os.system("pip install pick");os.system("python -m pip install pick");os.system("py -m pip install pick")
os.system("pip install rgbprint");os.system("python -m pip install rgbprint");os.system("py -m pip install rgbprint")
os.system("pip install discord.py");os.system("python -m pip install discord.py");os.system("py -m pip install discord.py")
os.system("pip install python-rapidjson");os.system("python -m pip install python-rapidjson");os.system("py -m pip install python-rapidjson")
os.system("pip install quart==0.17.0");os.system("python -m pip install quart==0.17.0");os.system("py -m pip install quart==0.17.0")
print("Successfully installed required modules.")
else:
print("Aborting installing modules.")
os.system("pause" if os.name == "nt" else "read -p \"Press any key to continue . . .\"")
exit(1)
os.system("cls" if os.name == "nt" else "clear")
if os.name == "nt":
try:
ctypes.windll.kernel32.SetConsoleTitleW("J3ldo Sniper")
except:
pass
if not os.path.exists("./logs"): os.mkdir("./logs")
# logging.config.dictConfig({'version': 1,'disable_existing_loggers': True})
logging.basicConfig(filename=f"./logs/logs {str(datetime.datetime.now())[:-10].replace(':', '')}.txt",
level=logging.INFO, format="%(asctime)s:%(levelname)s-%(module)s %(message)s")
logging.info("Started")
# Load the config
with open('config.json', "r") as f:
conf = json.load(f)
# Global variables
recent_logs = []
all_logs = []
runtime_start = time.time()
class Visual:
@staticmethod
def betterPrint(content, print_log=False, log=True, log_level="info", include_time=True):
now = f"[{datetime.datetime.now().strftime('%H:%M:%S.%f')}] " if include_time else ""
if log:
all_logs.append(Visual.removeColour(f"{now}{content}"))
exec('logging.' + log_level + '(f"{content}")')
if conf["better print"] and print_log:
recent_logs.append(f"[COLOR_LIGHT_BLUE]{now}{content}")
return
if Visual.__parsegradient(content) == 0:
print(Visual.textToColour(f"[COLOR_LIGHT_BLUE]{now}{content}"))
@staticmethod
def add_log(content, include_time=True):
now = f"[{datetime.datetime.now().strftime('%H:%M:%S.%f')}] " if include_time else ""
all_logs.append(Visual.removeColour(f"{now}{content}"))
@staticmethod
def __parsehex(text):
txt = text.split("[HEX_")
if len(txt) == 1:
return txt[0]
text = txt[0]
for i in txt[1:]:
i = i.split("]")
text += f"{rgbprint.Color(i[0])}{''.join(i[1:])}"
return text
@staticmethod
def __parsergb(text):
txt = text.split("[RGB_")
if len(txt) == 1:
return txt[0]
text = txt[0]
for i in txt[1:]:
i = i.split("]")
r, g, b = i[0].split(",")
text += f"{rgbprint.Color((int(r), int(g), int(b)))}{''.join(i[1:])}"
return text
@staticmethod
def __parsegradient(text): # Meest leesbaar stukje programma in de wereld
if "[GRADIENT" not in text:
return 0
try:
txt = text.split("[GRADIENT_")
print(txt[0], end="")
for i in txt[1:]:
start, end = i.split("]")[0].split("_")
toprint, other = i.split("[END]")
toprint = "".join(toprint.split("]")[1:])
rgbprint.gradient_print(toprint, start_color=start, end_color=end, end="")
print(other, end="")
except IndexError:
Visual.betterPrint("[COLOR_RED]Syntax error whilst decoding gradients.")
Visual.pause()
exit(1)
return 1
@staticmethod
def removeColour(text: str):
if "COLOR" in text:
for key in theme_info["colours"]:
text = text.replace(key, "")
return text
@staticmethod
def textToColour(text: str):
if "COLOR" in text:
for key in theme_info["colours"]:
text = text.replace(key, f"\x1b[38;5;{theme_info['colours'][key]}m")
try:
if "[HEX" in text:
text = Visual.__parsehex(text)
except IndexError:
Visual.betterPrint("[COLOR_RED]Syntax error whilst decoding hex.")
Visual.pause()
exit(1)
try:
if "[RGB" in text:
text = Visual.__parsergb(text)
except IndexError:
Visual.betterPrint("[COLOR_RED]Syntax error whilst decoding RGB.")
Visual.pause()
exit(1)
return text
@staticmethod
def textToVar(sniper, text: str):
if type(sniper) != UGCSniper:
Visual.betterPrint("[COLOR_RED] WARNING, NO VALID SNIPER PASSED TO textToVar")
Visual.pause()
exit(1)
custom_vars = {
"[username]": sniper.userinfo["name"],
"[displayName]": sniper.userinfo["displayName"],
"[userId]": sniper.userinfo["id"],
"[proxiesEnabled]": False,
"[proxyAmount]": len(sniper.proxies_raw),
"[currentProxy]": sniper.proxy,
"[changedProxies]": sniper.proxies_switched,
"[ratelimits]": sniper.ratelimits,
"[time]": sniper._time,
"[limitedsAmount]": len(sniper.limiteds),
"[limiteds]": ", ".join(sniper.limiteds),
"[speed]": sniper.speed,
"[status]": sniper.stats,
"[priceChecks]": sniper.checks_made,
"[bought]": sniper.bought,
"[boughtpaid]": sniper.boughtpaid,
"[ip]": sniper.ip,
"[tooltip]": sniper.tooltip,
"[memory_usage]": sniper.ram, # Disabled when needed for preformance purposes
"[cpu_usage]": "N/A",
"[network_strength]": "N/A",
"[network_receive]": "N/A",
"[netowrk_transmit]": "N/A",
"[x-csrf]": sniper.cookies[0][1],
"[cooldown]": sniper.cooldown,
"[errors]": sniper.errors,
"[version]": VERSION,
"[mode]": sniper.mode,
"[logs]": "".join(themeConfig.get('log seperator', "[LOG]\n").replace("[LOG]", log) for log in recent_logs),
"[runtime]": round(time.time()-runtime_start, 2)
}
if "[network_strength]" in text or "[network_receive]" in text or "[netowrk_transmit]" in text:
interface_info = subprocess.getoutput("netsh wlan show interfaces")
custom_vars["[network_strength]"] = interface_info.split("Signal : ")[1].split("%")[0]
custom_vars["[network_transmit]"] = interface_info.split("Transmit rate (Mbps) :")[1].splitlines()[0]
custom_vars["[network_receive]"] = interface_info.split("Receive rate (Mbps) : ")[1].splitlines()[0]
for key in custom_vars:
text = text.replace(key, str(custom_vars[key]))
return text
@staticmethod
def pause():
os.system("pause" if os.name == "nt" else "read -p \"Press any key to continue . . .\"")
@staticmethod
def clear():
os.system("cls" if os.name == "nt" else "clear")
class Other:
@staticmethod
def calculate_cooldown(reqs_per_min, mode):
try:
cooldown = 60 / reqs_per_min
except ZeroDivisionError:
Visual.betterPrint("[COLOR_RED]No limiteds added, please add a limited for the sniper to work.")
Visual.pause()
exit(1)
cooldown = conf.get(f"custom {mode} cooldown", -1) if conf.get(f"custom {mode} cooldown", -1) >= 0 else cooldown
return cooldown
@staticmethod
async def handle_ratelimit(sniper, log, custom_cooldown=-1, text="", no_switch=False):
cooldown = conf['proxy ratelimit cooldown'] if sniper.proxiesOn else conf['ratelimit cooldown']
if custom_cooldown >= 0: cooldown = custom_cooldown
if text == "": text = f"[COLOR_RED]Ratelimit continuing in {cooldown} seconds."
Visual.betterPrint(f"{text} - {log}", True)
# Run ratelimit event tasks
for task in ratelimit_tasks: task()
await asyncio.sleep(cooldown)
if sniper.proxiesOn and not no_switch:
sniper.proxy = next(sniper.proxy_pool)
sniper.proxies_switched += 1
return False, [], [], True
sniper.ratelimits += 1
return False, [], [], True
# Load theme
with open("themes/required/required.json", "r") as f:
theme_info = json.load(f)
themeVersion = "1.4.0"
themeLocation = "./themes/" + conf["current theme"]
with open(themeLocation + "/config.json", "r") as f:
themeConfig = json.load(f)
if themeConfig["version"] != themeVersion:
Visual.betterPrint(f"[COLOR_RED]DEPRECTATION WARNING - Version of the theme is deperecated, theme may not work.\n"
f"Do you still want to continue?[COLOR_WHITE]")
if pick(["Yes", "No"], "", indicator=themeConfig.get("indicator", ">>"))[1] == 1:
exit(1)
if themeConfig["type"] not in theme_info["types"]:
Visual.betterPrint(f"[COLOR_RED]Theme has invalid type, types can only be {' or'.join(theme_info['types'])[:-3]}")
if themeConfig["type"] == "py":
with open("themes/required/whitelisted.hash", "r") as f:
with open(f"{themeLocation}/{themeConfig['script']}", "rb") as con:
stop = hashlib.sha256(con.read()).hexdigest() in f.read().split(";")
if not conf.get("allowPyThemes", False) and not stop:
print(Visual.textToColour("[COLOR_LIGHT_BLUE]"), end="\n")
idx = pick(["Yes", "Yes, and dont warn me again.", "Yes, and whitelist this theme", "No",
"No, and show me more information about this program"],
f"WARNING The theme you are trying to use is using scripts to run, do you want to continue?",
indicator=themeConfig.get("indicator", ">>"))[1]
if idx == 3:
Visual.pause()
exit(1)
if idx == 1:
conf["allowPyThemes"] = True
with open('config.json', "w") as f:
json.dump(conf, f, indent=4)
if idx == 2:
with open("themes/required/whitelisted.hash", "a") as f:
with open(f"{themeLocation}/{themeConfig['script']}", "r") as con:
f.write(hashlib.sha256(con.read().encode()).hexdigest() + ";")
if idx == 4:
with open(themeLocation[2:] + "/" + themeConfig["script"], "rb") as f:
file_content = f.read()
# TO-DO
# Get imports
# Get lines of code
# Get other functions
imports = ""
for i in file_content.split("import "):
imports += f"\t{i.splitlines()[0].replace('from ', '')}\n"
print(Visual.textToColour(f"[COLOR_LIGHT_BLUE] All imports: \n{imports}\n"
f"[COLOR_GREEN]Lines of code: {len(file_content.splitlines())}\n\n"
f"[COLOR_WHITE]"))
Visual.pause()
exit(1)
themeFile = importlib.import_module(themeLocation.replace("/", ".")[2:] + "." + themeConfig["script"][:-3])
if os.name == "nt":
try:
ctypes.windll.kernel32.SetConsoleTitleW(themeConfig["title"])
except:
pass
if os.name == "nt" and themeConfig.get("resize", {"width": -1, "height": -1}) != {"width": -1, "height": -1}:
os.system(f"mode con: cols={themeConfig['resize']['width']} lines={themeConfig['resize']['height']}")
# Load themes info
with open(f"{themeLocation}/{themeConfig['logo']}", "r", encoding="unicode_escape") as f: logo = Visual.textToColour(
f.read())
with open(f"{themeLocation}/{themeConfig['printText']}", "r",
encoding="unicode_escape") as f: printText = Visual.textToColour(
f.read())
update_freq = -1
frames = []
current_frame = "N/A"
if themeConfig.get("animated", False):
for i in range(1, 60): # Max frames
try:
with open(f"{themeLocation}/{themeConfig['frames']}/frame_{i}.txt") as f:
frames.append(f.read())
except FileNotFoundError:
break
if len(frames) > 0:
update_freq = 1 / themeConfig['fps']
frame_pool = cycle(frames)
current_frame = next(frame_pool)
# Load extensions
# Initialize the start, iteration, and end tasks. These dont want to be overwritten
start_tasks = []
iteration_tasks = []
end_tasks = []
error_tasks = []
buy_tasks = []
start_buy_tasks = []
ratelimit_tasks = []
for module in os.listdir("./extensions/active"):
contents = ""
for script in os.listdir(f"./extensions/active/{module}"):
if os.path.isdir(f"./extensions/active/{module}/{script}"): continue
with open(f"./extensions/active/{module}/{script}", "r") as f:
contents += f.read()
module_hash = hashlib.sha256(contents.encode()).hexdigest()
with open("./extensions/required/trustedExtensions.hash", "r") as f:
trustedhashes = f.read().split(";")
if module_hash not in trustedhashes and not conf.get("trustExtensions", False):
print(Visual.textToColour("[COLOR_RED]"), end="")
idx = pick(["Yes", "Yes, and dont warn me again.", "Yes, and whitelist this extension", "No"],
f"WARNING - Unknown extension found. Do you want to continue? - Extension: {module}",
indicator=conf.get("indicator", ">>"))[1]
if idx == 1:
conf["trustExtensions"] = True
with open("config.json", "w") as f:
json.dump(conf, f, indent=4)
if idx == 2:
with open("./extensions/required/trustedExtensions.hash", "a") as f:
f.write(module_hash + ";")
if idx == 3:
Visual.pause()
exit(1)
module = importlib.import_module(f"extensions.active.{module}")
if hasattr(module, '__all__'):
all_names = module.__all__
else:
all_names = [name for name in dir(module) if not name.startswith('_')]
# Get the start, iteration, and end functions. These dont need to be overwritten for multiple extensions
if "start" in dir(module): start_tasks.append(module.start)
if "iteration" in dir(module): iteration_tasks.append(module.iteration)
if "end" in dir(module): end_tasks.append(module.end)
if "on_load" in dir(module): module.on_load()
if "error" in dir(module): error_tasks.append(module.error)
if "buy" in dir(module): buy_tasks.append(module.buy)
if "start_buy" in dir(module): start_buy_tasks.append(module.start_buy)
if "ratelimit" in dir(module): ratelimit_tasks.append(module.ratelimit)
globals().update({name: getattr(module, name) for name in all_names})
print(Visual.textToColour(f"[COLOR_LIGHT_BLUE]UGC-Sniper made by: @jeldo (J3ldo) and ! max#7948 (maxhithere)\n"
f"[COLOR_LIGHT_BLUE]Discord server: https://discord.com/invite/3Uvcf8d9aY)"))
time.sleep(1)
class UGCSniper: # OMG guys he stole this from xolo!!
def __init__(self):
Visual.clear()
if os.name == "nt": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
# Init data
self.errors = 0
self._time = 0
self.speed = 0
self.bought = 0
self.boughtpaid = 0
self.checks_made = 0
self.ratelimits = 0
self.proxies_switched = 0
self.stats = "N/A"
self.proxy = "N/A"
self.version = VERSION
self.ram = 0
self.finder_added = 0
self.finder_blacklist = []
self.limiteds = []
self.limitednames = {_id: "N/A" for _id in self.limiteds}
self.ip = ""
self.tooltips = [
"You can set custom cooldowns in the config.",
"Starting the sniper can be made fully automatic using the right config.",
"There are a lot of handy tools in the tools folder like an extension selector, and more.",
"Discord .gg/J3ldo to chat with the community",
"You can put in limiteds the following ways: id, id or id[enter/newline]id",
"You can put in multiple cookies so you dont use your main cookie for checking.",
"Links are supported in limiteds.txt"
]+themeConfig.get("custom tooltips", [])
self.tooltip = random.choice(self.tooltips)
self.mode = ""
self.mode_time = False
self.minutes = int(conf["time wait minutes"])
self.unix = math.floor(conf["time wait unix"])
self.cooldown = 0
self.userinfo = {}
self.update_token = False
asyncio.run(self.auto_update())
self.get_info()
self.load_limiteds()
self.limitednames = {_id: "N/A" for _id in self.limiteds}
self.load_proxies()
self.get_type()
def get_info(self):
self.cookies = [[i, ""] for i in conf["cookie"]]
if type(conf["cookie"]) != str: return
with open(conf["cookie"], "r") as f:
self.cookies = [[i, "", 0] for i in f.read().replace(";", "").splitlines()]
def load_limiteds(self):
self.limiteds = conf["limiteds"]
if type(self.limiteds) != str:
return
with open(conf["limiteds"], "r") as f:
contents = f.read()
if "/catalog/" in contents:
self.limiteds = [re.findall(r"/catalog/[0-9]+", contents)[0].split("/")[-1]]
else:
self.limiteds = contents.replace(" ", "").splitlines()
if "," in contents:
self.limiteds = contents.replace(" ", "").split(",")
def proxy_cycle(self):
idx = 0
while 1:
yield self.proxies_raw[idx]
idx += 1
if idx > len(self.proxies_raw)-1:
idx = 0
async def check_proxies(self):
async def is_working(session, proxy):
'''
:param session: The aiohttp session
:param proxy: The proxy url
:return: bool working
'''
try:
working = await session.get("http://users.roblox.com/v1/users/authenticated", ssl=False, proxy=proxy[0],
timeout=conf.get("timeout", 3))
if working.status == 401:
resp = await session.get(f"http://ip-api.com/json/", ssl=False, proxy=proxy[0],
timeout=conf.get("timeout", 3))
data = json.loads(await resp.text())
spacing = " " * (50 - len(f"{data['country']} ({data['regionName']})"))
print(Visual.textToColour(
f"[COLOR_GREEN][+] Working proxy in [COLOR_WHITE]{data['country']} ({data['regionName']})[COLOR_GREEN] {spacing}Proxy: {proxy[0]}"))
self.proxies_raw.append(proxy)
return True
except aiohttp.client_exceptions.InvalidURL:
new_prox = proxy[0].split(":")
proxy[0] = ""
for idx, item in enumerate(new_prox):
if idx == len(new_prox) - 2:
proxy[0] += "@" + item
elif idx == 0:
proxy[0] += item
else:
proxy[0] += ":" + item
if proxy[0] == "" or proxy[0] == ":": return False
return await is_working(session, proxy)
except:
return False
return False
chunks = [self.proxies_raw[i:i + 500] for i in range(0, len(self.proxies_raw), 500)]
self.proxies_raw = []
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=None),
json_serialize=json.dumps,
trust_env=True) as s:
for chunk in chunks:
tasks = []
for proxy in chunk:
tasks.append(asyncio.create_task(is_working(s, proxy)))
await asyncio.gather(*tasks)
def load_proxies(self):
with open(conf["proxies"], "r") as f:
self.proxies_raw = [["http://" + proxy, ""] if "http" not in proxy else [proxy, "x-csrf-token"] for proxy in f.read().splitlines()]
self.proxiesOn = bool(self.proxies_raw) and conf["proxies enabled"]
self.proxy = "N/A"
if self.proxiesOn:
if conf["checkProxies"]:
print(Visual.textToColour("[COLOR_LIGHT_BLUE]"), end="")
idx = pick(["Yes", "Yes, and save the working proxies.", "No", "No, and don't remind me again"],
"Proxies found, do you want to check them?",
indicator=themeConfig.get('indicator', ">>"))[1]
if idx == 0 or idx == 1:
asyncio.run(self.check_proxies())
if idx == 1:
with open(conf["proxies"], "w") as f:
f.write("\n".join(self.proxies_raw))
if idx == 1 or idx == 3:
conf["checkProxies"] = False
with open("config.json", "w") as f:
json.dump(conf, f, indent=4)
if len(self.proxies_raw) == 0:
return
self.proxy_pool = self.proxy_cycle()
self.proxy = next(self.proxy_pool)
async def auto_update(self):
async with aiohttp.ClientSession() as s:
try:
self.ip = json.loads(await (await s.get("http://www.httpbin.org/ip", timeout=2)).text())["origin"]
except:
self.ip = "N/A"
if not conf["auto update"] or conf.get("update reminder", 0) > time.time():
return
Visual.betterPrint("[COLOR_AQUAMARINE_1A]Checking for potential updates...")
async with aiohttp.ClientSession() as s:
src = await (await s.get("https://raw.githubusercontent.com/J3ldo/UGC-Sniper/main/main.py", ssl=False)).text()
try:
version = src.split("VERSION = \"")[1].split("\"")[0]
except IndexError:
visual.betterPrint("[COLOR_RED]Could not get valid version number")
version = VERSION
if version != VERSION:
idx = pick(["Yes", "No", "No, and don't remind me again", "No, Remind me in 30 minutes"],
Visual.textToColour("New update found, do you want to update?"),
indicator=themeConfig.get("indicator", ">>"))[1]
if idx == 1:
return
if idx == 2:
conf["auto update"] = False
with open('config.json', "w") as f:
json.dump(conf, f, indent=4)
return
if idx == 3:
conf["updateReminder"] = math.floor(time.time()) + 30 * 60
with open('config.json', "w") as f:
json.dump(conf, f, indent=4)
return
Visual.betterPrint("[COLOR_AQUAMARINE_1A]Updating code...")
with open("main.py", "w", encoding="utf-8") as f:
f.write(src)
Visual.betterPrint("[COLOR_AQUAMARINE_1A]Updated code! restart the sniper to use the newest version")
Visual.pause()
exit(0)
else:
Visual.betterPrint("[COLOR_AQUAMARINE_1A]No updates found.")
def get_type(self):
modes = ["Speed 1-2 minutes before ratelimit", "Quick 2-10 minutes before ratelimit", "Casual 10-60 minutes before ratelimit",
"Afk 1-12 hours before ratelimit", "Time 1-∞ minutes before ratelimit", "Specific time 1-∞ minutes before ratelimit"]
modeNames = ["Speed", "Quick", "Casual", "Afk", "Time", "Specific time"]
self.mode = conf.get("mode", "").title()
if self.mode not in modeNames:
self.mode = modeNames[
pick(modes, "Select your checking mode: ", indicator=themeConfig.get("indicator", ">>"))[1]]
if self.mode == "Speed":
self.cooldown = Other.calculate_cooldown(80, self.mode.lower())
elif self.mode == "Quick":
self.cooldown = Other.calculate_cooldown(60, self.mode.lower())
elif self.mode == "Casual":
self.cooldown = Other.calculate_cooldown(55, self.mode.lower())
elif self.mode == "Afk":
self.cooldown = Other.calculate_cooldown(50, self.mode.lower())
elif self.mode == "Time":
self.mode_time = True
if self.minutes < 0:
Visual.betterPrint("[COLOR_LIGHT_BLUE][>>] Enter number of minutes untill ugc releases: ")
self.minutes = int(input(Visual.textToColour("[COLOR_LIGHT_BLUE] [>>] ")))
Visual.betterPrint(
f"[COLOR_VIOLET][*] Sniper will run for {self.minutes} minutes / {self.minutes * 60} seconds before speed sniping")
time.sleep(3)
self.cooldown = conf["custom time cooldown"] if conf["custom time cooldown"] >= 0 else 0.5
if len(self.limiteds) == 0:
Visual.betterPrint("[COLOR_RED]No limiteds added, please add a limited for the sniper to work.")
Visual.pause()
exit(1)
else:
while 1:
if self.unix < 0:
Visual.betterPrint("[COLOR_LIGHT_BLUE][>>] Enter the unix timestamp of when the item releases.")
self.unix = math.floor(float(input(Visual.textToColour("[COLOR_LIGHT_BLUE] [>>] "))))
self.minutes = math.floor((self.unix - time.time()) / 60)
if self.minutes < 0:
Visual.betterPrint(
"[COLOR_RED]WARNING The specified unix timestamp already happend, please put in a valid timestamp.")
time.sleep(1)
self.unix = -1
Visual.clear()
continue
break
Visual.betterPrint(
f"[COLOR_LIGHT_BLUE]Will start sniping in {self.minutes} minutes or on {datetime.datetime.fromtimestamp(self.unix)}")
time.sleep(3)
self.mode_time = True
self.cooldown = conf["custom unix cooldown"] if conf["custom unix cooldown"] >= 0 else 0.5
async def wait(self):
if self.minutes <= 0:
return
if self.mode_time is True:
Visual.betterPrint(
"[COLOR_AQUAMARINE_1A]You picked time. Feel the essence of the sniper and the power of the limiteds. The great fortunes you can make, just by waiting..")
Visual.betterPrint(f"[COLOR_PINK_1][*] You have {self.minutes} minutes left.")
async with aiohttp.ClientSession() as s:
for i in range(self.minutes):
fact = json.loads(await (await s.get("https://catfact.ninja/fact")).text())["fact"]
for _ in range(60):
if self.minutes <= 0:
Visual.betterPrint("[COLOR_CYAN]Unpaused.")
return
await asyncio.sleep(1)
Visual.betterPrint(f"[COLOR_PINK_1][*] You have {self.minutes - (i + 1)} minutes left.\n"
f"\t[COLOR_CYAN]Random cat fact: {fact}")
Visual.betterPrint(f"[COLOR_PINK_1][*] Time ended. Starting spam sniper.")
def start(self):
for task in start_tasks: asyncio.run(task(self))
asyncio.run(self.main())
async def print_all(self):
global recent_logs, current_frame
iteration = 0
if themeConfig["type"] == "txt": Visual.betterPrint(logo, log=False)
if themeConfig["type"] == "py":
if themeFile.printLogo() == 0:
sniper.errors += 1
while 1:
if iteration > conf.get("log reset iteration", 3)*themeConfig.get("fps", 1):
iteration = 0
self.tooltip = random.choice(self.tooltips)
self.ram = subprocess.getoutput(f'tasklist /fi "pid eq {os.getpid()}"').split(" K")[0].split(" ")[
-1] if "[memory_usage]" in printText else "N/A" # Preformance go brr
recent_logs = []
Visual.clear()
if themeConfig["type"] == "py":
if conf.get("logo dupe", True):
if themeFile.printLogo() == 0: sniper.errors += 1
if themeFile.printText(sniper, "".join(
themeConfig.get('log seperator', "[LOG]\n").replace("[LOG]", log) for log in recent_logs)) == 0:
sniper.errors += 1
if themeConfig["type"] == "txt": # Text theme
if update_freq < 0: # Not animated
if conf.get("logo dupe", True): Visual.betterPrint(logo, log=False, include_time=False)
else: # Animated
Visual.betterPrint(current_frame, log=False, include_time=False)
current_frame = next(frame_pool)
Visual.betterPrint(Visual.textToVar(self, printText), log=False, include_time=False) # Print information
if update_freq < 0:
await asyncio.sleep(conf["print update cooldown"])
else:
await asyncio.sleep(update_freq)
iteration += 1
async def debug_print(self):
global recent_logs
Visual.betterPrint("[COLOR_GREEN]Successfully started debug print")
while 1:
if recent_logs:
Visual.betterPrint("\n".join(recent_logs), include_time=False)
recent_logs = []
await asyncio.sleep(0.1)
async def get_token(self):
logging.info("Started getting token.")
async with aiohttp.ClientSession(json_serialize=json.dumps) as s:
self.userinfo = await (await s.get("https://users.roblox.com/v1/users/authenticated",
cookies={".ROBLOSECURITY": self.cookies[0][0]})).json()
for idx, cookie in enumerate(self.cookies):
try:
self.cookies[idx][2] = (await (await s.get("https://users.roblox.com/v1/users/authenticated",
cookies={".ROBLOSECURITY": cookie[0]}, ssl=False)).json())['id']
except KeyError:
Visual.betterPrint("[COLOR_RED]Invalid cookie parsed.")
Visual.pause()
exit(1)
while 1:
for idx, cookie in enumerate(self.cookies):
if idx == 0 and self.update_token: self.update_token = False
try:
resp = await s.post("https://auth.roblox.com/v2/logout",
cookies={".ROBLOSECURITY": cookie[0]}, ssl=False)
self.cookies[idx][1] = resp.headers['x-csrf-token']
except:
self.update_token = True
break
logging.info(f"Got token of {self.cookies[idx][1]}")
for _ in range(round(30)):
if self.update_token:
break
await asyncio.sleep(1)
async def proxy_token(self):
async with aiohttp.ClientSession() as s:
async def get_token(idx):
try:
self.proxies_raw[idx][1] = (await s.post("https://auth.roblox.com/v1/usernames/validate",
proxy=self.proxies_raw[idx][0], timeout=conf.get("timeout", 3), proxy_auth=None)).headers['x-csrf-token']
except:
self.errors += 1
return
while 1:
tasks = []
for idx, proxy in enumerate(self.proxies_raw):
if idx == 0 and self.update_token: self.update_token = False
tasks.append(asyncio.create_task(get_token(idx)))
await asyncio.gather(*tasks)
for _ in range(round(30)):
if self.update_token:
break
await asyncio.sleep(1)
async def get_bought(self, session, limited, cookie):
try:
req = await session.get(
f"https://inventory.roblox.com/v2/users/{cookie[2]}/inventory/{limited['assetType']}?limit=100&sortOrder=Desc",
cookies={".ROBLOSECURITY": cookie[0] if not self.proxiesOn else ""},
headers={"x-csrf-token": cookie[0] if not self.proxiesOn else self.proxy[1]},
ssl=False, proxy=self.proxy[0] if self.proxiesOn else "", timeout=conf.get("timeout", 3), proxy_auth=None)
except asyncio.exceptions.TimeoutError:
Visual.betterPrint("[COLOR_RED]Buy ratelimit caught! (timeout)", True)
return -1
return (await req.text()).count(str(limited["id"]))
async def __buy(self, session, buydata, liminfo, cookie):
'''
:param session: The aiohttp.ClientSession
:param buydata: The data needed for the buy request
:return: bool bought, bool ratelimit, bool switch_cookie, bool soldout, dict data
'''
try:
req = await session.post(
f"https://apis.roblox.com/marketplace-sales/v1/item/{buydata['collectibleItemId']}/purchase-item",
json=buydata, ssl=False, proxy=self.proxy[0] if self.proxiesOn and conf["purchase proxy"] else "",
headers={"x-csrf-token": cookie[1] if not self.proxiesOn else self.proxy[1]},
cookies={".ROBLOSECURITY": cookie[0] if not self.proxiesOn else ""},
timeout=conf.get("timeout", 3), proxy_auth=None)
except asyncio.exceptions.TimeoutError:
Visual.betterPrint("[COLOR_RED]Buy ratelimit caught! (timeout)", True)
return False, True, False, False, {}
logging.info(f"Received: {await req.text()} - Sent : {buydata}")
if req.reason == "Too Many Requests":
Visual.betterPrint("[COLOR_RED]Buy ratelimit caught!", True)
return False, True, False, False, {}
data_raw = await req.text()
if data_raw == "":
Visual.betterPrint("[COLOR_RED]Caught Error whilst trying to get the buy information", True,
log_level="warning")
self.errors += 1
return False, False, False, False, {}
try:
data = json.loads(data_raw)
except json.JSONDecodeError:
Visual.betterPrint(
f"[COLOR_RED]Caught Error whilst trying to get the buy information. Info: '{data_raw}' - {req.reason}",
True, log_level="warning")
self.errors += 1
return False, False, False, False, {}
if data['purchaseResult'] == 'Flooded':
Visual.betterPrint("[COLOR_RED]Buy ratelimit caught!", True)
return False, True, False, False, data
if data['errorMessage'] == 'QuantityExhausted':
Visual.betterPrint(f"[COLOR_RED]All items sold out.", True)
return False, False, False, True, data
if data['errorMessage'] == "Only support User type for purchasing: request purchaser type Group":
Visual.betterPrint("[COLOR_RED]Limited is only available to buy from group.", True)
return False, False, False, True, data
if not data["purchased"]:
Visual.betterPrint(f"[COLOR_RED]Failed buying limited, trying again.. Info: {data} - {buydata}", True)
return False, False, False, False, data
if data["purchased"]:
Visual.betterPrint(f"[COLOR_AQUAMARINE_1A]Successfully bought limited! Info: {data} - {buydata}", True)
if conf["webhook enabled"]:
embed = discord.Embed(title='Purchased Limited', description=f'{"@everyone " if conf["ping everyone"] else ""}Successfully sniped a limited!',
color=discord.Colour.blue())
embed.add_field(name=f'Item',
value=f'[{liminfo["name"]}](https://www.roblox.com/catalog/{liminfo["id"]})')
embed.add_field(name=f'Stock', value=f'`{liminfo["unitsAvailableForConsumption"]}/{liminfo["totalQuantity"]}`')
embed.add_field(name=f'Received', value=f'{data}')
webhook = discord.Webhook.from_url(conf["webhook"], session=session)
await webhook.send(embed=embed)
return True, False, False, False, data
return False, False, False, False, data
async def buy(self, session, data, dont_remove=False):
'''
:param session: The aiohttp session
:param data: The item information received by the request
:return: bool boughtsession
'''
logging.info("Buying item, got: "+str(data))
for task in start_buy_tasks: asyncio.create_task(task(self, data["id"], data))
if dont_remove is False:
try:
self.limiteds.remove(str(data["id"]))
except ValueError:
logging.warning(f"Limited: {data['id']} not in limiteds, All data: {data}")
# Paid checks
if data["price"] > 0 and not conf.get("purchase paid ugcs", False):
Visual.betterPrint(f"[COLOR_RED]Aborted buying limited. Reason: paid limited - Price: {data['price']}",
True)
return
if data["price"] > conf.get("paid ugcs max price", 0):
Visual.betterPrint(
f"[COLOR_RED]Aborted buying limited. Reason: item price to high - Price: {data['price']}", True)
return
if data["price"] > 0 and self.boughtpaid >= conf.get("purchase paid ugcs amount", 0):
Visual.betterPrint(
f"[COLOR_RED]Aborted buying limited. Reason: Maximum amount of paid limiteds bought. - Price: {data['price']}",
True)
return
# Get the product id
productid = None
Visual.betterPrint("Getting needed information...", True)
while productid is None:
_inf = await session.post("https://apis.roblox.com/marketplace-items/v1/items/details",
json={"itemIds": [data["collectibleItemId"]]}, ssl=False)
try:
Visual.betterPrint("Sent request for information, scraping needed information")
inf = json.loads(await _inf.text())[0]
productid = inf["collectibleProductId"]
except (json.JSONDecodeError, KeyError):
Visual.betterPrint(
f"[COLOR_RED]Something went wrong whilst getting the product id Logs - {await _inf.text()} - {_inf.reason}. Trying again.",
True)
continue
# Set up the data
Visual.betterPrint("Got needed information, setting up data", True)
buydata = {
"collectibleItemId": inf["collectibleItemId"],
"expectedCurrency": 1,
"expectedPrice": data["price"] if conf.get("purchase paid ugcs", False) else 0,
"expectedPurchaserId": "id of the receiver",
"expectedPurchaserType": "User",
"expectedSellerId": data["creatorTargetId"],
"expectedSellerType": data['creatorType'],
"idempotencyKey": "random uuid4 string that will be your key or smthn",
"collectibleProductId": productid
}
Visual.betterPrint("Set up data.", True)
# Run buy tasks.
for task in buy_tasks: asyncio.create_task(task(self, data["id"], data, buydata))
boughtsession = 0
limit = data.get("quantityLimitPerUser", 0) if data.get("quantityLimitPerUser", 0) > 0 else conf[
"cookie bought max"]
soldout = False
while not soldout:
for cookie in self.cookies:
boughtsession = 0
boughtbefore = 0
buydata['expectedPurchaserId'] = cookie[2]
if soldout:
break
while not soldout:
tasks = []
get_bought = asyncio.create_task(self.get_bought(session, data, cookie))
for _ in range(4):
buydata["idempotencyKey"] = str(uuid.uuid4())
tasks.append(asyncio.create_task(self.__buy(session, copy.copy(buydata), data, cookie)))