This repository was archived by the owner on Nov 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaTools.lua
More file actions
2945 lines (2823 loc) · 124 KB
/
LuaTools.lua
File metadata and controls
2945 lines (2823 loc) · 124 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
--[[
ABJ4403's LuaTools
(C) 2022-2024 ABJ4403
WARNING: Sharing this script in any encrypted form is violating GPL v3 license,
and restricts users freedom of changing the hard-coded configuration.
Any violations should be reported to the project's issues section
and will result in DMCA Takedown Notice.
]]
--— Configuration ————————————————--
local gg,io,os = gg,io,os -- precache the usual call function (faster function call)
-- Fake-semi-global variable just to make VirtGG perform better (anti hook global/local variable detection)
local _g = {
tmp = {},
randStr = function(len,byteFrom,byteTo)
local len=len or 8
local byteFrom=byteFrom or 128
local byteTo=byteTo or 255
local e=""
for i=1,len do
e=e..string.char(math.random(byteFrom,byteTo))
end
return e
end,
--XOR encryption
xdenc_XOR = function(iv,key)local iv_,key_,i,stringChar={iv:byte(0,-1)},{key:byte(0,-1)},0,string.char local r=iv:gsub(".",function()i=i+1 return stringChar(iv_[i]~key_[(i%#key_)+1])end)return r end,
dec_wrap_XOR = function(key)return'(iv)local iv,key,stringChar={iv:byte(0,-1)},{([==['..key..']==]):byte(0,-1)},string.char for i=1,#iv do iv[i]=stringChar(iv[i]~key[(i%#key)+1]) end return table.concat(iv)'end,
cfg = {
-- Allow user freedom of changing whatever they want
-- Please DO NOT encrypt this script, because we like to change configuration like below
-- if you encrypt this script, then you can't customize stuff here.
-- you will need a code editor (preferably the one that has syntax-highlighting & code-folding, like Acode), and Lua knowledge for customizing these stuff below...
VERSION = "2.9", -- plz ignore this :)
scriptPath = gg.getFile():gsub('.lua$',''), -- strip the .lua,
--fileChoice = '/sdcard/Notes/test', -- dummy, replaced whenever any file is selected within the GUI
debugMode = true,
obfOpts = {
minGGVer = gg.VERSION, -- GG version required
minGGBuildVer = gg.BUILD, -- minimal GG build version required
allowNewGGBuildVer = true, -- whether to allow newer GG version or not (uses gg.BUILD variable only)
ggPkg = "", -- what only gg package script will run
appPkg = "", -- what only target package script will run
scriptExpiry = "20301111", -- YYYYMMDD order
scriptPW = "1234", -- script password
stripAnnotations = true,
savePW = true, -- when enabled, the hashed password (not the actual pw) will be exported to a file with '.lt.cfg' extension
encryptStrings = false,
encryptTables = true,
text = {
failAppPkgInvalid = "[PkgScanner] This script is only allowed to run on %s, and the target app package name is %s",
failDatePassed = "[GGRestrict] This script is expired at %s.",
failDeniedPkgs = "[PkgScanner] Denied packages detected: %s",
failGGPkgInvalid = "[PkgScanner] This script is only allowed to run on %s, and your GG package name is %s",
failGGVerBelow = "[PkgScanner] This script is only allowed to run on %s %s (build %s), and you're running on version %s (build %s)",
failHookDetected = "[VariableTracer] Hook detected! Please run the script in a normal environment.",
failLogDetected = "[DumpDetector] Logging detected! this may be caused by slow device, if you didn't expect this, please contact the script author.",
failInvalidPW = "[Auth] Invalid Password!",
failInvalidPWFile = "[Auth] Invalid Password hash stored in configuration!",
failRenamed = "[FileWatcher] Renaming detected! sorry but you need to rename the script back to: %s your script name is: %s",
promoteYourself = "\tFollow me!\n\tGitHub: https://github.com/ABJ4403\n\tTelegram: https://t.me/ABJ4403_Group\n\tYouTube: https://youtube.com/@AyamGGoreng",
inputPass = "[Auth] Input Password:",
warnPeeking = "[NoPeek] Caught peeking values",
}
},
lasmPatches = {
-- Put your patches here (if you add/remove entries in here, you may want to modify `wrapper_lasmPatches()`)
-- Important: Lua doesn't use RegEx: https://lua.org/manual/5.1/manual.html#5.4.1
-- Also, ^$()%.[]*+-? is magic char, escape those using % instead of \
selfDecrypt = {
-- For self-decrypt
-- Removed for now cuz its too big
},
RemoveGarbage = {
--All this was original by @ABJ4403
{'[^\n]*; garbage\n',''},
--{'[^\n]*; unused\n',''}, -- disabled cuz removing RETURN after TAILCALL, and this f'ed unluac
{'\nRETURN (v%d-%.%.v%d-)\nRETURN ; unused\n','\nRETURN %1\n'},
--{'\nTAILCALL (.-)\nRETURN .- ; unused\n','\nTAILCALL %1\n'}, -- disabled cuz removing RETURN after TAILCALL, and this f'ed unluac
{'[^\n]*; variable v%d- out of stack %(%.maxstacksize = %d- for this func%)\n',''},
{'JMP :goto_%d- ; %-0 ↑\n',''},
{'JMP :goto_%d- ; %+0 ↓\n',''},
{'OP%[%d%d%] 0x[0-9a-f]-\n',''},
{'GETTABLE v%d- v%d- nil\n',''}, -- table[nil]. in Lua you can't set a table with nil as key
{'SETTABLE v%d- nil .-\n',''}, -- same as above
--{'\n.- CONST%[%d-%]',''}, -- untested
--remove null loop
-- while true do end/infinite loop
{':goto_(%d-)\nJMP :goto_%1\n',''},
{'FORLOOP v%d- GOTO%[%-%d-%] ; %-%d- ↑\n; %.end local v%d- "%(for index%)"\n; %.end local v%d- "%(for limit%)"\n; %.end local v%d- "%(for step%)"\n; %.end local v%d- "%(for iterator%)"',''},
{'FORLOOP v%d- GOTO%[%d-%] ; %+%d- ↓\n; %.end local v%d- "%(for index%)"\n; %.end local v%d- "%(for limit%)"\n; %.end local v%d- "%(for step%)"\n; %.end local v%d- "%(for iterator%)"',''},
{'LOADK v%d- %d-\nLOADK v%d- %d-\nLOADK v%d- %d-\n; %.local v%d- "%(for index%)"\n; %.local v%d- "%(for limit%)"\n; %.local v%d- "%(for step%)"\n; %.local v%d- "%(for iterator%)"\nFORPREP v%d- :goto_%d- ; %+0 ↓\n:goto_%d-\nFORLOOP v%d- :goto_%d- ; %-1 ↑\n; %.end local v%d- "%(for index%)"\n; %.end local v%d- "%(for limit%)"\n; %.end local v%d- "%(for step%)"\n; %.end local v%d- "%(for iterator%)"',''},
--anti-unluac (BOR,BNOT,BAND,BXOR is OP41,OP42,OP43,OP44
--if lua version is 5.2, which makes unluac confused)
{'BAND v%d- v%d- v%d-\n',''},
--{'BOR v(%d-) v(%d-) v(%d-)\n','ADD v%1 v%2 v%3'}, -- in cases like gg.setRanges(gg.REGION_* | gg.REGION_*)
{'BNOT v%d- v%d-\n',''},
--{'BXOR v%d- v%d- v%d-\n',''},
{'SHL v%d- v%d- v%d-\n',''},
{'SHR v%d- v%d- v%d-\n',''},
--malformed arithmetic that is if executed, crashed the script
{'BAND v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'BAND v'..a..' '..b..' '..c..'\n'end}, -- a & b
{'BXOR v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'BXOR v'..a..' '..b..' '..c..'\n'end}, -- a ~ b
{'BOR v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'BOR v'..a..' '..b..' '..c..'\n'end}, -- a | b
{'ADD v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'ADD v'..a..' '..b..' '..c..'\n'end}, -- a + b
{'SUB v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'SUB v'..a..' '..b..' '..c..'\n'end}, -- a - b
{'MUL v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'MUL v'..a..' '..b..' '..c..'\n'end}, -- a * b
{'DIV v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'DIV v'..a..' '..b..' '..c..'\n'end}, -- a / b
{'IDIV v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'IDIV v'..a..' '..b..' '..c..'\n'end}, -- a // b
{'MOD v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'MOD v'..a..' '..b..' '..c..'\n'end}, -- a % b
{'POW v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'POW v'..a..' '..b..' '..c..'\n'end}, -- a ^ b
{'SHR v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'SHR v'..a..' '..b..' '..c..'\n'end}, -- a >> b
{'SHL v(%d-) (.-) (.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'SHL v'..a..' '..b..' '..c..'\n'end}, -- a << b
{'CONCAT v(%d-) (.-)%.%.(.-)\n',function(a,b,c)return (b=='nil'or b=='true'or b=='false'or c=='nil'or c=='true'or c=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'CONCAT v'..a..' '..b..'..'..c..'\n'end}, -- a .. b
{'UNM v(%d-) (.-)\n',function(a,b)return (b=='nil'or b=='true'or b=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'UNM v'..a..' '..b..'\n'end}, -- -a
{'LEN v(%d-) (.-)\n',function(a,b)return (b=='nil'or b=='true'or b=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'LEN v'..a..' '..b..'\n'end}, -- #a
{'BNOT v(%d-) (.-)\n',function(a,b)return (b=='nil'or b=='true'or b=='false') and'LOADNIL v'..a..'..v'..a..'\n'or'BNOT v'..a..' '..b..'\n'end}, -- ~a
--Unnecessary calls (simplify instructions, can improve performance)
--convert checks against same variable to `nil ==/~= nil` (0/1 basically makes true/false)
{'LT 1 (.-) %1\n','EQ 0 nil nil\n'},
{'LE 1 (.-) %1\n','EQ 1 nil nil\n'},
{'LT 1 (%d-) (%d-)\n',function(b,c)return tonumber(b)<tonumber(c) and'EQ 0 nil nil\n'or'EQ 1 nil nil\n'end},
{'LT 0 (%d-) (%d-)\n',function(b,c)return tonumber(b)>tonumber(c) and'EQ 0 nil nil\n'or'EQ 1 nil nil\n'end},
{'LE 1 (%d-) (%d-)\n',function(b,c)return tonumber(b)<=tonumber(c) and'EQ 0 nil nil\n'or'EQ 1 nil nil\n'end},
{'LE 0 (%d-) (%d-)\n',function(b,c)return tonumber(b)>tonumber(c) and'EQ 0 nil nil\n'or'EQ 1 nil nil\n'end},
--unnecessary math (precalculate results for faster code)
{'(%u-) v(%d-) (%-?[0-9%.]-) (%-?[0-9%.]-)\n',function(i,v,a,b)
a = tonumber(a)
b = tonumber(b)
local c
if i == "BAND" then c = a & b
elseif i == "BXOR" then c = a ~ b
elseif i == "BOR" then c = a | b
elseif i == "ADD" then c = a + b
elseif i == "SUB" then c = a - b
elseif i == "MUL" then c = a * b
elseif i == "DIV" then c = a / b
elseif i == "IDIV" then c = a // b
elseif i == "MOD" then c = a % b
elseif i == "POW" then c = a ^ b
elseif i == "SHR" then c = a >> b
elseif i == "SHL" then c = a << b
else return ("%s v%s %s %s \n"):format(i,v,v,a,b)
end
c = tostring(c)
-- if the result is infinity number, return 1/0
if c == "inf" then
return 'DIV v'..v..' 1 0\n'
elseif c == "-inf" then
return 'DIV v'..v..' -1 0\n'
end
return 'LOADK v'..v..' '..c..'\n'
end},
--literally moves nothing
{'MOVE v(%d-) v%1\n',''},
--not not true > true (aka. useless code again)
{'NOT v(%d-) v%1\nNOT v%1 v%1\n',''},
{'EQ 0 (.-) (.-)\n',function(b,c)if b == c then b,c='nil','nil'end return'EQ 0 '..b..' '..c..'\n'end},
-- specific crafted values that when
-- assembled and disassembled will give invalid values
-- generated with making infinite number `val = 9e999` or `LOADK v0 9E999`
{'%u- v%d- Infinity%.0\n',''},
{'%u- v%d- Infinity%.0 [^\n]*\n',''},
{'%u- v%d- [^\n]* Infinity%.0\n',''},
{'%u- v%d- -Infinity%.0\n',''},
{'%u- v%d- -Infinity%.0 [^\n]*\n',''},
{'%u- v%d- [^\n]* -Infinity%.0\n',''},
{'%u- v%d- null\n',''},
{'%u- v%d- null [^\n]*\n',''},
{'%u- v%d- [^\n]* null\n',''},
--function with no upval (crashes assembler)
--{'%.source (.-\n%.maxstacksize %d-)\n','.source %1\n.upval u0 nil\n'},
--function with no RETURN (crashes assembler and causes vm error)
--{'%.source (.-\n)%.end',function(srcinst)return'.source '..srcinst:gsub('\nRETURN[^\n]*','')..'RETURN\n.end'end},
},
RemoveLasmBlock = {
-- Lasm block, known as Anti reassemble
-- Original by SwinX Tools. some numbers were modified to work...
{
'[^\n]*%.source ".-"\n%.linedefined %d-\n%.lastlinedefined %d-\n%.numparams (%d-)\n%.is_vararg (%d-)\n%.maxstacksize (%d-)\n',
function(a,b,c)return'.source ""\n.linedefined 0\n.lastlinedefined 0\n.numparams '..math.min(21,tonumber(a))..'\n.is_vararg '..b..'\n.maxstacksize '..math.min(21,tonumber(c))..'\n'end
},
},
RemoveCodeHider = {
{' SET_TOP\n','\n'}, -- CALL v?..v? SET_TOP. some code fails, `print((function()return 1 end)()` returns nil instead of 1)
{'\nSETTABLE v%d- "[^\n]*" v%d-\n','\n'}, -- looks like this removes important code dont use this (a.b = nil)
--{'\nSETTABLE v%d- "[^\n]*" nil\n','\n'},
--{'\nSETTABLE v%d- v%d- nil\n','\n'},
},
EssentialMinify = {
-- Some regex fails, this can help by trimming spaces/tabs, and blank lines...
{'\n%s*(.-)%s*\n','\n%1\n'}, -- trim tabs
{'%s*\n%s*','\n'}, -- trim tabs
{'\n\n','\n'}, --remove blank line (doesnt do anything?)
-- useless gg assembly annotation (untested)
--{'\n; %.end local v%d- "%(for generator%)"\n','\n'},
--{'\n; %.end local v%d- "%(for state%)"\n','\n'},
--{'\n; %.end local v%d- "%(for control%)"\n','\n'},
--{'\n; %.end local v%d- "%(for key%)"\n','\n'},
},
JmpObf = {
--tries to remove some JMP obfuscations (this won't work on sophisticated obfuscations though)
--{'\nJMP :goto_(%d-) ; (%-%d-) ↑\n',function(l,o)l,o=tonumber(l),tonumber(o) return l > 0 or l < -999 and""or"JMP :goto_"..l.." ; "..o.." ↑\n"end},
--{'\nJMP :goto_(%d-) ; (%d-) ↓\n' ,function(l,o)l,o=tonumber(l),tonumber(o) return l < 0 or l > 999 and""or"JMP :goto_"..l.." ; "..o.." ↓\n"end},
{'\nJMP :goto_(%d-) ; 0 ↓\n:goto_(%d-)',function(l,o)return a==b and''or'\nJMP :goto_'..a..' ; 0 ↓\n:goto_'..b end},
--{'\nJMP :goto_(%d-) ; 0 ↓\n:goto_(%d-)',function(l,o)return a==b and'\n:goto_'..b or'\nJMP :goto_'..a..' ; 0 ↓\n:goto_'..b end},
},
},
bytecodePatches = {
-- Put your bytecode patches here
-- this should only used in condition where
-- either the script is corrupted, dealing with
-- very long strings (so long it caused vm crash)
-- or it cant be disassembled
bigLasm = {
--btw 4,?,?,?,? is based on the text length (eg. YEET > 4,(1+4=5),0,0,0)
--and most of these can also be repeat 1e4 instead of 1e3
--I think i know how these works, this is the example: (_="aaa(repeated 10k times)") (repeated 60k times)
--by replacing it with 4,1,0,0,0, we essentially making it LOADK v? "<empty string>"
{'\4\17\39\0\0'..('.'):rep(1e4),'\4\1\0\0\0\0'},
{('\0\99\53\151\82\116\66\115\67\53'):rep(1e3),'\4\1\0\0\0\0'},
{('\0\99\53\66\82\116\66\115\67\53'):rep(1e3),'\4\1\0\0\0\0'},
{('\0\99\145\151\23\130\37\115\67\53'):rep(1e3),'\4\1\0\0\0\0'},
{('\0\103\53\151\82\116\70\115\67\69'):rep(1e3),'\4\1\0\0\0\0'},
},
antiReassembleNullStr = {
--opposite of above, this fixes null string to empty string instead to make it assembleable again
--could've done it with lasm but more option is good eh?
--especially for some script that has unknown anti disassemble
{'\4\0\0\0\0','\4\1\0\0\0\0'},
},
antiDisassemble1 = {
{'\128\0\228\0\128','\128\0\31\0\128'}
}
}
},
lasmPatchesName = {
selfDecrypt = {
"rmAntiHook",
"rmPasswordRegular",
"rmPasswordExportPw",
"rmNoRename",
"rmSpamlog",
"rmHbxvpnObf"
},
RemoveGarbage = {
"garbage",
--"unused",
"unusedReturn",
--"returnAfterTailcall",
"outOfStack",
"uselessJmpUp",
"uselessJmpDown",
"malformedOp",
"nullTable",
"nullTable2",
--"nullConst",
"nullLoop",
"nullLoop2",
"nullLoop3",
"nullLoop4",
"antiUnluacBAND",
--"antiUnluacBOR",
"antiUnluacBNOT",
--"antiUnluacBXOR",
"antiUnluacSHL",
"antiUnluacSHR",
"malformedBAND",
"malformedBXOR",
"malformedBOR",
"malformedADD",
"malformedSUB",
"malformedMUL",
"malformedDIV",
"malformedIDIV",
"malformedMOD",
"malformedPOW",
"malformedSHR",
"malformedSHL",
"malformedCONCAT",
"malformedUNM",
"malformedLEN",
"malformedBNOT",
"unnecessaryLTEQ",
"unnecessaryLEEQ",
"unnecessaryLT",
"unnecessaryGT",
"unnecessaryLE",
"unnecessaryGT2",
"unnecessaryMath",
"unnecessaryMOVE",
"unnecessaryNOT",
"unnecessaryEQ",
"NaNinfinity1",
"NaNinfinity2",
"NaNinfinity3",
"NaNnull1",
"NaNnull2",
"NaNnull3",
--"noUpval",
--"noReturn"
},
RemoveLasmBlock = {},
RemoveCodeHider = {},
RemoveBlocker1 = {},
EssentialMinify = {},
JmpObf = {},
},
}
_g.obfMod = {
-- Put your obfuscation module here (sorted by name)
A_EncryptorSignature = function()return "local _=[[\n\n——————————————————————————————————————————————————\n|\n| 🛡 Encrypted by ABJ4403's LuaTools encryptor v".._g.cfg.VERSION.." (https://github.com/ABJ4403/LuaTools)\n| Features:\n| + Simple, no bloat.\n| + Free & Open-Source, Licensed under GPL v3\n| + Modable.\n| + Table/string encryption.\n| + Fast (No arbitrary slowdown, great optimization, local variables, isolated obfuscator modules makes sure global variables not polluted).\n| + Optional Hard-Password requirement (with XOR encryption, we can use the password itself as a decryption key :) TODO...\n| + Respects both the author & end user.\n|\n| If you trying to open this encrypted file,\n| well uhh... GL to even decrypt this XD (if you do)\n| Otherwise if you think this isn't safe, Don't worry, the encryptor is open-source :D\n| Go to https://github.com/ABJ4403/LuaTools for the source code\n|\n——————————————————————————————————————————————————\n\n\n]]"end,
B_PromoteYourself = function()return "local _=[[\n\n".._g.cfg.obfOpts.text.promoteYourself.."\n\n]]"end,
C_RestrictGGVer = function()
local matcher,verTxt = 'gg.BUILD < GGPacBuildVer'
if not _g.cfg.obfOpts.allowNewGGBuildVer then
verTxt = 'version'
matcher = matcher..' or gg.VERSION ~= GGPacVer'
else
verTxt = 'minimum version'
end
if _g.cfg.obfOpts.minGGVer ~= '' and _g.cfg.obfOpts.minGGBuildVer ~= '' then
return 'local GGPacVer,GGPacBuildVer,verTxt='.._g.cfg.enc(_g.cfg.obfOpts.minGGVer)..',tonumber('.._g.cfg.enc(_g.cfg.obfOpts.minGGBuildVer)..'),"'..verTxt..'" if '..matcher..' then print(("'.._g.cfg.obfOpts.text.failGGVerBelow..'"):format(verTxt,GGPacVer,GGPacBuildVer,gg.VERSION,gg.BUILD))os.exit()end GGPacVer,GGPacBuildVer,verTxt=nil,nil,nil'
end
end,
--[[D_RestrictGGPkg = function()
if _g.cfg.obfOpts.ggPkg ~= '' then
return 'local GGPkgNm="'.._g.cfg.enc(_g.cfg.obfOpts.ggPkg)..'" if gg.PACKAGE ~= GGPkgNm then print(("'.._g.cfg.obfOpts.text.failGGPkgInvalid..'"):format(GGPkgNm,gg.PACKAGE))os.exit()end GGPkgNm=nil'
end
end,]]
--[[E_RestrictAppPkg = function()
if _g.cfg.obfOpts.appPkg ~= '' then
return 'local GGAppPkg="'.._g.cfg.enc(_g.cfg.obfOpts.appPkg)..'" if gg.getTargetPackage() ~= GGAppPkg then print(("'.._g.cfg.obfOpts.text.failAppPkgInvalid..'"):format(GGAppPkg,gg.getTargetPackage()))return end GGAppPkg=nil'
end
end,]]
F_RestrictExpire = function()
if _g.cfg.obfOpts.scriptExpiry ~= '' then
return 'local GGPacDtm='.._g.cfg.enc(_g.cfg.obfOpts.scriptExpiry)..'if tonumber(os.date"%Y%m%d") > tonumber(GGPacDtm) then print(("'.._g.cfg.obfOpts.text.failDatePassed..'"):format(GGPacDtm))os.exit()end GGPacDtm=nil'
end
end,
G_RestrictPkgs = function()return 'for _,v in ipairs{"app.greyshirts.sslcapture","com.goushi.gtpcanary","com.goushi.httpcanary","com.guoshi.httpcanary.premium","com.minhui.networkcapture","com.minhui.wifianalyzer","com.packagesniffer.frtparlak","frtparlak.rootsniffer","jp.co.taosoftware.android.packetcapture","any_.body_.can_.fuck_.tencent_","com.aero.ss","com.blackduty.gc","com.coolfoolggfuckscript.tm","com.decrypt.revo6","com.dzelttwyuyyes","com.Egypt.yuosseef","com.eidymumcghpfeeeavps","com.fhshwhpvqvruvjtu","com.fireongaming.fog","com.fnmods","com.fnmods.sstool","com.foxcyber.gg","com.fqtnswrf","com.froze.konzlet7.logger","com.froze.logger","com.germany.decompile","com.ghueczxrttlhgd","com.gmsm","com.hckeam.mjgql","com.ioclxgpsiyps.ikfbqe","com.ioyysvgfsrig","com.ioyysvgfsriht","com.jtbodgpqxox","com.kaoygxapp","com.laallkxhtrnqncw","com.lua.decompil","com.lua.decompilD","com.lua.skyn","com.modeghaith.hd","com.mod.iraq","com.mrteamz.id","com.mwjvnwesbghkxbjznbwo","com.nochqxpucsbldqqx","com.nydpvsb.z.r.pkgh","com.paranoiaworks.unicus.android.sse","com.pepsi.up","com.prabalgaming.logger","com.pvt4u","com.qq.xXxLogger","com.raincitygaming.ggmod","com.redwolfgaming.ripgg","com.rjvsbmhdspmnfbame","com.roxmemek","com.s.fyojrme","com.smile.ggmods","com.smu.xdwqnkrst","com.sstool.only.sstool","com.sudsjcqvvcmgutdjeg","com.sxqa","com.tc","com.tssfjipkmrco","com.vip.paidhacksonly.mr.toxin","com.vnpqk","com.vrexqfftfsxekm.kl","com.wtkc.gg","com.xyyxgxfn","com.yy.qptvrjwerw.ghoex","com.zgb","com.zyt.sstooD","com.zyt.sstool.premium","DISABLED_catch.Art.Tool.seatch","DISABLED_catch_.me_.if_.you_.can_93","fucklog.by.decbydbc","io.neoterm","most_scripts.fucker","serdadu.log.revo6","sstool.only.com.sstool"} do if gg.isPackageInstalled(v)or gg.PACKAGE == v then print(("'.._g.cfg.obfOpts.text.failDeniedPkgs..'"):format(v))os.exit()end end'end,
H_NoRename = function()return 'local origFileName,fileName="'.._g.cfg.fileChoice:gsub('^/.+/','')..'.enc.lua",gg.getFile():gsub("^/.+/","")if fileName ~= origFileName then print(("'.._g.cfg.obfOpts.text.failRenamed..'"):format(origFileName,fileName))os.exit()end'end,
I_AntiReassemble = function()return [[while nil do ("__LuaTools_Encryption_NullString__")(-9e999) end]]end, -- leverages gg lasm bug that unable to generate floating point number beyond certain point so it will print Infinity.0
J_AntiSSTool = function()return [[while nil do local i={}if(i.i)then i.i=i.i(i)end end]]end,
K_HBXVpnObf = function()return [[while nil do local obf_srE6={nil,-nil%-nil,nil,-nil}if #obf_srE6<0 then break end if obf_srE6[#obf_srE6]<0 then break end if obf_srE6[-nil]~=#obf_srE6&~obf_srE6 then obf_srE6[#obf_srE6]=obf_srE6[-nil]()end if#obf_srE6<nil then obf_srE6[#obf_srE6]=obf_srE6[-nil%nil]()end goto X1 if nil or 0 then return end::X0::obf_P3oU()::X1::function obf_P3oU()goto X2 if nil or 0 then return end::X3::obf_P3oU:_()::X2::goto X3 end goto X0 for i=1,0 do obf_srE6="obf"end for i=1,0 do if nil then obf_srE6="obf"end end if nil then if true then else goto obf_s4df end if nil then else goto obf_s4df end if nil then else goto obf_s4df end::obf_s4df::end end]]end,
L_HookDetect = function()return 'local tmp if debug.getinfo(function()end).isvararg or debug.getinfo(1).istailcall or("a"):rep(2)~="aa" then print("'.._g.cfg.obfOpts.text.failHookDetected..'")os.exit()end for _,t in ipairs{gg,io,os,string,math,table,bit32,utf8,debug}do for _,f in pairs(t)do if type(f) == "function" then tmp = debug.getinfo(f)if tmp.short_src ~= "[Java]" or tmp.source ~= "=[Java]" or tmp.what ~= "Java" or ((k == debug.getinfo and tmp.namewhat ~= "field") and (k ~= debug.getinfo and tmp.namewhat ~= "")) or tmp.linedefined ~= -1 or tmp.lastlinedefined ~= -1 or tmp.currentline ~= -1 or not tmp.isvararg or tmp.istailcall or({debug.getlocal(f,2)})[2] or({debug.getupvalue(f,1)})[2] or(tostring(f):match("function: @.-:"))then print("'.._g.cfg.obfOpts.text.failHookDetected..'")os.exit()end end end end tmp=nil'end,
M_Password = function()
if _g.cfg.obfOpts.scriptPW ~= '' then
--base code only have askPw function
local pwCode = 'askPw=function()CH=gg.prompt({"'.._g.cfg.obfOpts.text.inputPass..'"},nil,{"text"})if not CH or decode(CH[1])~=pwHash then print("'.._g.cfg.obfOpts.text.failInvalidPW..'")os.exit()end '
if _g.cfg.obfOpts.savePW then
--add pw file handler
pwCode = 'local ltFile,ltOutput=gg.getFile():gsub("%.enc%.lua$",".lua"):gsub("%.lua$",".lt.cfg")'..pwCode..'io.open(ltFile,"wb"):write([====[-- ABJ4403 LuaTools Encryptor configuration\n-- Please do not edit this file just in case there is an encoding error while doing it\n-- If you really want to edit this file, use a good code editor that respects the encoding of a file\nreturn {\n--Password hash (to avoid typing the same password again)\n password_hash = "]====]..pwHash..[====["\n}]====]):close()end ltOutput,err=loadfile(ltFile)if ltOutput and not err then ltOutput=ltOutput()if type(ltOutput)~="table"or ltOutput.password_hash~=pwHash then print("'.._g.cfg.obfOpts.text.failInvalidPWFile..'")askPw()end else askPw()end'
else
--just ask pw
pwCode = pwCode..'end askPw()'
end
pwCode = 'local pwHash,askPw,CH,err="'.._g.cfg.xdenc(_g.cfg.obfOpts.scriptPW,_g.cfg.obfOpts.pwHash)..'" '..pwCode..' CH,askPw,pwHash,err=nil,nil,nil,nil' -- code to clear everything
return pwCode
end
end,
N_Welcome = function()return [[gg.toast("🛡 Encrypted by ABJ4403's Lua encryptor v]].._g.cfg.VERSION..[[. Please wait...")]]end,
O_AntiLoad = function()return 'local load,str=load,function()local _=nil end for i=1,1e3 do load(str)end'end,
P_NoPeek = function()return 'gg.searchNumber=(function()local ggSearchNumber=gg.searchNumber return function(...)if gg.isVisible()then gg.setVisible(false)gg.clearList()print("'.._g.cfg.obfOpts.text.warnPeeking..'")end ggSearchNumber(...)if gg.isVisible()then gg.setVisible(false)gg.clearList()print("'.._g.cfg.obfOpts.text.warnPeeking..'")end end end)()'end,
Q_SpamLog = function()return 'local ot,dt,LOG,t1,t2=os.time,debug.traceback,("\0\255"):rep(1e3)t1=ot()for i=1,2e3 do dt(1,nil,LOG)end t2=ot()if t2-t1>1 then print("'.._g.cfg.obfOpts.text.failLogDetected..'")os.exit()end ot,dt,t1,t2,LOG=nil,nil,nil,nil,nil'end,
--R_BigLASM = function()return "while nil do local "..('_="BigLASM"'):rep(6e4)..("(function()end)"):rep(200)..' _=nil '..('goto x '):rep(20)..'::x:: end'end, -- Makes assembly file really big, but unfortunately within lua vm limit (in gameguardian luaj case, its very small footprint limit, more than that, error goes yeet)
--x_cHeaphumanVerify = function()return "local tmp=math.random(1000,9999)local CH=gg.prompt({'[cHeapumanVerification] Input this number to make sure that you\\'re human: '..tmp},nil,{'text'})if not CH or tonumber(CH[1]) ~= tmp then print('".._g.cfg.obfOpts.text.failInvalidPW.."')os.exit()end CH=nil"end,
--x_cHeaphumanVerify2 = function()return 'local t,r,c={"Apple","Banana","Island/Beach","Cat","Dog","Octopus","Bird","Penguin","Panda","Pizza","Donut","Candy","Tea","Shrimp","Car","House","Rocket","Orange","Lemon","Mushroom","Fox","Flower"},{math.random(1,22),math.random(1,22),math.random(1,22),math.random(1,3)}c=gg.alert("[cHeapumanVerification] Choose the corrent answer by pressing the buttons below.\\nWhat is the meaning of this emoji: "..({"🍎","🍌","🏝","🐈","🐕","🐙","🐦","🐧","🐼","🍕","🍩","🍬","🍵","🍤","🚗","🏘","🚀","🍊","🍋","🍄","🦊","🌻"})[r[r[4]]],t[r[1]],t[r[2]],t[r[3]])if not c or r[4]~=c then print("'.._g.cfg.obfOpts.text.failInvalidPW..'")os.exit()end'end,
}
_g.enc_wrap_XOR = function(key)
_g.dec_wrap_XOR = _g.dec_wrap_XOR(key)
local key = {key:byte(0,-1)}
return function(str)
-- don't encrypt if nothing gets passed
str = tostring(str)
if str == '' then return [[""]] end
str = {str:byte(0,-1)}
for i=1,#str do
str[i] = string.char(str[i] ~ key[(i % #key) + 1])
end
-- parenthesis around decode is to prevent parsing error in cases like: `return'a'` > `returndecode(..)`
return '(decode([==['..table.concat(str)..']==]))'
end
end
_g.cfg.enc = _g.enc_wrap_XOR
_g.cfg.xdenc = _g.xdenc_XOR -- this means XOR Enc.. Dec..
_g.cfg.dec_wrap_factory = _g.dec_wrap_XOR
--————————————————————————————————--
--— Core functions ———————————————--
function _g.MENU()
local CH = gg.choice({
"🔐 1. Encrypt Lua",
"🔑 2. Decrypt Lua",
"🔨 3. (De)compile Lua",
"⚫ 4. Hide compiled Lua bytecodes",
"⛏️ 5. (Dis)assemble Lua",
"🩹️ 6. Bytecode Patches",
"🩹️ 7. LASM Patches",
"💉 8. Inject code to compiled script",
"📦 9. Containerize script",
"__about__",
"__exit__",
},nil,"ABJ4403's LuaTools ".._g.cfg.VERSION)
if CH == 1 then _g.wrapper_encryptLua()
elseif CH == 2 then _g.wrapper_decryptLua()
elseif CH == 3 then _g.wrapper_compileLua()
elseif CH == 4 then _g.wrapper_hideLuaBytecode()
elseif CH == 5 then _g.wrapper_luacAssembly()
elseif CH == 6 then _g.wrapper_bytecodePatches()
elseif CH == 7 then _g.wrapper_lasmPatches()
elseif CH == 8 then _g.wrapper_injectCodeToLuac()
elseif CH == 9 then _g.wrapper_secureRun()
elseif CH == 10 then _g.MENU_about()
elseif CH == 11 then
gg.setVisible(true)
--[[print("[D] Debugging mode.")
for i in pairs(_G) do
print("[D] _G."..i)
end
for i in pairs(_ENV) do
print("[D] _ENV."..i)
end]]
print("[+] Script quit safely.")
os.exit()
end
end
function _g.MENU_about()
local CH = gg.choice({
"__about__",
"Features",
"License",
"Credits",
"Encryption test",
"__back__"
},nil,"ABJ4403's LuaTools ".._g.cfg.VERSION)
if CH == 1 then
gg.alert("ABJ4403's LuaTools v".._g.cfg.VERSION..[[ © 2022-2024
Manage your Lua scripts on the go!
Why did i make this?
Just to make my life (maybe yours too) easier. and not having to install other proprietary APKs, executables, or even proprietary decryptor/encryptor that can only do one thing and its worst at the same time (eg: PG Encrypt, but no way to decrypt it in the same place, and vice versa. And also there's lots of proprietary gg Lua script out there. maybe you want to clean its garbage code so it can run faster? or run in in secure isolated environment so you can have a peace of mind knowing the files on your phone wont get removed by mallicious `os.remove` API call, or overwriting your files using `io.open/write/read` API call, or executing mallicious commands using `os.execute` API, or you dont want your data to get stolen using `gg.makeRequest` API? Maybe you also wanted to encrypt the script in the correct way because you wanted to share a script, but also realized that your script is too much risky to share to public because you dont want bad cheater (aka. the abuser) uses too much out of your script to hurt other online players? Or you need that little extra tiny SPEED by precompiling the source script and removing its hidden garbage code too.
I created this under 24 hour (on a phone btw!) as a challenge :D So it would be really appreciated if you can contribute to LuaTools GitHub repository (once the script has been open-sourced: https://github.com/ABJ4403/LuaTools) or give a star to my project on GitHub. or simply credit my work (by not removing mentions about me and others in this script :) Thank you :D
]]) _g.MENU_about()
elseif CH == 2 then gg.alert([[Features:
+ Simple, no bloat (no blingy nonsense, no fake loading).
+ Always FOSS (Free and Open-source), Licensed under GPL v3
+ Easy to understand.
+ Basic (De?)Compile, and (Dis)Assemble available (think of it like "pocket" luac semi-unluac).
+ Encryption:
+ Obfuscation modules (no one has EVER seen this concept):
+ Encryptor signature, and promote yourself.
+ Restrict GG (minimal) version and package name.
+ Restrict target application package.
+ Expiry date.
+ Detect Decrypt-related packages.
+ Detect external modification.
+ No Rename.
+ Anti SSTool (a normal function but breaks SSTool).
+ HBX VPN Simple Obfuscation.
+ Hook detection.
+ Password (with optional save hashed password).
+ Welcome (runs after putting correct password).
+ AntiLoad (calls load API with bogus function).
+ NoPeek (Prevent peeking at search values).
+ Spam Log.
+ BigLASM (makes it less convenient to disassemble the script).
+ "Human verification", useless but who knows someone wants it for "maximum security".
+ Interchangable encryption methods (if you know how to code Lua, and if this script is FOSS or not...).
+ Every obfuscation code is containerized, which is great for performance, security, and reduces global variable pollution.
+ Encrypted API query.
+ High performance (No fake loading, great optimization, automagic local variable use).
. (TODO) Optional Hard-Password requirement (with XOR encryption, we can use the password itself as a decryption key)
+ Not only "Free as in price", but also "Free as in Freedom". built-in hard-coded configuration allows you to tinker which encryption/obfuscation module suits your needs :D (not for now...)
+ Respects the user, both the author and the end user (not yet, because the code isnt FOSS yet).
+ Decryption:
+ Deobfuscation patches (again no one has ever seen this):
+ Remove LASM Block.
+ Remove Garbage.
+ Remove Code hider? (unstable).
+ Remove blocker.
+ Remove nonsenses (experiment).
+ Run script in isolated environment.
+ Powered by VirtGG and some Script Compiler 3.7.
+ Protect your device from unwanted script modification (os.execute,os.remove,gg.makeRequest,etc).
. Grab a password from basic pwall script (untested).
. Run script with different version/package name.
+ Remove BigLASM (untested, because i got no real example to test against).]]) _g.MENU_about()
elseif CH == 3 then gg.alert("License:\nLuaTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\n\nLuaTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with LuaTools. If not, see https://gnu.org/licenses\n\n"..[[VirtGG License (proprietary for an early development version for abuse reason):
VirtGG © 2022-2024 ABJ4403, End User License Agreement.
You are allowed to:
- Use it in a respectful manner and good intentions.
You are NOT ALLOWED TO:
- Redistribute the code.
- Reverse-engineer the code.
- Include it in your project.
All rights reserved.]]) _g.MENU_about()
elseif CH == 4 then gg.alert("Credits:\n• ABJ4403 - Original creator.\n• Veyron, HBXVPN - Obfuscation codes.\n• Enyby - For some portion of Script Compiler 3.7 source codes (specifically the dump input field).\n• SwinXTools - for Remove LASM Block deobfuscation codes.\n• Daddyaaaaaaa - for Remove blocker 1 deobfuscation codes.\n• LuaGGEG, Angela, MafiaWar - for Remove BigLASM code.") _g.MENU_about()
elseif CH == 5 then gg.alert([=====[ ——— Encryption test ———
Texts below shouldn't look jumbled up.
Encrypted table queries test:
- gg.searchNumber(5,gg.TYPE_WORD)
- gg.getResults(9)
Anti exit detection test:
- os.exit()
String encryption test:
- 'Hello world!'
- \"Hello world!\"
- [[Test]]
- [=[Test]=]
- [==[Test]==]
- [===[Test]===]
- [====[Test]====]
Annotation test:
-- Hello World!
--[[Hello World!]]
--[==[Hello World!]==]
——— End of encryption test ———]=====]) _g.MENU_about()
elseif CH == 6 then _g.MENU() end
end
function _g.wrapper_encryptLua()
local CH = gg.prompt(
{
'📂 Input File (make sure the extension is .lua):', -- 1
'🧹 Strip \45\45\91\61\61\91 annotations \93\61\61\93 (should be safe if you don\'t use inline annotation inside string)', -- ik this looks weird, but its to avoid getting wiped by encryptor XD
'🔀️ Encrypt strings (Experimental, should be safe if you don\'t use escaped quotation mark)',
'🔀️ Encrypt table queries (rarely quirky)',
'🔐 ️Password', -- 5
'🔐️ Only ask password for once',
'🗓️ Expiry Date (in YYYYMMDD format)',
'⚙️ GG package',
'⚙️ Target package',
'⚙️ GG version requirement (blank to not use)', -- 10
'⚙️ Minimum GG build version requirement (blank to not use)',
'⚙️ Allow newer versions (only works with build number)',
'===== ADVANCED OPTIONS: =====\n\n\n\n\n💬️️ Promotional text (eg. Follow, Sub to YT channel), shown in Lua binary', -- 13
'💬️️ Ask password',
'💬️️ Wrong password', -- 15
'💬️️ Wrong Target Package',
'💬️️ Expired message',
'💬️️ Denied packages',
'💬️️ Wrong GG Version',
'💬️️ GG Version below', -- 20
'💬️️ Hook Detected',
'💬️️ Illegal Modification',
'💬️️ Log Detected',
'💬️️ Renamed',
'💬️️ Warn Value Peeking', --25
},
{
_g.cfg.fileChoice,-- 1
_g.cfg.obfOpts.stripAnnotations,
_g.cfg.obfOpts.encryptStrings,
_g.cfg.obfOpts.encryptTables,
_g.cfg.obfOpts.scriptPW, -- 5
_g.cfg.obfOpts.savePW,
_g.cfg.obfOpts.scriptExpiry,
_g.cfg.obfOpts.ggPkg,
_g.cfg.obfOpts.appPkg,
_g.cfg.obfOpts.minGGVer, -- 10
_g.cfg.obfOpts.minGGBuildVer,
_g.cfg.obfOpts.allowNewGGBuildVer,
--
_g.cfg.obfOpts.text.promoteYourself,
_g.cfg.obfOpts.text.inputPass,
_g.cfg.obfOpts.text.failInvalidPW, -- 15
_g.cfg.obfOpts.text.failAppPkgInvalid,
_g.cfg.obfOpts.text.failDatePassed,
_g.cfg.obfOpts.text.failDeniedPkgs,
_g.cfg.obfOpts.text.failGGPkgInvalid,
_g.cfg.obfOpts.text.failGGVerBelow, -- 20
_g.cfg.obfOpts.text.failHookDetected,
_g.cfg.obfOpts.text.failIllegalMod,
_g.cfg.obfOpts.text.failLogDetected,
_g.cfg.obfOpts.text.failRenamed,
_g.cfg.obfOpts.text.warnPeeking, -- 25
},
{
'file', -- 1
'checkbox',
'checkbox',
'checkbox',
'text', -- 5
'checkbox',
'number',
'text',
'text',
'text', -- 10
'text',
'checkbox',
--
'text',
'text',
'text', -- 15
'text',
'text',
'text',
'text',
'text', -- 20
'text',
'text',
'text',
'text',
'text', -- 25
}
);
if CH and CH[1] then
gg.toast("Encrypting, Please wait... this will take maximum of couple seconds")
_g.cfg.fileChoice = CH[1]:gsub(".lua$",'')
_g.cfg.obfOpts.stripAnnotations = CH[2]
_g.cfg.obfOpts.encryptStrings = CH[3]
_g.cfg.obfOpts.encryptTables = CH[4]
_g.cfg.obfOpts.scriptPW = CH[5]
_g.cfg.obfOpts.savePW = CH[6]
_g.cfg.obfOpts.scriptExpiry = CH[7]
_g.cfg.obfOpts.ggPkg = CH[8]
_g.cfg.obfOpts.appPkg = CH[9]
_g.cfg.obfOpts.minGGVer = CH[10]
_g.cfg.obfOpts.minGGBuildVer = CH[11]
_g.cfg.obfOpts.allowNewGGBuildVer = CH[12]
--
_g.cfg.obfOpts.text.promoteYourself = CH[13]
_g.cfg.obfOpts.text.inputPass = CH[14]
_g.cfg.obfOpts.text.failInvalidPW = CH[15]
_g.cfg.obfOpts.text.failAppPkgInvalid = CH[16]
_g.cfg.obfOpts.text.failDatePassed = CH[17]
_g.cfg.obfOpts.text.failDeniedPkgs = CH[18]
_g.cfg.obfOpts.text.failGGPkgInvalid = CH[19]
_g.cfg.obfOpts.text.failGGVerBelow = CH[20]
_g.cfg.obfOpts.text.failHookDetected = CH[21]
_g.cfg.obfOpts.text.failIllegalMod = CH[22]
_g.cfg.obfOpts.text.failLogDetected = CH[23]
_g.cfg.obfOpts.text.failRenamed = CH[24]
_g.cfg.obfOpts.text.warnPeeking = CH[25]
_g.encryptLua()
print("[✔] Finished encrypting ".._g.cfg.fileChoice.."!\n[+] Input File: ".._g.cfg.fileChoice..".lua\n[+] Output File: ".._g.cfg.fileChoice..".enc.lua")
end
end
function _g.wrapper_decryptLua()
local opts1 = gg.prompt({
"Input decompiled script (make sure the file extension is .dec1.lua, IMPORTANT: code must be formatted properly!!!)",
"Encryptor used to encrypt the script\n1. General (tries to deobfuscate some codes, eg. string.char)\n2. ABJ4403's LuaTools [1;2]",
},{
_g.cfg.fileChoice,
1,
},{
"file",
"number",
})
if opts1 then
-- here should open 1st file and decrypt based on 2nd choice
opts1[1] = opts1[1]:gsub(".dec1.lua$",'')
opts1[2] = tonumber(opts1[2])
_g.cfg.fileChoice = opts1[1]
local opts2
if opts1[2] == 1 then
opts2 = gg.prompt({
"Decryptor specific options:\n\nPasses (higher may get better result, but takes slightly longer) [1;5]",
},{""},{
"number",
})
end
if opts2 then
gg.toast("Decrypting, Please wait... this will take maximum of couple seconds")
_g.DATA = _g.io_readFile(_g.cfg.fileChoice..'.dec1.lua')
_g.decryptLua({
inputFile=opts1[1],
encryptorUsed=opts1[2],
decryptorOpts=opts2
})
_g.io_writeFile(_g.cfg.fileChoice..'.dec2.lua',_g.DATA)
print("[✔] Finished decrypting ".._g.cfg.fileChoice.."!\n[+] Input File: ".._g.cfg.fileChoice..".dec1.lua\n[+] Output File: ".._g.cfg.fileChoice..".dec2.lua")
end
end
end
function _g.wrapper_hideLuaBytecode()
local CH = gg.prompt(
{
'This function is EXPERIMENTAL! This will try to hide the actual Lua bytecode by putting it at the end of new Lua bytecode so that when recompiled, its gone\n📂 Input File (make sure the extension is .lua, and its already compiled):', -- 1
},
{
_g.cfg.fileChoice,-- 1
},
{
'file', -- 1
}
);
if CH and CH[1] then
gg.toast("Hiding Lua bytecodes...")
print("[i] Hiding Lua bytecodes...")
_g.cfg.fileChoice = CH[1]:gsub(".lua$",'')
_g.hideLuaBytecode()
print("[✔] Finished hiding bytecode ".._g.cfg.fileChoice.."!\n[+] Input File: ".._g.cfg.fileChoice..".lua\n[+] Output File: ".._g.cfg.fileChoice..".bytecodeHidden.lua")
gg.toast("[✔] Encryption complete.")
end
end
function _g.wrapper_compileLua()
-- Ask user for file...
local CH = gg.prompt({
'📂 Input File (make sure the extension is .lua):',
'Strip debugging symbol (not recommended)',
'Preserve namespaces',
'Decompile (TODO-LoPrio,Waiting)'
},{_g.cfg.fileChoice,false,true,false},{'file','checkbox','checkbox','checkbox'});
if CH and CH[1] then
gg.toast("Compiling, Please wait... this will take maximum of couple seconds")
CH[1] = CH[1]:gsub(".lua$",'')
_g.cfg.fileChoice = CH[1]
_g.compileLua(".luac",CH[2],CH[3])
print("[✔] Finished Compiling "..CH[1].."!\n[+] Input File: "..CH[1]..".lua\n[+] Output File: "..CH[1]..".luac")
gg.toast("Compiling complete.")
end
end
function _g.wrapper_luacAssembly()
-- Ask user for file...
local CH = gg.prompt({
'📂 Input File (make sure the extension is either .luac/.lasm):',
'Assemble'
},{_g.cfg.fileChoice,false},{'file','checkbox'});
if CH and CH[1] then
CH[1] = CH[1]:gsub("%.luac$",''):gsub("%.lasm$",'')
if CH[2] == true then
gg.toast("Assembling, please wait...")
_g.cfg.fileChoice = CH[1]
_g.assembleLua(false)
print("[+] Finished Assembling!\n | Input: "..CH[1]..".lasm\n | Output: "..CH[1]..".luac")
gg.toast("Assembling finished!")
else
gg.toast("Disassembling, please wait...")
_g.cfg.fileChoice = CH[1]
_g.disassembleLua('.luac',false)
print("[+] Finished Disassembling!\n | Input: "..CH[1]..".luac\n | Output: "..CH[1]..".lasm")
gg.toast("Disassembling finished!")
end
end
end
function _g.wrapper_bytecodePatches()
local CH = gg.prompt({
'📂 Input File (make sure the extension is .enc.lua):',
'Remove BigLASM (long string that makes lasm big)',
'Remove anti disassemble',
'Fix header (BTW i recommend reassemble the script instead of fixing the header)',
},
{
_g.cfg.fileChoice,
true,
false,
true,
},{
'file',
'checkbox',
'checkbox',
'checkbox',
});
if CH and CH[1] then
-- Bytecode Patching
_g.cfg.fileChoice = CH[1]:gsub("%.enc%.lua$",'')
_g.DATA = _g.io_readFile(_g.cfg.fileChoice..".enc.lua")
if CH[2] then gg.toast("Running selected operations... 1/?") _g.patchBytecode("bigLasm") print("[✔] bigLasm removed!")end
if CH[3] then gg.toast("Running selected operations... 2/?") _g.patchBytecode("antiDisassemble1") print("[✔] antiDisassemble1 removed!")end
gg.toast("Running selected operations... 3/?")
_g.io_writeFile(
_g.cfg.fileChoice..".bcpatch.lua",
_g.DATA
)
-- uhh didnt modLuaHeader accepts .enc.lua?
if CH[4] then gg.toast("Running selected operations... 4/?") _g.modLuaHeader('LuaFixHeader',".bcpatch.lua") print("[✔] Lua header fixed!")end
print("\n[+] Input File: ".._g.cfg.fileChoice..".lua\n[+] Output File: ".._g.cfg.fileChoice..".bcpatch.lua")
gg.toast("Operation completed!")
end
end
function _g.wrapper_lasmPatches()
local CH = gg.prompt({
'📂 Input File (make sure the extension is .enc.lua/.lasm, will directly write to lasm if using that extension):', -- 1
'Remove Garbage (recommended)', -- 3
'Remove "Code Hider" (TODO: still poor translation)', -- 4
'Remove Lasm Block (enable if you cant disassemble the script, disable if you got ArrayOutOfBound error when running the script)', -- 5
'Unblock 1 (by Daddyaaaaaaa)', -- 6
"Remove some JMP Obfuscations", -- 7
'Remove ABJ4403\'s encryption to some extent', -- 8
},{
_g.cfg.fileChoice,
true,false,false, -- 234
false,false,false -- 567
},{
'file',
'checkbox','checkbox','checkbox',
'checkbox','checkbox','checkbox'
});
if CH and CH[1] then
local isAsmFile = CH[1]:match('.lasm$')
CH[1] = isAsmFile and CH[1]:gsub(".lasm$",'') or CH[1]:gsub(".enc.lua$",'')
_g.cfg.fileChoice = CH[1]
-- Assembly Patching
_g.DATA = isAsmFile and _g.io_readFile(_g.cfg.fileChoice..".lasm") or _g.disassembleLua('.enc.lua',true)
gg.toast("Running selected operations... 1/10") _g.patchAssembly("EssentialMinify")
if _g.cfg.debugMode then _g.io_writeFile(_g.cfg.fileChoice..".dbg.lasm",_g.DATA) end
if CH[2] then gg.toast("Running selected operations... 2/10") _g.patchAssembly("RemoveGarbage") print("[✔] Garbages removed!")end
if CH[7] then gg.toast("Running selected operations... 3/10") _g.patchAssembly("selfDecrypt") print("[✔] Self decrypted! (some)")end
if CH[3] then gg.toast("Running selected operations... 4/10") _g.patchAssembly("RemoveCodeHider") print("[✔] Hide codes removed!")end
if CH[4] then gg.toast("Running selected operations... 5/10") _g.patchAssembly("RemoveLasmBlock") print("[✔] LasmBlock Removed!")end
if CH[5] then gg.toast("Running selected operations... 6/10") _g.patchAssembly("RemoveBlocker1") print("[✔] Blockers patched!")end
if CH[6] then gg.toast("Running selected operations... 8/10") _g.patchAssembly("JmpObf") print("[✔] Removed JMP Obfuscations!")end
--8
gg.toast("Running selected operations... 9/10")
_g.io_writeFile(_g.cfg.fileChoice..".lasm",_g.DATA)
if isAsmFile then print('[i] Lua Assembly file format detected, script will not be compiled.') else _g.assembleLua(true) end
print("\n[+] Input File: ".._g.cfg.fileChoice..".enc.lua\n[+] Output File: ".._g.cfg.fileChoice..".luac")
gg.toast("Operation completed!")
end
end
function _g.wrapper_injectCodeToLuac()
-- Warning: Unstable PoC
-- And lots of things didnt work
local CH = gg.prompt({
'📂 Input Target script (make sure the extension is .lua/.lasm, and make sure to backup your script because this may overwrite the script you chosen):',
'📂 Input Injected code (make sure the extension is .lua/.lasm):',
'Set max stack size to 250 (fixes ArrayOutOfBound error)'
},{
_g.cfg.fileChoice,
_g.cfg.fileChoice,
false
},{
'file','file','checkbox',
})
if CH and CH[1] and CH[2] then
-- detect assembly
local isTargetAsmFile = CH[1]:match('.lasm$')
local isInjectAsmFile = CH[2]:match('.lasm$')
-- strip names and stuff
CH[1] = isTargetAsmFile and CH[1]:gsub(".lasm$",'') or CH[1]:gsub(".lua$",'')
CH[2] = isInjectAsmFile and CH[2]:gsub(".lasm$",'') or CH[2]:gsub(".lua$",'')
local INJECTED_CODE = ''
-- Disassemble
gg.toast("Disassembling...")
_g.cfg.fileChoice = CH[1]
_g.DATA = isTargetAsmFile and _g.io_readFile(CH[1]..".lasm") or _g.disassembleLua('.lua',true)
_g.cfg.fileChoice = CH[2]
INJECTED_CODE = isInjectAsmFile and _g.io_readFile(CH[2]..".lasm") or _g.disassembleLua('.lua',true)
_g.cfg.fileChoice = CH[1]
-- Cleanup assembly code
gg.toast("Cleaning assembly codes...")
for j=1,#_g.cfg.lasmPatches.EssentialMinify do
_g.DATA = _g.DATA:gsub(_g.cfg.lasmPatches.EssentialMinify[j][1],_g.cfg.lasmPatches.EssentialMinify[j][2])
INJECTED_CODE = INJECTED_CODE:gsub(_g.cfg.lasmPatches.EssentialMinify[j][1],_g.cfg.lasmPatches.EssentialMinify[j][2])
end
-- stuff
local ggAssemblyHeader = {
'; --[=========[ Lua assembler file generated by GameGuardian '..gg.VERSION..' ('..gg.BUILD..')\n',
"; ]=========] gg.require('"..gg.VERSION.."', "..gg.BUILD..")"
}
-- remove comments, beginning .line, avoid variable collision
gg.toast("Removing comments, beginning .line, avoid collision...")
INJECTED_CODE = INJECTED_CODE:gsub(' ;.-\n','\n'):gsub(';.-\n','\n')
INJECTED_CODE = INJECTED_CODE:gsub('\n%.line %d-\n','\n')
INJECTED_CODE = INJECTED_CODE:gsub(':goto_',':inject_')
INJECTED_CODE = INJECTED_CODE:gsub(' F(%d-)',' Injected%1')
-- Split instructions and functions
gg.toast("Splitting instruction & funcs...1")
_g.DATA = _g.splitLuaAssembly(_g.DATA)
gg.toast("Splitting instruction & funcs...2")
INJECTED_CODE = _g.splitLuaAssembly(INJECTED_CODE)
-- Fix ArrayOutOfBounds error (TODO: can we calculate the real value instead??)
if CH[3] then
--idea:
--how about if we match v255 all the way to v0
--and if one of them found, use that + 1
_g.DATA[1] = _g.DATA[1]:gsub('\n%.maxstacksize %d-\n','\n.maxstacksize 250\n',1)
end
-- remove RETURN after function (if not removed, the script will just quit :/)
gg.toast("Fixes...")
INJECTED_CODE[2] = INJECTED_CODE[2]:gsub('\nRETURN','',1)
-- Code optimization (only if the codes starts with `FunctionName()`)
INJECTED_CODE[2] = INJECTED_CODE[2]:gsub(
'\nCLOSURE v(%d-) (.-)\nSETTABUP u(%d-) (.-) v(%d-)\nGETTABUP v(%d-) u(%d-) (.-)\nCALL v(%d-)..v(%d-)\n',
function(v1,f, u1,f1,v2, v3,u2,f2, v4,v5)
return (f1 == f2 and u1 == u2 and (v1 == v2 and v1 == v3 and v1 == v4 and v1 == v5)) and
('\nCLOSURE v%d %s\nCALL v%d..v%d\n'):format(v1,f,v4,v5) or
('\nCLOSURE v%d %s\nSETTABUP u%d %s v%d\nGETTABUP v%d u%d %s\nCALL v%d..v%d\n'):format(v1,f,u1,f1,v1,v3,u2,f2,v4,v5)
end
)
-- Combine the script in these orders:
-- GG LASM Header, Source, Injected instructions, Target instructions, Target functions, Injected functions, GG LASM Header
_g.DATA =
ggAssemblyHeader[1]..'\n'..
_g.DATA[1]..'\n'..
INJECTED_CODE[2]..'\n'..
_g.DATA[2]..'\n'..
_g.DATA[3]..'\n'..
INJECTED_CODE[3]..'\n'..
ggAssemblyHeader[2]
ggAssemblyHeader = nil
INJECTED_CODE = nil
-- Assemble Lua
_g.io_writeFile(_g.cfg.fileChoice..".lasm",_g.DATA)
if isTargetAsmFile then print('[i] Lua Assembly file format detected, script will not be compiled.') else _g.assembleLua(true) end
-- Completed
print("\n[+] Input File: ".._g.cfg.fileChoice..".lua\n[+] Output File: ".._g.cfg.fileChoice..".luac")
gg.toast("Operation completed!")
end
end
function _g.wrapper_secureRun()
local opts = gg.prompt({
"📂 Script:", -- 1
"📂 Wrapper script (commonly used for other modifications):", -- 2
"❌️ Disable mallicious functions", -- 3
"🛡️ Run security tests (if 3rd option enabled)", -- 4
"⚠️ Exit if security tests fail (if 3rd + 4th option enabled)", -- 5
"📜️ Dump function calls", -- 6
"📜️ Dump load calls", -- 7
"📜️ Dump input strings (commonly used to extract password, leave blank to disable)", -- 8
"🖊️ GG Version", -- 9
"🖊️ GG Version int", -- 10
"🖊️ GG Build", -- 11
"🖊️ GG Package", -- 12
"🖊️ GG Target Package", -- 13
"📜️ Minimum size to log `load()` API (TODO)", -- 14
"📜 Verbose log (TODO)", -- 15
"📜 Quieten log (TODO)", -- 16
"📜 Print log (TODO)", -- 17
"📜 Dump log (You can use os.date formatting in here. TODO)", -- 18
},{
_g.cfg.fileChoice, -- 1
nil, -- 2
true, -- 3
true, -- 4
true, -- 5
true, -- 6
false, -- 7
false, -- 8
gg.VERSION, -- 9
gg.VERSION_INT, -- 10
gg.BUILD, -- 11
gg.PACKAGE, -- 12
gg.getTargetPackage(), -- 13
400, -- 14
false, -- 15
false, -- 16
true, -- 17
_g.cfg.scriptPath..'/ScriptLog_%y.%m.%d_%H.%M.log', -- 18
},{
"file", -- 1
"file", -- 2
"checkbox", -- 3
"checkbox", -- 4
"checkbox", -- 5
"checkbox", -- 6
"checkbox", -- 7
"checkbox", -- 8
"text", -- 9
"number", -- 10
"number", -- 11
"text", -- 12
"text", -- 13
"number", -- 14
"checkbox", -- 15
"checkbox", -- 16
"checkbox", -- 17
"text", -- 18
})
if opts and opts[1] then
_g.secureRun({
targetScript=opts[1],
wrapScript=opts[2],
disableMalFn=opts[3],
runTests=opts[4],
exitIfTestsFail=opts[5],
dumpCalls=opts[6],