Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ build

# Ignore Local Test Files
test.lua
test.obfuscated.lua
test.obfuscated.lua
config.lua
3 changes: 0 additions & 3 deletions src/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
-- config.lua
--
-- In this Script, some Global config Variables are defined
-- These may be changed

-- You are not allowed to change the following Variables
local NAME = "Prometheus";
local REVISION = "Alpha";
local VERSION = "v0.2";
Expand All @@ -29,7 +27,6 @@ return {
NameAndVersion = string.format("%s %s", NAME, VERSION),
Version = VERSION;
Revision = REVISION;
Watermark = string.format("Obfuscated using %s %s %s by %s", NAME, REVISION, VERSION, BY); -- You are not allowed to edit the watermark
-- Config Starts Here
IdentPrefix = "__prometheus_"; -- The Prefix used for Identifiers generated by PROMETHEUS. NOTE: There should be no identifiers in the script to be obfuscated starting with that prefix, because that can lead to weird bugs

Expand Down
2 changes: 1 addition & 1 deletion src/prometheus/ast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ function Ast.MulExpression(lhs, rhs, simplify)
end

function Ast.DivExpression(lhs, rhs, simplify)
if(simplify and rhs.isConstant and lhs.isConstant) then
if(simplify and rhs.isConstant and lhs.isConstant and rhs.value ~= 0) then
local success, val = pcall(function() return lhs.value / rhs.value end);
if success then
return Ast.ConstantNode(val);
Expand Down
10 changes: 3 additions & 7 deletions src/prometheus/compiler/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ function Compiler:compileStatement(statement, funcDepth)
self:addStatement(self:setRegister(scope, tmpReg, Ast.IndexExpression(self:register(scope, baseReg), self:register(scope, tmpReg))), {tmpReg}, {tmpReg, baseReg}, false);

self:addStatement(self:setRegister(scope, tmpReg, Ast.FunctionCallExpression(self:register(scope, tmpReg), args)), {tmpReg}, {tmpReg, unpack(regs)}, true);
self:freeRegister(baseReg, false);

self:freeRegister(tmpReg, false);
for i, reg in ipairs(regs) do
self:freeRegister(reg, false);
Expand Down Expand Up @@ -2004,9 +2004,6 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
end
end




self:freeRegister(baseReg, false);
for i, reg in ipairs(regs) do
self:freeRegister(reg, false);
Expand Down Expand Up @@ -2052,9 +2049,9 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
self:addStatement(self:setRegister(scope, tmpReg, Ast.IndexExpression(self:register(scope, baseReg), self:register(scope, tmpReg))), {tmpReg}, {baseReg, tmpReg}, false);

if returnAll then
self:addStatement(self:setRegister(scope, retRegs[1], Ast.TableConstructorExpression{Ast.TableEntry(Ast.FunctionCallExpression(self:register(scope, tmpReg), args))}), {retRegs[1]}, {baseReg, unpack(regs)}, true);
self:addStatement(self:setRegister(scope, retRegs[1], Ast.TableConstructorExpression{Ast.TableEntry(Ast.FunctionCallExpression(self:register(scope, tmpReg), args))}), {retRegs[1]}, {tmpReg, unpack(regs)}, true);
else
self:addStatement(self:setRegister(scope, tmpReg, Ast.TableConstructorExpression{Ast.TableEntry(Ast.FunctionCallExpression(self:register(scope, tmpReg), args))}), {tmpReg}, {baseReg, unpack(regs)}, true);
self:addStatement(self:setRegister(scope, tmpReg, Ast.TableConstructorExpression{Ast.TableEntry(Ast.FunctionCallExpression(self:register(scope, tmpReg), args))}), {tmpReg}, {tmpReg, unpack(regs)}, true);

for i, reg in ipairs(retRegs) do
self:addStatement(self:setRegister(scope, reg, Ast.IndexExpression(self:register(scope, tmpReg), Ast.NumberExpression(i))), {reg}, {tmpReg}, false);
Expand All @@ -2071,7 +2068,6 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
self:addStatement(self:setRegister(scope, retRegs[1], Ast.FunctionCallExpression(self:register(scope, tmpReg), args)), {retRegs[1]}, {baseReg, unpack(regs)}, true);
end

self:freeRegister(baseReg, false);
for i, reg in ipairs(regs) do
self:freeRegister(reg, false);
end
Expand Down
2 changes: 0 additions & 2 deletions src/prometheus/pipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ function Pipeline:apply(code, filename)

logger:info(string.format("Generated Code size is %.2f%% of the Source Code size", (string.len(code) / sourceLen)*100))

code = "--[[\n " .. config.Watermark .. "\n]]\n" .. code;

return code;
end

Expand Down
2 changes: 0 additions & 2 deletions src/prometheus/steps/AntiTamper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ end
repeat until valid;
]]

print(code);

local parsed = Parser:new({LuaVersion = Enums.LuaVersion.Lua51}):parse(code);
local doStat = parsed.body.statements[1];
doStat.body.scope:setParent(ast.body.scope);
Expand Down