Skip to content

Commit b3537c1

Browse files
committed
Add Break Beautify Step
1 parent 8c9a84c commit b3537c1

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
-- This Script is Part of the Prometheus Obfuscator by Levno_710
2+
--
3+
-- BreakBeautify.lua
4+
--
5+
-- This Script provides an Obfuscation Step, that breaks the script when beautified
6+
7+
local Step = require("prometheus.step");
8+
local Ast = require("prometheus.ast");
9+
local Scope = require("prometheus.scope");
10+
local RandomStrings = require("prometheus.randomStrings")
11+
local Parser = require("prometheus.parser");
12+
local Enums = require("prometheus.enums");
13+
local logger = require("logger");
14+
15+
local BreakBeautify = Step:extend();
16+
BreakBeautify.Description = "This Step Breaks your Script when it is beautified. This is only effective when using the new VM.";
17+
BreakBeautify.Name = "Break Beautify";
18+
19+
BreakBeautify.SettingsDescriptor = {
20+
21+
}
22+
23+
function BreakBeautify:init(settings)
24+
25+
end
26+
27+
function BreakBeautify:apply(ast, pipeline)
28+
if pipeline.PrettyPrint then
29+
logger:warn(string.format("\"%s\" cannot be used with PrettyPrint, ignoring \"%s\"", self.Name, self.Name));
30+
return ast;
31+
end
32+
local code = [[
33+
do
34+
local gmatch = string.gmatch;
35+
local err = function() error("Beautify Detected!") end;
36+
37+
local pcallIntact2 = false;
38+
local pcallIntact = pcall(function()
39+
pcallIntact2 = true;
40+
end) and pcallIntact2;
41+
42+
local _1, s1 = pcall(function() local a = ]] .. tostring(math.random(1, 2^24)) .. [[ - "]] .. RandomStrings.randomString() .. [[" ^ ]] .. tostring(math.random(1, 2^24)) .. [[ return "]] .. RandomStrings.randomString() .. [[" / a; end)
43+
local m1 = gmatch(tostring(s1), ':(%d*):')()
44+
local l1 = tonumber(m1)
45+
46+
local _2, s2 = pcall(function() local a = ]] .. tostring(math.random(1, 2^24)) .. [[ - "]] .. RandomStrings.randomString() .. [[" ^ ]] .. tostring(math.random(1, 2^24)) .. [[ return "]] .. RandomStrings.randomString() .. [[" / a; end)
47+
local m2 = gmatch(tostring(s2), ':(%d*):')()
48+
local l2 = m2 and {[tonumber(m2)] = true} or {};
49+
if not(_1 or _2) and l2[l1] and pcallIntact then else
50+
repeat
51+
return (function()
52+
while true do
53+
l1, l2 = l2, l1;
54+
err();
55+
end
56+
end)();
57+
until true;
58+
while true do
59+
l2 = math.random(1, 6);
60+
if l2 > 2 then
61+
l2 = tostring(l1);
62+
else
63+
l1 = l2;
64+
end
65+
end
66+
return nil;
67+
end
68+
end
69+
]]
70+
71+
local parsed = Parser:new({LuaVersion = Enums.LuaVersion.Lua51}):parse(code);
72+
local doStat = parsed.body.statements[1];
73+
doStat.body.scope:setParent(ast.body.scope);
74+
table.insert(ast.body.statements, 1, doStat);
75+
76+
return ast;
77+
end
78+
79+
return BreakBeautify;

0 commit comments

Comments
 (0)