Skip to content

Commit d0156ff

Browse files
committed
Move debug.traceback to useDebug
1 parent 09a41a4 commit d0156ff

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/prometheus/steps/AntiTamper.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function AntiTamper:apply(ast, pipeline)
3535
end
3636
local code = "do local valid = true;";
3737
if self.UseDebug then
38+
local string = RandomStrings.randomString();
3839
code = code .. [[
3940
-- Anti Beautify
4041
local sethook = debug and debug.sethook or function() end;
@@ -64,28 +65,27 @@ function AntiTamper:apply(ast, pipeline)
6465
valid = false;
6566
end
6667
end
68+
69+
-- Anti Beautify
70+
local function getTraceback()
71+
local str = (function(arg)
72+
return debug.traceback(arg)
73+
end)("]] .. string .. [[");
74+
return str;
75+
end
76+
77+
local traceback = getTraceback();
78+
valid = valid and traceback:sub(1, traceback:find("\n") - 1) == "]] .. string .. [[";
79+
local iter = traceback:gmatch(":(%d*):");
80+
local v, c = iter(), 1;
81+
for i in iter do
82+
valid = valid and i == v;
83+
c = c + 1;
84+
end
85+
valid = valid and c >= 2;
6786
]]
6887
end
69-
local string = RandomStrings.randomString();
7088
code = code .. [[
71-
-- Anti Beautify
72-
local function getTraceback()
73-
local str = (function(arg)
74-
return debug.traceback(arg)
75-
end)("]] .. string .. [[");
76-
return str;
77-
end
78-
79-
local traceback = getTraceback();
80-
valid = valid and traceback:sub(1, traceback:find("\n") - 1) == "]] .. string .. [[";
81-
local iter = traceback:gmatch(":(%d*):");
82-
local v, c = iter(), 1;
83-
for i in iter do
84-
valid = valid and i == v;
85-
c = c + 1;
86-
end
87-
valid = valid and c >= 2;
88-
8989
local gmatch = string.gmatch;
9090
local err = function() error("Tamper Detected!") end;
9191

0 commit comments

Comments
 (0)