diff --git a/src/prometheus/pipeline.lua b/src/prometheus/pipeline.lua index b045aa9..fe21f85 100644 --- a/src/prometheus/pipeline.lua +++ b/src/prometheus/pipeline.lua @@ -133,7 +133,7 @@ function Pipeline:setLuaVersion(luaVersion) luaVersion = luaVersion; }); self.unparser = Unparser:new({ - luaVersion = luaVersion; + LuaVersion = luaVersion; }); self.conventions = conventions; end diff --git a/src/prometheus/step.lua b/src/prometheus/step.lua index 59e6f48..159c91f 100644 --- a/src/prometheus/step.lua +++ b/src/prometheus/step.lua @@ -55,7 +55,7 @@ function Step:new(settings) if data.max then if settingValue > data.max then - logger:error(string.format("Invalid value for the Setting \"%s\" of the Step \"%s\". The biggest allowed value is %d", key, self.Name, data.min)); + logger:error(string.format("Invalid value for the Setting \"%s\" of the Step \"%s\". The biggest allowed value is %d", key, self.Name, data.max)); end end diff --git a/src/prometheus/steps/SplitStrings.lua b/src/prometheus/steps/SplitStrings.lua index c549cd8..060101a 100644 --- a/src/prometheus/steps/SplitStrings.lua +++ b/src/prometheus/steps/SplitStrings.lua @@ -167,7 +167,7 @@ end local function generateCustomFunctionLiteral(parentScope, variant) local parser = Parser:new({ - LuaVersion = LuaVersion.Lua52; + LuaVersion = LuaVersion.Lua51; }); -- Custom Function Type 1 @@ -190,7 +190,7 @@ end local function generateGlobalCustomFunctionDeclaration(ast, data) local parser = Parser:new({ - LuaVersion = LuaVersion.Lua52; + LuaVersion = LuaVersion.Lua51; }); -- Custom Function Type 1 diff --git a/src/prometheus/visitast.lua b/src/prometheus/visitast.lua index 1709885..c7e963d 100644 --- a/src/prometheus/visitast.lua +++ b/src/prometheus/visitast.lua @@ -139,7 +139,7 @@ function visitStatement(statement, previsit, postvisit, data) for i, expression in ipairs(statement.expressions) do statement.expressions[i] = visitExpression(expression, previsit, postvisit, data); end - visitBlock(statement.body, previsit, postvisit, data, false); + statement.body = visitBlock(statement.body, previsit, postvisit, data, false); elseif(statement.kind == AstKind.IfStatement) then statement.condition = visitExpression(statement.condition, previsit, postvisit, data); statement.body = visitBlock(statement.body, previsit, postvisit, data, false); diff --git a/tests.lua b/tests.lua deleted file mode 100644 index 00f229f..0000000 --- a/tests.lua +++ /dev/null @@ -1,171 +0,0 @@ --- This Script is Part of the Prometheus Obfuscator by levno-710 --- --- tests.lua --- --- This Script will Perform tests using all lua files within the tests directory - --- Require Prometheus -local Prometheus = require("src.prometheus") - --- Enable Debugging --- logger.logLevel = logger.LogLevel.Debug; - --- Config Variables - Later passed as Parameters -local noColors = false; -- Whether Colors in the Console output should be enabled -local isWindows = package.config:sub(1, 1) == "\\"; -- Whether the Test are Performed on a Windows or Linux System -local ciMode = false; -- Whether the Test error are ignored or not -local iterationCount = 20; -- How often each test should be executed - -for _, currArg in pairs(arg) do - if currArg == "--Linux" then - isWindows = false - end - if currArg == "--Windows" then - isWindows = true - end - if currArg == "--CI" then - ciMode = true - end - local iterationValue = currArg:match("^%-%-iterations=(%d+)$") - if iterationValue then - iterationCount = math.max(tonumber(iterationValue), 1) - end -end - --- Enable/Disable Console Colors - this may be needed because cmd.exe and powershell.exe do not support ANSI Color Escape Sequences. The Windows Terminal Application is needed -Prometheus.colors.enabled = not noColors; - --- Apply Obfuscation Pipeline -local pipeline = Prometheus.Pipeline:new({ - Seed = 0; -- For Using Time as Seed - VarNamePrefix = ""; -- No Custom Prefix -}); - --- "Mangled" for names like this : a, b, c, d, ... --- "MangledShuffled" is the same except the chars come in a different order - Recommended --- "Il" for weird names like this : IlIIl1llI11l1 - Recommended to make less readable --- "Number" for names like this : _1, _2, _3, ... - Not recommended -pipeline:setNameGenerator("MangledShuffled"); - -local function describePlatform() - return isWindows and "Windows" or "Linux" -end - -print(string.format( - "Performing Prometheus Tests (iterations=%d per file/preset, platform=%s)...", - iterationCount, - describePlatform() -)) -local function scandir(directory) - local i, t, popen = 0, {}, io.popen - local pfile = popen(isWindows and 'dir "'..directory..'" /b' or 'ls -a "'..directory..'"') - if not pfile then - error("Failed to list files in test directory: " .. tostring(directory)) - end - for filename in pfile:lines() do - if string.sub(filename, -4) == ".lua" then - i = i + 1 - t[i] = filename - end - end - pfile:close() - return t -end - -local function shallowcopy(orig) - local orig_type = type(orig) - local copy - if orig_type == 'table' then - copy = {} - for orig_key, orig_value in pairs(orig) do - copy[orig_key] = orig_value - end - else -- number, string, boolean, etc - copy = orig - end - return copy -end - -local function validate(a, b) - local outa = ""; - local outb = ""; - - local enva = shallowcopy(getfenv(a)); - local envb = shallowcopy(getfenv(a)); - - enva.print = function(...) - for _, v in ipairs({...}) do - outa = outa .. tostring(v); - end - end - - envb.print = function(...) - for _, v in ipairs({...}) do - outb = outb .. tostring(v); - end - end - - setfenv(a, enva); - setfenv(b, envb); - - if(not pcall(a)) then error("Expected Reference Program not to Fail!") end - if(not pcall(b)) then return false, outa, nil end - - return outa == outb, outa, outb -end - - -local presets = Prometheus.Presets; -local testdir = "./tests/" -Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error; -local fc = 0; -for _, filename in ipairs(scandir(testdir)) do - local path = testdir .. filename; - local file = io.open(path,"r"); - - local code = file:read("*a"); - print(Prometheus.colors("[CURRENT] ", "magenta") .. filename); - for name, preset in pairs(presets) do - for i = #preset.Steps, 1, -1 do - if preset.Steps[i].Name == "AntiTamper" then - table.remove(preset.Steps, i); - end - end - - for _ = 1, iterationCount do - pipeline = Prometheus.Pipeline:fromConfig(preset); - local obfuscated = pipeline:apply(code); - - local funca = loadstring(code); - local funcb = loadstring(obfuscated); - - if funcb == nil then - print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. "): " .. name .. ", Invalid Lua!"); - print("[SOURCE]", obfuscated); - fc = fc + 1; - else - local validated, outa, outb = validate(funca, funcb); - - if not validated then - print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. "): " .. name); - print("[OUTA] ", outa); - print("[OUTB] ", outb); - print("[SOURCE]", obfuscated); - fc = fc + 1; - end - end - end - end - file:close(); -end - -if fc < 1 then - print(Prometheus.colors("[PASSED] ", "green") .. "All tests passed!"); - return 0; -else - print(Prometheus.colors("[FAILED] ", "red") .. "Some tests failed!"); - if ciMode then - error("Test Failed!") - end - return -1; -end