diff --git a/benchmark.lua b/benchmark.lua
index 5ff09ffb..3c61faba 100644
--- a/benchmark.lua
+++ b/benchmark.lua
@@ -6,7 +6,7 @@ print("Iterations: " .. tostring(Iterations))
print("CLOSURE testing.")
local Start = os.clock()
local TStart = Start
-for Idx = 1, Iterations do
+for _ = 1, Iterations do
(function()
if not true then
print("Hey gamer.")
diff --git a/cli.lua b/cli.lua
index a092ce35..3f0477c6 100644
--- a/cli.lua
+++ b/cli.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
--- test.lua
--- This script contains the Code for the Prometheus CLI
+-- cli.lua
+--
+-- This Script contains the Code for the Prometheus CLI
-- Configure package.path for requiring Prometheus
local function script_path()
diff --git a/doc/getting-started/the-config-object.md b/doc/getting-started/the-config-object.md
index b77a01c9..4df718e3 100644
--- a/doc/getting-started/the-config-object.md
+++ b/doc/getting-started/the-config-object.md
@@ -1,6 +1,6 @@
# The Config Object
-Prometheus takes a configuration objetct. In this object there can be many properties applied. \
+Prometheus takes a configuration object. In this object there can be many properties applied. \
The following table provides an overview:
| Property | type | possible values | default |
@@ -18,21 +18,19 @@ As an example, here is the code for the minify preset:
```lua
{
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- No obfuscation steps
- Steps = {
-
- }
- };
+ -- The default LuaVersion is Lua51
+ LuaVersion = "Lua51";
+ -- For minifying no VarNamePrefix is applied
+ VarNamePrefix = "";
+ -- Name Generator for Variables
+ NameGenerator = "MangledShuffled";
+ -- No pretty printing
+ PrettyPrint = false;
+ -- Seed is generated based on current time
+ Seed = 0;
+ -- No obfuscation steps
+ Steps = {}
+};
```
### Steps
@@ -49,7 +47,7 @@ Steps = {
-- Apply to Strings only
StringsOnly = true;
-- Apply to all Constants, 0.5 would only affect 50% of strings
- Treshold = 1;
+ Threshold = 1;
}
},
}
diff --git a/doc/getting-started/writing-a-custom-config-file.md b/doc/getting-started/writing-a-custom-config-file.md
index 9620f489..ada5f6ba 100644
--- a/doc/getting-started/writing-a-custom-config-file.md
+++ b/doc/getting-started/writing-a-custom-config-file.md
@@ -13,7 +13,7 @@ return {
NameGenerator = "MangledShuffled";
-- No pretty printing
PrettyPrint = false;
- -- Seed is generated based on current time
+ -- Seed is generated based on current time
-- When specifying a seed that is not 0, you will get the same output every time
Seed = 0;
-- Obfuscation steps
@@ -25,7 +25,7 @@ return {
-- Apply to Strings only
StringsOnly = true;
-- Apply to all Constants, 0.5 would only affect 50% of strings
- Treshold = 1;
+ Threshold = 1;
}
},
}
diff --git a/doc/steps/constantarray.md b/doc/steps/constantarray.md
index f3e8ed9f..61338e1a 100644
--- a/doc/steps/constantarray.md
+++ b/doc/steps/constantarray.md
@@ -10,12 +10,12 @@ description: >-
| Name | type | description |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
-| Treshold | number | The relative amount of nodes that will be affected" |
-| StringsOnly | boolean | Wether to only Extract Strings |
-| Shuffle | boolean | Wether to shuffle the order of Elements in the Array |
-| Rotate | boolean | Wether to rotate the String Array by a specific (random) amount. This will be undone on runtime. |
-| LocalWrapperTreshold | number | The relative amount of nodes functions, that will get local wrappers |
-| LocalWrapperCount | number | The number of Local wrapper Functions per scope. This only applies if LocalWrapperTreshold is greater than 0 |
+| Threshold | number | The relative amount of nodes that will be affected" |
+| StringsOnly | boolean | Whether to only Extract Strings |
+| Shuffle | boolean | Whether to shuffle the order of Elements in the Array |
+| Rotate | boolean | Whether to rotate the String Array by a specific (random) amount. This will be undone on runtime. |
+| LocalWrapperThreshold | number | The relative amount of nodes functions, that will get local wrappers |
+| LocalWrapperCount | number | The number of Local wrapper Functions per scope. This only applies if LocalWrapperThreshold is greater than 0 |
| LocalWrapperArgCount | number | The number of Arguments to the Local wrapper Functions |
| MaxWrapperOffset | number | The Max Offset for the Wrapper Functions |
@@ -32,7 +32,7 @@ print("4")
{% code title="out.lua" %}
```lua
--- LocalWrapperCount = 3
+-- LocalWrapperCount = 3
-- LocalWrapperArgCount = 5
local F = {"4", "3", "2", "1"}
do
diff --git a/doc/steps/splitstrings.md b/doc/steps/splitstrings.md
index 6f834e90..af6f00d8 100644
--- a/doc/steps/splitstrings.md
+++ b/doc/steps/splitstrings.md
@@ -8,11 +8,11 @@ description: This Step splits Strings to a specific or random length
| Name | type | description | Values |
| ------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
-| Treshold | number | The relative amount of nodes that will be affected | 0 <= x <= 1 |
+| Threshold | number | The relative amount of nodes that will be affected | 0 <= x <= 1 |
| MinLength | number | The minimal length for the chunks in that the Strings are splitted | x > 0 |
| MaxLength | number | The maximal length for the chunks in that the Strings are splitted | x >= MinLength |
| ConcatenationType | enum | The Functions used for Concatenation. Note that when using custom, the String Array will also be Shuffled | "strcat", "table", "custom" |
-| CustomFunctionType | enum |
The Type of Function code injection This Option only applies when custom Concatenation is selected.
Note that when chosing inline, the code size may increase significantly!
| "global", "local", "inline" |
+| CustomFunctionType | enum | The Type of Function code injection This Option only applies when custom Concatenation is selected.
Note that when choosing inline, the code size may increase significantly!
| "global", "local", "inline" |
| CustomLocalFunctionsCount | number | The number of local functions per scope. This option only applies when CustomFunctionType = local | x > 0 |
### Example
diff --git a/doc/steps/vmify.md b/doc/steps/vmify.md
index 3febbb0a..dd0aa69e 100644
--- a/doc/steps/vmify.md
+++ b/doc/steps/vmify.md
@@ -1,5 +1,5 @@
---
-description: This Step will Compile your script and run it within a Vm
+description: This Step will Compile your script and run it within a VM.
---
# Vmify
diff --git a/src/cli.lua b/src/cli.lua
index 49c35559..a6d3997d 100644
--- a/src/cli.lua
+++ b/src/cli.lua
@@ -1,154 +1,158 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- cli.lua
--- This script contains the Code for the Prometheus CLI
+--
+-- This Script contains the Code for the Prometheus CLI.
--- Configure package.path for requiring Prometheus
+-- Configure package.path for requiring Prometheus.
local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*[/%\\])")
end
-package.path = script_path() .. "?.lua;" .. package.path;
+package.path = script_path() .. "?.lua;" .. package.path
---@diagnostic disable-next-line: different-requires
-local Prometheus = require("prometheus");
-Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Info;
+local Prometheus = require("prometheus")
+Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Info
-- Check if the file exists
local function file_exists(file)
- local f = io.open(file, "rb")
- if f then f:close() end
- return f ~= nil
+ local f = io.open(file, "rb")
+ if f then
+ f:close()
+ end
+ return f ~= nil
end
string.split = function(str, sep)
- local fields = {}
- local pattern = string.format("([^%s]+)", sep)
- str:gsub(pattern, function(c) fields[#fields+1] = c end)
- return fields
+ local fields = {}
+ local pattern = string.format("([^%s]+)", sep)
+ str:gsub(pattern, function(c)
+ fields[#fields + 1] = c
+ end)
+ return fields
end
-- get all lines from a file, returns an empty
-- list/table if the file does not exist
local function lines_from(file)
- if not file_exists(file) then return {} end
- local lines = {}
- for line in io.lines(file) do
- lines[#lines + 1] = line
- end
- return lines
- end
+ if not file_exists(file) then
+ return {}
+ end
+ local lines = {}
+ for line in io.lines(file) do
+ lines[#lines + 1] = line
+ end
+ return lines
+end
-- CLI
-local config;
-local sourceFile;
-local outFile;
-local luaVersion;
-local prettyPrint;
+local config, sourceFile, outFile, luaVersion, prettyPrint
-Prometheus.colors.enabled = true;
+Prometheus.colors.enabled = true
-- Parse Arguments
-local i = 1;
+local i = 1
while i <= #arg do
- local curr = arg[i];
- if curr:sub(1, 2) == "--" then
- if curr == "--preset" or curr == "--p" then
- if config then
- Prometheus.Logger:warn("The config was set multiple times");
- end
-
- i = i + 1;
- local preset = Prometheus.Presets[arg[i]];
- if not preset then
- Prometheus.Logger:error(string.format("A Preset with the name \"%s\" was not found!", tostring(arg[i])));
- end
-
- config = preset;
- elseif curr == "--config" or curr == "--c" then
- i = i + 1;
- local filename = tostring(arg[i]);
- if not file_exists(filename) then
- Prometheus.Logger:error(string.format("The config file \"%s\" was not found!", filename));
- end
-
- local content = table.concat(lines_from(filename), "\n");
- -- Load Config from File
- local func = loadstring(content);
- -- Sandboxing
- setfenv(func, {});
- config = func();
- elseif curr == "--out" or curr == "--o" then
- i = i + 1;
- if(outFile) then
- Prometheus.Logger:warn("The output file was specified multiple times!");
- end
- outFile = arg[i];
- elseif curr == "--nocolors" then
- Prometheus.colors.enabled = false;
- elseif curr == "--Lua51" then
- luaVersion = "Lua51";
- elseif curr == "--LuaU" then
- luaVersion = "LuaU";
- elseif curr == "--pretty" then
- prettyPrint = true;
- elseif curr == "--saveerrors" then
- -- Override error callback
- Prometheus.Logger.errorCallback = function(...)
- print(Prometheus.colors(Prometheus.Config.NameUpper .. ": " .. ..., "red"))
-
- local args = {...};
- local message = table.concat(args, " ");
-
- local fileName = sourceFile:sub(-4) == ".lua" and sourceFile:sub(0, -5) .. ".error.txt" or sourceFile .. ".error.txt";
- local handle = io.open(fileName, "w");
- handle:write(message);
- handle:close();
-
- os.exit(1);
- end;
- else
- Prometheus.Logger:warn(string.format("The option \"%s\" is not valid and therefore ignored", curr));
- end
- else
- if sourceFile then
- Prometheus.Logger:error(string.format("Unexpected argument \"%s\"", arg[i]));
- end
- sourceFile = tostring(arg[i]);
- end
- i = i + 1;
+ local curr = arg[i]
+ if curr:sub(1, 2) == "--" then
+ if curr == "--preset" or curr == "--p" then
+ if config then
+ Prometheus.Logger:warn("The config was set multiple times")
+ end
+
+ i = i + 1
+ local preset = Prometheus.Presets[arg[i]]
+ if not preset then
+ Prometheus.Logger:error(string.format('A Preset with the name "%s" was not found!', tostring(arg[i])))
+ end
+
+ config = preset
+ elseif curr == "--config" or curr == "--c" then
+ i = i + 1
+ local filename = tostring(arg[i])
+ if not file_exists(filename) then
+ Prometheus.Logger:error(string.format('The config file "%s" was not found!', filename))
+ end
+
+ local content = table.concat(lines_from(filename), "\n")
+ -- Load Config from File
+ local func = loadstring(content)
+ -- Sandboxing
+ setfenv(func, {})
+ config = func()
+ elseif curr == "--out" or curr == "--o" then
+ i = i + 1
+ if outFile then
+ Prometheus.Logger:warn("The output file was specified multiple times!")
+ end
+ outFile = arg[i]
+ elseif curr == "--nocolors" then
+ Prometheus.colors.enabled = false
+ elseif curr == "--Lua51" then
+ luaVersion = "Lua51"
+ elseif curr == "--LuaU" then
+ luaVersion = "LuaU"
+ elseif curr == "--pretty" then
+ prettyPrint = true
+ elseif curr == "--saveerrors" then
+ -- Override error callback
+ Prometheus.Logger.errorCallback = function(...)
+ print(Prometheus.colors(Prometheus.Config.NameUpper .. ": " .. ..., "red"))
+
+ local args = { ... }
+ local message = table.concat(args, " ")
+
+ local fileName = sourceFile:sub(-4) == ".lua" and sourceFile:sub(0, -5) .. ".error.txt"
+ or sourceFile .. ".error.txt"
+ local handle = io.open(fileName, "w")
+ handle:write(message)
+ handle:close()
+
+ os.exit(1)
+ end
+ else
+ Prometheus.Logger:warn(string.format('The option "%s" is not valid and therefore ignored', curr))
+ end
+ else
+ if sourceFile then
+ Prometheus.Logger:error(string.format('Unexpected argument "%s"', arg[i]))
+ end
+ sourceFile = tostring(arg[i])
+ end
+ i = i + 1
end
if not sourceFile then
- Prometheus.Logger:error("No input file was specified!")
+ Prometheus.Logger:error("No input file was specified!")
end
if not config then
- Prometheus.Logger:warn("No config was specified, falling back to Minify preset");
- config = Prometheus.Presets.Minify;
+ Prometheus.Logger:warn("No config was specified, falling back to Minify preset")
+ config = Prometheus.Presets.Minify
end
-- Add Option to override Lua Version
-config.LuaVersion = luaVersion or config.LuaVersion;
-config.PrettyPrint = prettyPrint ~= nil and prettyPrint or config.PrettyPrint;
+config.LuaVersion = luaVersion or config.LuaVersion
+config.PrettyPrint = prettyPrint ~= nil and prettyPrint or config.PrettyPrint
if not file_exists(sourceFile) then
- Prometheus.Logger:error(string.format("The File \"%s\" was not found!", sourceFile));
+ Prometheus.Logger:error(string.format('The File "%s" was not found!', sourceFile))
end
if not outFile then
- if sourceFile:sub(-4) == ".lua" then
- outFile = sourceFile:sub(0, -5) .. ".obfuscated.lua";
- else
- outFile = sourceFile .. ".obfuscated.lua";
- end
+ if sourceFile:sub(-4) == ".lua" then
+ outFile = sourceFile:sub(0, -5) .. ".obfuscated.lua"
+ else
+ outFile = sourceFile .. ".obfuscated.lua"
+ end
end
-local source = table.concat(lines_from(sourceFile), "\n");
-local pipeline = Prometheus.Pipeline:fromConfig(config);
-local out = pipeline:apply(source, sourceFile);
-Prometheus.Logger:info(string.format("Writing output to \"%s\"", outFile));
+local source = table.concat(lines_from(sourceFile), "\n")
+local pipeline = Prometheus.Pipeline:fromConfig(config)
+local out = pipeline:apply(source, sourceFile)
+Prometheus.Logger:info(string.format('Writing output to "%s"', outFile))
-- Write Output
-local handle = io.open(outFile, "w");
-handle:write(out);
-handle:close();
+local handle = io.open(outFile, "w")
+handle:write(out)
+handle:close()
diff --git a/src/colors.lua b/src/colors.lua
index e6bd4f37..c71484fe 100644
--- a/src/colors.lua
+++ b/src/colors.lua
@@ -1,61 +1,65 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
-
+--
+-- colors.lua
+--
+-- This Script provides a simple method for syntax highlighting of Lua code
+
local keys = {
- reset = 0,
-
- bright = 1,
- dim = 2,
- underline = 4,
- blink = 5,
- reverse = 7,
- hidden = 8,
-
- black = 30,
- pink = 91,
- red = 31,
- green = 32,
- yellow = 33,
- blue = 34,
- magenta = 35,
- cyan = 36,
- grey = 37,
- gray = 37,
- white = 97,
-
- blackbg = 40,
- redbg = 41,
- greenbg = 42,
- yellowbg = 43,
- bluebg = 44,
- magentabg = 45,
- cyanbg = 46,
- greybg = 47,
- graybg = 47,
- whitebg = 107,
+ reset = 0,
+ bright = 1,
+ dim = 2,
+ underline = 4,
+ blink = 5,
+ reverse = 7,
+ hidden = 8,
+ black = 30,
+ pink = 91,
+ red = 31,
+ green = 32,
+ yellow = 33,
+ blue = 34,
+ magenta = 35,
+ cyan = 36,
+ grey = 37,
+ gray = 37,
+ white = 97,
+ blackbg = 40,
+ redbg = 41,
+ greenbg = 42,
+ yellowbg = 43,
+ bluebg = 44,
+ magentabg = 45,
+ cyanbg = 46,
+ greybg = 47,
+ graybg = 47,
+ whitebg = 107,
}
-
-local escapeString = string.char(27) .. '[%dm';
+
+local escapeString = string.char(27) .. "[%dm"
local function escapeNumber(number)
- return escapeString:format(number)
+ return escapeString:format(number)
end
-
local settings = {
- enabled = true,
+ enabled = true,
}
local function colors(str, ...)
- if not settings.enabled then
- return str;
- end
- str = tostring(str or '')
+ if not settings.enabled then
+ return str
+ end
+ str = tostring(str or "")
- local escapes = {};
- for i, name in ipairs({...}) do
- table.insert(escapes, escapeNumber(keys[name]))
- end
+ local escapes = {}
+ for _, name in ipairs({ ... }) do
+ table.insert(escapes, escapeNumber(keys[name]))
+ end
- return escapeNumber(keys.reset) .. table.concat(escapes) .. str .. escapeNumber(keys.reset);
+ return escapeNumber(keys.reset) .. table.concat(escapes) .. str .. escapeNumber(keys.reset)
end
-
-return setmetatable(settings, { __call = function(_, ...) return colors(...) end});
\ No newline at end of file
+
+return setmetatable(settings, {
+ __call = function(_, ...)
+ return colors(...)
+ end,
+})
diff --git a/src/config.lua b/src/config.lua
index 628453e0..dd6f8efb 100644
--- a/src/config.lua
+++ b/src/config.lua
@@ -4,17 +4,17 @@
--
-- In this Script, some Global config Variables are defined
-local NAME = "Prometheus";
+local NAME = "Prometheus";
local REVISION = "Alpha";
local VERSION = "v0.2";
-local BY = "levno-710";
+local BY = "levno-710";
for _, currArg in pairs(arg) do
if currArg == "--CI" then
local releaseName = string.gsub(string.format("%s %s %s", NAME, REVISION, VERSION), "%s", "-")
print(releaseName)
end
-
+
if currArg == "--FullVersion" then
print(VERSION)
end
@@ -29,7 +29,7 @@ return {
Revision = REVISION;
-- 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
-
+
SPACE = " "; -- The Whitespace to be used by the unparser
- TAB = "\t"; -- The Tab Whitespace to be used by the unparser for pretty printing
+ TAB = "\t"; -- The Tab Whitespace to be used by the unparser for pretty printing
}
\ No newline at end of file
diff --git a/src/highlightlua.lua b/src/highlightlua.lua
index 27581ddf..5e5b6be2 100644
--- a/src/highlightlua.lua
+++ b/src/highlightlua.lua
@@ -1,9 +1,11 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
+-- highlightlua.lua
+--
-- This Script provides a simple Method for Syntax Highlighting of Lua code
local Tokenizer = require("prometheus.tokenizer");
-local colors = require("colors");
+local colors = require("colors");
local TokenKind = Tokenizer.TokenKind;
local lookupify = require("prometheus.util").lookupify;
diff --git a/src/logger.lua b/src/logger.lua
index 133ae4ac..71c69744 100644
--- a/src/logger.lua
+++ b/src/logger.lua
@@ -1,6 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- logger.lua
+--
+-- This Script provides a Logger for Prometheus.
local logger = {}
local config = require("config");
diff --git a/src/presets.lua b/src/presets.lua
index 5a9b9619..db4f5209 100644
--- a/src/presets.lua
+++ b/src/presets.lua
@@ -2,194 +2,114 @@
--
-- presets.lua
--
--- This Script Provides some configuration presets
+-- This Script provides the predefined obfuscation presets for Prometheus
return {
- ["Minify"] = {
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- No obfuscation steps
- Steps = {
+ -- Minifies your code. Does not obfuscate it. No performance loss.
+ ["Minify"] = {
+ LuaVersion = "Lua51",
+ VarNamePrefix = "",
+ NameGenerator = "MangledShuffled",
+ PrettyPrint = false,
+ Seed = 0,
+ Steps = {},
+ },
- }
- };
- ["Weak"] = {
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables that look like this: IlI1lI1l
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- Obfuscation steps
- Steps = {
- {
- Name = "Vmify";
- Settings = {
+ -- Weak obfuscation. Very readable, low performance loss.
+ ["Weak"] = {
+ LuaVersion = "Lua51",
+ VarNamePrefix = "",
+ NameGenerator = "MangledShuffled",
+ PrettyPrint = false,
+ Seed = 0,
+ Steps = {
+ { Name = "Vmify", Settings = {} },
+ {
+ Name = "ConstantArray",
+ Settings = {
+ Threshold = 1,
+ StringsOnly = true,
+ },
+ },
+ { Name = "WrapInFunction", Settings = {} },
+ },
+ },
- };
- },
- {
- Name = "ConstantArray";
- Settings = {
- Treshold = 1;
- StringsOnly = true;
- }
- },
- {
- Name = "WrapInFunction";
- Settings = {
+ -- This is here for the tests.lua file.
+ -- It helps isolate any problems with the Vmify step.
+ -- It is not recommended to use this preset for obfuscation.
+ -- Use the Weak, Medium, or Strong for obfuscation instead.
+ ["Vmify"] = {
+ LuaVersion = "Lua51",
+ VarNamePrefix = "",
+ NameGenerator = "MangledShuffled",
+ PrettyPrint = false,
+ Seed = 0,
+ Steps = {
+ { Name = "Vmify", Settings = {} },
+ },
+ },
- }
- },
- }
- };
- ["Vmify"] = {
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables that look like this: IlI1lI1l
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- Obfuscation steps
- Steps = {
- {
- Name = "Vmify";
- Settings = {
+ -- Medium obfuscation. Moderate obfuscation, moderate performance loss.
+ ["Medium"] = {
+ LuaVersion = "Lua51",
+ VarNamePrefix = "",
+ NameGenerator = "MangledShuffled",
+ PrettyPrint = false,
+ Seed = 0,
+ Steps = {
+ { Name = "EncryptStrings", Settings = {} },
+ {
+ Name = "AntiTamper",
+ Settings = {
+ UseDebug = false,
+ },
+ },
+ { Name = "Vmify", Settings = {} },
+ {
+ Name = "ConstantArray",
+ Settings = {
+ Threshold = 1,
+ StringsOnly = true,
+ Shuffle = true,
+ Rotate = true,
+ LocalWrapperThreshold = 0,
+ },
+ },
+ { Name = "NumbersToExpressions", Settings = {} },
+ { Name = "WrapInFunction", Settings = {} },
+ },
+ },
- };
- },
- }
- };
- ["Medium"] = {
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- Obfuscation steps
- Steps = {
- {
- Name = "EncryptStrings";
- Settings = {
-
- };
- },
- {
- Name = "AntiTamper";
- Settings = {
- UseDebug = false;
- };
- },
- {
- Name = "Vmify";
- Settings = {
-
- };
- },
- {
- Name = "ConstantArray";
- Settings = {
- Treshold = 1;
- StringsOnly = true;
- Shuffle = true;
- Rotate = true;
- LocalWrapperTreshold = 0;
- }
- },
- {
- Name = "NumbersToExpressions";
- Settings = {
-
- }
- },
- {
- Name = "WrapInFunction";
- Settings = {
-
- }
- },
- }
- };
- ["Strong"] = {
- -- The default LuaVersion is Lua51
- LuaVersion = "Lua51";
- -- For minifying no VarNamePrefix is applied
- VarNamePrefix = "";
- -- Name Generator for Variables that look like this: IlI1lI1l
- NameGenerator = "MangledShuffled";
- -- No pretty printing
- PrettyPrint = false;
- -- Seed is generated based on current time
- Seed = 0;
- -- Obfuscation steps
- Steps = {
- {
- Name = "Vmify";
- Settings = {
-
- };
- },
- {
- Name = "EncryptStrings";
- Settings = {
-
- };
- },
- {
- Name = "AntiTamper";
- Settings = {
-
- };
- },
- {
- Name = "Vmify";
- Settings = {
-
- };
- },
- {
- Name = "ConstantArray";
- Settings = {
- Treshold = 1;
- StringsOnly = true;
- Shuffle = true;
- Rotate = true;
- LocalWrapperTreshold = 0;
- }
- },
- {
- Name = "NumbersToExpressions";
- Settings = {
-
- }
- },
- {
- Name = "WrapInFunction";
- Settings = {
-
- }
- },
- }
- },
+ -- Strong obfuscation, high performance loss.
+ ["Strong"] = {
+ LuaVersion = "Lua51",
+ VarNamePrefix = "",
+ NameGenerator = "MangledShuffled",
+ PrettyPrint = false,
+ Seed = 0,
+ Steps = {
+ { Name = "Vmify", Settings = {} },
+ { Name = "EncryptStrings", Settings = {} },
+ {
+ Name = "AntiTamper",
+ Settings = {
+ UseDebug = false,
+ },
+ },
+ { Name = "Vmify", Settings = {} },
+ {
+ Name = "ConstantArray",
+ Settings = {
+ Threshold = 1,
+ StringsOnly = true,
+ Shuffle = true,
+ Rotate = true,
+ LocalWrapperThreshold = 0,
+ },
+ },
+ { Name = "NumbersToExpressions", Settings = {} },
+ { Name = "WrapInFunction", Settings = {} },
+ },
+ },
}
diff --git a/src/prometheus.lua b/src/prometheus.lua
index 7dc46d6e..3f4d42c1 100644
--- a/src/prometheus.lua
+++ b/src/prometheus.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- prometheus.lua
+--
-- This file is the entrypoint for Prometheus
-- Configure package.path for require
@@ -48,24 +49,24 @@ end
-- Require Prometheus Submodules
-local Pipeline = require("prometheus.pipeline");
+local Pipeline = require("prometheus.pipeline");
local highlight = require("highlightlua");
-local colors = require("colors");
-local Logger = require("logger");
-local Presets = require("presets");
-local Config = require("config");
-local util = require("prometheus.util");
+local colors = require("colors");
+local Logger = require("logger");
+local Presets = require("presets");
+local Config = require("config");
+local util = require("prometheus.util");
-- Restore package.path
package.path = oldPkgPath;
-- Export
return {
- Pipeline = Pipeline;
- colors = colors;
- Config = util.readonly(Config); -- Readonly
- Logger = Logger;
+ Pipeline = Pipeline;
+ colors = colors;
+ Config = util.readonly(Config); -- Readonly
+ Logger = Logger;
highlight = highlight;
- Presets = Presets;
+ Presets = Presets;
}
diff --git a/src/prometheus/ast.lua b/src/prometheus/ast.lua
index 778f6d8d..6cd6914e 100644
--- a/src/prometheus/ast.lua
+++ b/src/prometheus/ast.lua
@@ -1,6 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- ast.lua
+--
+-- This Script provides the Abstract Syntax Tree (AST) for Prometheus.
local Ast = {}
diff --git a/src/prometheus/compiler/block.lua b/src/prometheus/compiler/block.lua
index d834114b..572f8569 100644
--- a/src/prometheus/compiler/block.lua
+++ b/src/prometheus/compiler/block.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- block.lua
+--
-- Block management for the compiler
local Scope = require("prometheus.scope");
diff --git a/src/prometheus/compiler/compile_top.lua b/src/prometheus/compiler/compile_top.lua
index 0ba61d24..63ebc1dd 100644
--- a/src/prometheus/compiler/compile_top.lua
+++ b/src/prometheus/compiler/compile_top.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- compile_top.lua
--- This Script contains the compilation of the top node, function, and block
+--
+-- This Script contains the compilation of the top node, function, and block.
local Ast = require("prometheus.ast");
local util = require("prometheus.util");
diff --git a/src/prometheus/compiler/compiler.lua b/src/prometheus/compiler/compiler.lua
index 65e94c75..31af5831 100644
--- a/src/prometheus/compiler/compiler.lua
+++ b/src/prometheus/compiler/compiler.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- compiler.lua
--- This Script contains the new Compiler
+--
+-- This Script is the main compiler module.
local Ast = require("prometheus.ast");
local Scope = require("prometheus.scope");
@@ -100,7 +101,7 @@ function Compiler:compile(ast)
local psc = Scope:new(newGlobalScope, nil);
local _, getfenvVar = newGlobalScope:resolve("getfenv");
- local _, tableVar = newGlobalScope:resolve("table");
+ local _, tableVar = newGlobalScope:resolve("table");
local _, unpackVar = newGlobalScope:resolve("unpack");
local _, envVar = newGlobalScope:resolve("_ENV");
local _, newproxyVar = newGlobalScope:resolve("newproxy");
@@ -134,7 +135,7 @@ function Compiler:compile(ast)
self.argsVar = self.containerFuncScope:addVariable();
self.currentUpvaluesVar = self.containerFuncScope:addVariable();
self.detectGcCollectVar = self.containerFuncScope:addVariable();
- self.returnVar = self.containerFuncScope:addVariable();
+ self.returnVar = self.containerFuncScope:addVariable();
self.upvaluesTable = self.scope:addVariable();
self.upvaluesReferenceCountsTable = self.scope:addVariable();
@@ -271,7 +272,11 @@ function Compiler:compile(ast)
assignmentStatRhs[i] = v.val;
end
- local functionNode = Ast.FunctionLiteralExpression({
+
+ -- NEW: Position Shuffler
+ local ids = util.shuffle({1, 2, 3, 4, 5, 6, 7});
+
+ local items = {
Ast.VariableExpression(self.scope, self.envVar),
Ast.VariableExpression(self.scope, self.unpackVar),
Ast.VariableExpression(self.scope, self.newproxyVar),
@@ -279,7 +284,24 @@ function Compiler:compile(ast)
Ast.VariableExpression(self.scope, self.getmetatableVar),
Ast.VariableExpression(self.scope, self.selectVar),
Ast.VariableExpression(self.scope, argVar),
- unpack(util.shuffle(tbl))
+ }
+
+ local astItems = {
+ Ast.OrExpression(Ast.AndExpression(Ast.VariableExpression(newGlobalScope, getfenvVar), Ast.FunctionCallExpression(Ast.VariableExpression(newGlobalScope, getfenvVar), {})), Ast.VariableExpression(newGlobalScope, envVar));
+ Ast.OrExpression(Ast.VariableExpression(newGlobalScope, unpackVar), Ast.IndexExpression(Ast.VariableExpression(newGlobalScope, tableVar), Ast.StringExpression("unpack")));
+ Ast.VariableExpression(newGlobalScope, newproxyVar);
+ Ast.VariableExpression(newGlobalScope, setmetatableVar);
+ Ast.VariableExpression(newGlobalScope, getmetatableVar);
+ Ast.VariableExpression(newGlobalScope, selectVar);
+ Ast.TableConstructorExpression({
+ Ast.TableEntry(Ast.VarargExpression());
+ })
+ }
+
+ local functionNode = Ast.FunctionLiteralExpression({
+ items[ids[1]], items[ids[2]], items[ids[3]], items[ids[4]],
+ items[ids[5]], items[ids[6]], items[ids[7]],
+ unpack(util.shuffle(tbl))
}, Ast.Block({
Ast.AssignmentStatement(assignmentStatLhs, assignmentStatRhs);
Ast.ReturnStatement{
@@ -292,15 +314,8 @@ function Compiler:compile(ast)
return Ast.TopNode(Ast.Block({
Ast.ReturnStatement{Ast.FunctionCallExpression(functionNode, {
- Ast.OrExpression(Ast.AndExpression(Ast.VariableExpression(newGlobalScope, getfenvVar), Ast.FunctionCallExpression(Ast.VariableExpression(newGlobalScope, getfenvVar), {})), Ast.VariableExpression(newGlobalScope, envVar));
- Ast.OrExpression(Ast.VariableExpression(newGlobalScope, unpackVar), Ast.IndexExpression(Ast.VariableExpression(newGlobalScope, tableVar), Ast.StringExpression("unpack")));
- Ast.VariableExpression(newGlobalScope, newproxyVar);
- Ast.VariableExpression(newGlobalScope, setmetatableVar);
- Ast.VariableExpression(newGlobalScope, getmetatableVar);
- Ast.VariableExpression(newGlobalScope, selectVar);
- Ast.TableConstructorExpression({
- Ast.TableEntry(Ast.VarargExpression());
- })
+ astItems[ids[1]], astItems[ids[2]], astItems[ids[3]], astItems[ids[4]],
+ astItems[ids[5]], astItems[ids[6]], astItems[ids[7]],
})};
}, psc), newGlobalScope);
end
diff --git a/src/prometheus/compiler/constants.lua b/src/prometheus/compiler/constants.lua
index cb1d6c02..5ddbdd1a 100644
--- a/src/prometheus/compiler/constants.lua
+++ b/src/prometheus/compiler/constants.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- constants.lua
--- This Script contains the compiler constants shared across modules
+--
+-- This Script contains the compiler constants shared across modules.
return {
MAX_REGS = 100,
diff --git a/src/prometheus/compiler/emit.lua b/src/prometheus/compiler/emit.lua
index 2858b8af..c7704b5e 100644
--- a/src/prometheus/compiler/emit.lua
+++ b/src/prometheus/compiler/emit.lua
@@ -1,7 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- emit.lua
--- This Script contains the container function body emission for the compiler
+-- This Script contains the container function body emission for the compiler.
local Ast = require("prometheus.ast");
local Scope = require("prometheus.scope");
@@ -151,4 +151,4 @@ return function(Compiler)
return Ast.Block(stats, self.containerFuncScope);
end
-end
+end
\ No newline at end of file
diff --git a/src/prometheus/compiler/expressions.lua b/src/prometheus/compiler/expressions.lua
index 9aaf388d..9192e471 100644
--- a/src/prometheus/compiler/expressions.lua
+++ b/src/prometheus/compiler/expressions.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- expressions.lua
--- This Script contains the expression handlers: exports handler table keyed by AstKind
+--
+-- This Script contains the expression handlers: exports handler table keyed by AstKind.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/expressions/and.lua b/src/prometheus/compiler/expressions/and.lua
index 12444a29..af12d7b6 100644
--- a/src/prometheus/compiler/expressions/and.lua
+++ b/src/prometheus/compiler/expressions/and.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- and.lua
--- This Script contains the expression handler for the AndExpression
+--
+-- This Script contains the expression handler for the AndExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/binary.lua b/src/prometheus/compiler/expressions/binary.lua
index 3926a12c..2810a5ba 100644
--- a/src/prometheus/compiler/expressions/binary.lua
+++ b/src/prometheus/compiler/expressions/binary.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- binary.lua
--- This Script contains the expression handler for the Binary operations (Add, Sub, Mul, Div, etc.)
+--
+-- This Script contains the expression handler for the Binary operations (Add, Sub, Mul, Div, etc.).
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/boolean.lua b/src/prometheus/compiler/expressions/boolean.lua
index 67de88f2..8f55ee78 100644
--- a/src/prometheus/compiler/expressions/boolean.lua
+++ b/src/prometheus/compiler/expressions/boolean.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- boolean.lua
--- This Script contains the expression handler for the BooleanExpression
+--
+-- This Script contains the expression handler for the BooleanExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/function_call.lua b/src/prometheus/compiler/expressions/function_call.lua
index 41e61b11..343fd891 100644
--- a/src/prometheus/compiler/expressions/function_call.lua
+++ b/src/prometheus/compiler/expressions/function_call.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- function_call.lua
--- This Script contains the expression handler for the FunctionCallExpression
+--
+-- This Script contains the expression handler for the FunctionCallExpression.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/expressions/function_literal.lua b/src/prometheus/compiler/expressions/function_literal.lua
index 1fc3d9a7..c0950ee5 100644
--- a/src/prometheus/compiler/expressions/function_literal.lua
+++ b/src/prometheus/compiler/expressions/function_literal.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- function_literal.lua
+--
-- This Script contains the expression handler for the FunctionLiteralExpression
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/index.lua b/src/prometheus/compiler/expressions/index.lua
index 4600b13b..fb1f653c 100644
--- a/src/prometheus/compiler/expressions/index.lua
+++ b/src/prometheus/compiler/expressions/index.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- index.lua
--- This Script contains the expression handler for the IndexExpression
+--
+-- This Script contains the expression handler for the IndexExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/len.lua b/src/prometheus/compiler/expressions/len.lua
index 92c81de5..0657cf4f 100644
--- a/src/prometheus/compiler/expressions/len.lua
+++ b/src/prometheus/compiler/expressions/len.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- len.lua
+--
-- This Script contains the expression handler for the LenExpression
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/negate.lua b/src/prometheus/compiler/expressions/negate.lua
index 41cb9d4a..ea56d592 100644
--- a/src/prometheus/compiler/expressions/negate.lua
+++ b/src/prometheus/compiler/expressions/negate.lua
@@ -1,4 +1,8 @@
--- Expression handler: NegateExpression
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- negate.lua
+--
+-- This Script contains the expression handler for the NegateExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/nil.lua b/src/prometheus/compiler/expressions/nil.lua
index a314605c..a6295838 100644
--- a/src/prometheus/compiler/expressions/nil.lua
+++ b/src/prometheus/compiler/expressions/nil.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- nil.lua
--- This Script contains the expression handler for the NilExpression
+--
+-- This Script contains the expression handler for the NilExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/not.lua b/src/prometheus/compiler/expressions/not.lua
index af847583..f0def99e 100644
--- a/src/prometheus/compiler/expressions/not.lua
+++ b/src/prometheus/compiler/expressions/not.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- not.lua
--- This Script contains the expression handler for the NotExpression
+--
+-- This Script contains the expression handler for the NotExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/number.lua b/src/prometheus/compiler/expressions/number.lua
index 9f799427..22246dca 100644
--- a/src/prometheus/compiler/expressions/number.lua
+++ b/src/prometheus/compiler/expressions/number.lua
@@ -1,4 +1,8 @@
--- Expression handler: NumberExpression
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- number.lua
+--
+-- This Script contains the expression handler for the NumberExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/or.lua b/src/prometheus/compiler/expressions/or.lua
index c3032f6e..aff6b843 100644
--- a/src/prometheus/compiler/expressions/or.lua
+++ b/src/prometheus/compiler/expressions/or.lua
@@ -1,4 +1,8 @@
--- Expression handler: OrExpression
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- or.lua
+--
+-- This Script contains the expression handler for the OrExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/pass_self_function_call.lua b/src/prometheus/compiler/expressions/pass_self_function_call.lua
index 175f5a8c..78ea10b6 100644
--- a/src/prometheus/compiler/expressions/pass_self_function_call.lua
+++ b/src/prometheus/compiler/expressions/pass_self_function_call.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- pass_self_function_call.lua
--- This Script contains the expression handler for the PassSelfFunctionCallExpression
+--
+-- This Script contains the expression handler for the PassSelfFunctionCallExpression.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/expressions/string.lua b/src/prometheus/compiler/expressions/string.lua
index 776f0e8d..dd08e150 100644
--- a/src/prometheus/compiler/expressions/string.lua
+++ b/src/prometheus/compiler/expressions/string.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- string.lua
--- This Script contains the expression handler for the StringExpression
+--
+-- This Script contains the expression handler for the StringExpression.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/table_constructor.lua b/src/prometheus/compiler/expressions/table_constructor.lua
index 77a400e4..087c3f0e 100644
--- a/src/prometheus/compiler/expressions/table_constructor.lua
+++ b/src/prometheus/compiler/expressions/table_constructor.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- table_constructor.lua
--- This Script contains the expression handler for the TableConstructorExpression
+--
+-- This Script contains the expression handler for the TableConstructorExpression.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/expressions/vararg.lua b/src/prometheus/compiler/expressions/vararg.lua
index 322430a7..86d72343 100644
--- a/src/prometheus/compiler/expressions/vararg.lua
+++ b/src/prometheus/compiler/expressions/vararg.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- vararg.lua
+--
-- This Script contains the expression handler for the VarargExpression
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/expressions/variable.lua b/src/prometheus/compiler/expressions/variable.lua
index c72f0e41..9f95fdf8 100644
--- a/src/prometheus/compiler/expressions/variable.lua
+++ b/src/prometheus/compiler/expressions/variable.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- variable.lua
+--
-- This Script contains the expression handler for the VariableExpression
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/register.lua b/src/prometheus/compiler/register.lua
index 43789b5a..2fae1fac 100644
--- a/src/prometheus/compiler/register.lua
+++ b/src/prometheus/compiler/register.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- register.lua
--- Register management for the compiler
+--
+-- This Script contains the register management for the compiler.
local Ast = require("prometheus.ast");
local constants = require("prometheus.compiler.constants");
@@ -167,7 +168,7 @@ return function(Compiler)
function Compiler:copyRegisters(scope, to, from)
local idStats = {};
- local vals = {};
+ local vals = {};
for i, id in ipairs(to) do
local fromId = from[i];
if(fromId ~= id) then
diff --git a/src/prometheus/compiler/statements.lua b/src/prometheus/compiler/statements.lua
index 62264d79..27ac6bdc 100644
--- a/src/prometheus/compiler/statements.lua
+++ b/src/prometheus/compiler/statements.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- statements.lua
--- This Script contains the statement handlers: exports handler table keyed by AstKind
+--
+-- This Script contains the statement handlers: exports handler table keyed by AstKind.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/statements/assignment.lua b/src/prometheus/compiler/statements/assignment.lua
index 305160e9..fc4f4620 100644
--- a/src/prometheus/compiler/statements/assignment.lua
+++ b/src/prometheus/compiler/statements/assignment.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- assignment.lua
--- This Script contains the statement handler for the AssignmentStatement
+--
+-- This Script contains the statement handler for the AssignmentStatement.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/statements/break_statement.lua b/src/prometheus/compiler/statements/break_statement.lua
index 909c0260..28e15c82 100644
--- a/src/prometheus/compiler/statements/break_statement.lua
+++ b/src/prometheus/compiler/statements/break_statement.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- break_statement.lua
--- This Script contains the statement handler for the BreakStatement
+--
+-- This Script contains the statement handler for the BreakStatement.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/compound.lua b/src/prometheus/compiler/statements/compound.lua
index a07eb097..b0ca4035 100644
--- a/src/prometheus/compiler/statements/compound.lua
+++ b/src/prometheus/compiler/statements/compound.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- compound.lua
+--
-- This Script contains the statement handler for the Compound statements (compound add, sub, mul, etc.)
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/continue_statement.lua b/src/prometheus/compiler/statements/continue_statement.lua
index e2b0984f..a7656999 100644
--- a/src/prometheus/compiler/statements/continue_statement.lua
+++ b/src/prometheus/compiler/statements/continue_statement.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- continue_statement.lua
--- This Script contains the statement handler for the ContinueStatement
+--
+-- This Script contains the statement handler for the ContinueStatement.
local Ast = require("prometheus.ast");
@@ -11,7 +12,7 @@ return function(self, statement, funcDepth)
local statScope;
repeat
statScope = statScope and statScope.parentScope or statement.scope;
- for id, name in pairs(statScope.variables) do
+ for id, _ in pairs(statScope.variables) do
table.insert(toFreeVars, {
scope = statScope,
id = id;
@@ -19,7 +20,7 @@ return function(self, statement, funcDepth)
end
until statScope == statement.loop.body.scope;
- for i, var in ipairs(toFreeVars) do
+ for _, var in ipairs(toFreeVars) do
local varScope, id = var.scope, var.id;
local varReg = self:getVarRegister(varScope, id, nil, nil);
if self:isUpvalue(varScope, id) then
diff --git a/src/prometheus/compiler/statements/do_statement.lua b/src/prometheus/compiler/statements/do_statement.lua
index d8b7f025..65d71daf 100644
--- a/src/prometheus/compiler/statements/do_statement.lua
+++ b/src/prometheus/compiler/statements/do_statement.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- do_statement.lua
--- This Script contains the statement handler for the DoStatement
+--
+-- This Script contains the statement handler for the DoStatement.
return function(self, statement, funcDepth)
self:compileBlock(statement.body, funcDepth);
diff --git a/src/prometheus/compiler/statements/for_in_statement.lua b/src/prometheus/compiler/statements/for_in_statement.lua
index fd779351..af82ce67 100644
--- a/src/prometheus/compiler/statements/for_in_statement.lua
+++ b/src/prometheus/compiler/statements/for_in_statement.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- for_in_statement.lua
+--
-- This Script contains the statement handler for the ForInStatement
local Ast = require("prometheus.ast");
@@ -95,7 +96,7 @@ return function(self, statement, funcDepth)
self:addStatement(self:setPos(scope, checkBlock.id), {self.POS_REGISTER}, {}, false);
self:setActiveBlock(finalBlock);
- for i, reg in ipairs(exprregs) do
+ for i, _ in ipairs(exprregs) do
self:freeRegister(exprregs[i], true)
end
end;
diff --git a/src/prometheus/compiler/statements/for_statement.lua b/src/prometheus/compiler/statements/for_statement.lua
index 38adb3d9..3c5e03f9 100644
--- a/src/prometheus/compiler/statements/for_statement.lua
+++ b/src/prometheus/compiler/statements/for_statement.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- for_statement.lua
+--
-- This Script contains the statement handler for the ForStatement
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/function_call.lua b/src/prometheus/compiler/statements/function_call.lua
index 865a5e40..c1f32a5d 100644
--- a/src/prometheus/compiler/statements/function_call.lua
+++ b/src/prometheus/compiler/statements/function_call.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- function_call.lua
--- This Script contains the statement handler for the FunctionCallStatement
+--
+-- This Script contains the statement handler for the FunctionCallStatement.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
@@ -9,7 +10,7 @@ local AstKind = Ast.AstKind;
return function(self, statement, funcDepth)
local scope = self.activeBlock.scope;
local baseReg = self:compileExpression(statement.base, funcDepth, 1)[1];
- local retReg = self:allocRegister(false);
+ local retReg = self:allocRegister(false);
local regs = {};
local args = {};
@@ -31,7 +32,7 @@ return function(self, statement, funcDepth)
self:addStatement(self:setRegister(scope, retReg, Ast.FunctionCallExpression(self:register(scope, baseReg), args)), {retReg}, {baseReg, unpack(regs)}, true);
self:freeRegister(baseReg, false);
self:freeRegister(retReg, false);
- for i, reg in ipairs(regs) do
+ for _, reg in ipairs(regs) do
self:freeRegister(reg, false);
end
end;
diff --git a/src/prometheus/compiler/statements/function_declaration.lua b/src/prometheus/compiler/statements/function_declaration.lua
index 8142a2fe..3dde2c1a 100644
--- a/src/prometheus/compiler/statements/function_declaration.lua
+++ b/src/prometheus/compiler/statements/function_declaration.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- function_declaration.lua
--- This Script contains the statement handler for the FunctionDeclaration
+--
+-- This Script contains the statement handler for the FunctionDeclaration.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/if_statement.lua b/src/prometheus/compiler/statements/if_statement.lua
index 45b2c127..0a093968 100644
--- a/src/prometheus/compiler/statements/if_statement.lua
+++ b/src/prometheus/compiler/statements/if_statement.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- if_statement.lua
--- This Script contains the statement handler for the IfStatement
+--
+-- This Script contains the statement handler for the IfStatement.
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/local_function_declaration.lua b/src/prometheus/compiler/statements/local_function_declaration.lua
index 22525f1c..195bb5a1 100644
--- a/src/prometheus/compiler/statements/local_function_declaration.lua
+++ b/src/prometheus/compiler/statements/local_function_declaration.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- local_function_declaration.lua
+--
-- This Script contains the statement handler for the LocalFunctionDeclaration
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/statements/local_variable_declaration.lua b/src/prometheus/compiler/statements/local_variable_declaration.lua
index 5189c8e4..33f2e7a5 100644
--- a/src/prometheus/compiler/statements/local_variable_declaration.lua
+++ b/src/prometheus/compiler/statements/local_variable_declaration.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- local_variable_declaration.lua
+--
-- This Script contains the statement handler for the LocalVariableDeclaration
local Ast = require("prometheus.ast");
@@ -24,7 +25,7 @@ return function(self, statement, funcDepth)
end
if #exprregs == 0 then
- for i=1, #statement.ids do
+ for _=1, #statement.ids do
table.insert(exprregs, self:compileExpression(Ast.NilExpression(), funcDepth, 1)[1]);
end
end
diff --git a/src/prometheus/compiler/statements/pass_self_function_call.lua b/src/prometheus/compiler/statements/pass_self_function_call.lua
index 03e16757..5c946602 100644
--- a/src/prometheus/compiler/statements/pass_self_function_call.lua
+++ b/src/prometheus/compiler/statements/pass_self_function_call.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- pass_self_function_call.lua
--- This Script contains the statement handler for the PassSelfFunctionCallStatement
+--
+-- This Script contains the statement handler for the PassSelfFunctionCallStatement.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
@@ -9,7 +10,7 @@ local AstKind = Ast.AstKind;
return function(self, statement, funcDepth)
local scope = self.activeBlock.scope;
local baseReg = self:compileExpression(statement.base, funcDepth, 1)[1];
- local tmpReg = self:allocRegister(false);
+ local tmpReg = self:allocRegister(false);
local args = { self:register(scope, baseReg) };
local regs = { baseReg };
@@ -32,7 +33,7 @@ return function(self, statement, funcDepth)
self:addStatement(self:setRegister(scope, tmpReg, Ast.FunctionCallExpression(self:register(scope, tmpReg), args)), {tmpReg}, {tmpReg, unpack(regs)}, true);
self:freeRegister(tmpReg, false);
- for i, reg in ipairs(regs) do
+ for _, reg in ipairs(regs) do
self:freeRegister(reg, false);
end
end;
diff --git a/src/prometheus/compiler/statements/repeat_statement.lua b/src/prometheus/compiler/statements/repeat_statement.lua
index c3e4be85..84944a03 100644
--- a/src/prometheus/compiler/statements/repeat_statement.lua
+++ b/src/prometheus/compiler/statements/repeat_statement.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- repeat_statement.lua
--- This Script contains the statement handler for the RepeatStatement
+--
+-- This Script contains the statement handler for the RepeatStatement.
local Ast = require("prometheus.ast");
@@ -15,7 +16,7 @@ return function(self, statement, funcDepth)
self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.NumberExpression(innerBlock.id)), {self.POS_REGISTER}, {}, false);
self:setActiveBlock(innerBlock);
- for i, stat in ipairs(statement.body.statements) do
+ for _, stat in ipairs(statement.body.statements) do
self:compileStatement(stat, funcDepth);
end;
@@ -24,7 +25,7 @@ return function(self, statement, funcDepth)
self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(finalBlock.id)), Ast.NumberExpression(innerBlock.id))), { self.POS_REGISTER }, { conditionReg }, false);
self:freeRegister(conditionReg, false);
- for id, name in ipairs(statement.body.scope.variables) do
+ for id, _ in ipairs(statement.body.scope.variables) do
local varReg = self:getVarRegister(statement.body.scope, id, funcDepth, nil);
if self:isUpvalue(statement.body.scope, id) then
scope:addReferenceToHigherScope(self.scope, self.freeUpvalueFunc);
diff --git a/src/prometheus/compiler/statements/return.lua b/src/prometheus/compiler/statements/return.lua
index cdd59e09..8c7fa874 100644
--- a/src/prometheus/compiler/statements/return.lua
+++ b/src/prometheus/compiler/statements/return.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- return.lua
--- This Script contains the statement handler for the ReturnStatement
+--
+-- This Script contains the statement handler for the ReturnStatement.
local Ast = require("prometheus.ast");
local AstKind = Ast.AstKind;
diff --git a/src/prometheus/compiler/statements/while_statement.lua b/src/prometheus/compiler/statements/while_statement.lua
index 5d58d125..c4a93220 100644
--- a/src/prometheus/compiler/statements/while_statement.lua
+++ b/src/prometheus/compiler/statements/while_statement.lua
@@ -1,6 +1,7 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- while_statement.lua
+--
-- This Script contains the statement handler for the WhileStatement
local Ast = require("prometheus.ast");
diff --git a/src/prometheus/compiler/upvalue.lua b/src/prometheus/compiler/upvalue.lua
index 1db1e5cc..494dce4f 100644
--- a/src/prometheus/compiler/upvalue.lua
+++ b/src/prometheus/compiler/upvalue.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- upvalue.lua
--- Upvalue and GC management for the compiler
+--
+-- This Script contains the upvalue and GC management for the compiler.
local Ast = require("prometheus.ast");
local Scope = require("prometheus.scope");
diff --git a/src/prometheus/enums.lua b/src/prometheus/enums.lua
index 162bdfac..0516787d 100644
--- a/src/prometheus/enums.lua
+++ b/src/prometheus/enums.lua
@@ -1,45 +1,46 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- enums.lua
--- This file Provides some enums used by the Obfuscator
+--
+-- This Script provides some enums used by the Obfuscator.
local Enums = {};
local chararray = require("prometheus.util").chararray;
Enums.LuaVersion = {
- LuaU = "LuaU" ,
+ LuaU = "LuaU" ,
Lua51 = "Lua51",
}
Enums.Conventions = {
[Enums.LuaVersion.Lua51] = {
Keywords = {
- "and", "break", "do", "else", "elseif",
- "end", "false", "for", "function", "if",
- "in", "local", "nil", "not", "or",
- "repeat", "return", "then", "true", "until", "while"
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or",
+ "repeat", "return", "then", "true", "until", "while"
},
SymbolChars = chararray("+-*/%^#=~<>(){}[];:,."),
MaxSymbolLength = 3,
Symbols = {
- "+", "-", "*", "/", "%", "^", "#",
- "==", "~=", "<=", ">=", "<", ">", "=",
- "(", ")", "{", "}", "[", "]",
- ";", ":", ",", ".", "..", "...",
+ "+", "-", "*", "/", "%", "^", "#",
+ "==", "~=", "<=", ">=", "<", ">", "=",
+ "(", ")", "{", "}", "[", "]",
+ ";", ":", ",", ".", "..", "...",
},
- IdentChars = chararray("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"),
- NumberChars = chararray("0123456789"),
- HexNumberChars = chararray("0123456789abcdefABCDEF"),
- BinaryNumberChars = {"0", "1"},
- DecimalExponent = {"e", "E"},
- HexadecimalNums = {"x", "X"},
- BinaryNums = {"b", "B"},
- DecimalSeperators = false,
+ IdentChars = chararray("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"),
+ NumberChars = chararray("0123456789"),
+ HexNumberChars = chararray("0123456789abcdefABCDEF"),
+ BinaryNumberChars = {"0", "1"},
+ DecimalExponent = {"e", "E"},
+ HexadecimalNums = {"x", "X"},
+ BinaryNums = {"b", "B"},
+ DecimalSeperators = false,
- EscapeSequences = {
+ EscapeSequences = {
["a"] = "\a";
["b"] = "\b";
["f"] = "\f";
@@ -58,33 +59,33 @@ Enums.Conventions = {
},
[Enums.LuaVersion.LuaU] = {
Keywords = {
- "and", "break", "do", "else", "elseif", "continue",
- "end", "false", "for", "function", "if",
- "in", "local", "nil", "not", "or",
- "repeat", "return", "then", "true", "until", "while"
+ "and", "break", "do", "else", "elseif", "continue",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or",
+ "repeat", "return", "then", "true", "until", "while"
},
SymbolChars = chararray("+-*/%^#=~<>(){}[];:,."),
MaxSymbolLength = 3,
Symbols = {
- "+", "-", "*", "/", "%", "^", "#",
- "==", "~=", "<=", ">=", "<", ">", "=",
+ "+", "-", "*", "/", "%", "^", "#",
+ "==", "~=", "<=", ">=", "<", ">", "=",
"+=", "-=", "/=", "%=", "^=", "..=", "*=",
- "(", ")", "{", "}", "[", "]",
- ";", ":", ",", ".", "..", "...",
- "::", "->", "?", "|", "&",
+ "(", ")", "{", "}", "[", "]",
+ ";", ":", ",", ".", "..", "...",
+ "::", "->", "?", "|", "&",
},
- IdentChars = chararray("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"),
- NumberChars = chararray("0123456789"),
- HexNumberChars = chararray("0123456789abcdefABCDEF"),
- BinaryNumberChars = {"0", "1"},
- DecimalExponent = {"e", "E"},
- HexadecimalNums = {"x", "X"},
- BinaryNums = {"b", "B"},
- DecimalSeperators = {"_"},
+ IdentChars = chararray("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"),
+ NumberChars = chararray("0123456789"),
+ HexNumberChars = chararray("0123456789abcdefABCDEF"),
+ BinaryNumberChars = {"0", "1"},
+ DecimalExponent = {"e", "E"},
+ HexadecimalNums = {"x", "X"},
+ BinaryNums = {"b", "B"},
+ DecimalSeperators = {"_"},
- EscapeSequences = {
+ EscapeSequences = {
["a"] = "\a";
["b"] = "\b";
["f"] = "\f";
diff --git a/src/prometheus/namegenerators.lua b/src/prometheus/namegenerators.lua
index afbf1bf7..e69a95af 100644
--- a/src/prometheus/namegenerators.lua
+++ b/src/prometheus/namegenerators.lua
@@ -1,3 +1,9 @@
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- namegenerators.lua
+--
+-- This Script provides a collection of name generators for Prometheus.
+
return {
Mangled = require("prometheus.namegenerators.mangled");
MangledShuffled = require("prometheus.namegenerators.mangled_shuffled");
diff --git a/src/prometheus/pipeline.lua b/src/prometheus/pipeline.lua
index 7e4f0775..367b8415 100644
--- a/src/prometheus/pipeline.lua
+++ b/src/prometheus/pipeline.lua
@@ -2,10 +2,10 @@
--
-- pipeline.lua
--
--- This Script Provides a Configurable Obfuscation Pipeline that can obfuscate code using different Modules
--- These Modules can simply be added to the pipeline
+-- This Script provides a configurable obfuscation pipeline that can obfuscate code using different modules
+-- These modules can simply be added to the pipeline.
-local Enums = require("prometheus.enums");
+local Enums = require("prometheus.enums");
local util = require("prometheus.util");
local Parser = require("prometheus.parser");
local Unparser = require("prometheus.unparser");
@@ -16,7 +16,7 @@ local NameGenerators = require("prometheus.namegenerators");
local Steps = require("prometheus.steps");
local LuaVersion = Enums.LuaVersion;
--- On Windows os.clock can be used. On other Systems os.time must be used for benchmarking
+-- On Windows, os.clock can be used. On other systems, os.time must be used for benchmarking.
local isWindows = package and package.config and type(package.config) == "string" and package.config:sub(1,1) == "\\";
local function gettime()
if isWindows then
@@ -43,7 +43,7 @@ function Pipeline:new(settings)
local conventions = Enums.Conventions[luaVersion];
if(not conventions) then
logger:error("The Lua Version \"" .. luaVersion
- .. "\" is not recognised by the Tokenizer! Please use one of the following: \"" .. table.concat(util.keys(Enums.Conventions), "\",\"") .. "\"");
+ .. "\" is not recognized by the Tokenizer! Please use one of the following: \"" .. table.concat(util.keys(Enums.Conventions), "\",\"") .. "\"");
end
local prettyPrint = settings.PrettyPrint or Pipeline.DefaultSettings.PrettyPrint;
@@ -77,10 +77,10 @@ end
function Pipeline:fromConfig(config)
config = config or {};
local pipeline = Pipeline:new({
- LuaVersion = config.LuaVersion or LuaVersion.Lua51;
- PrettyPrint = config.PrettyPrint or false;
+ LuaVersion = config.LuaVersion or LuaVersion.Lua51;
+ PrettyPrint = config.PrettyPrint or false;
VarNamePrefix = config.VarNamePrefix or "";
- Seed = config.Seed or 0;
+ Seed = config.Seed or 0;
});
pipeline:setNameGenerator(config.NameGenerator or "MangledShuffled")
@@ -126,7 +126,7 @@ function Pipeline:setLuaVersion(luaVersion)
local conventions = Enums.Conventions[luaVersion];
if(not conventions) then
logger:error("The Lua Version \"" .. luaVersion
- .. "\" is not recognised by the Tokenizer! Please use one of the following: \"" .. table.concat(util.keys(Enums.Conventions), "\",\"") .. "\"");
+ .. "\" is not recognized by the Tokenizer! Please use one of the following: \"" .. table.concat(util.keys(Enums.Conventions), "\",\"") .. "\"");
end
self.parser = Parser:new({
@@ -157,7 +157,7 @@ end
function Pipeline:apply(code, filename)
local startTime = gettime();
- filename = filename or "Anonymus Script";
+ filename = filename or "Anonymous Script";
logger:info(string.format("Applying Obfuscation Pipeline to %s ...", filename));
-- Seed the Random Generator
if(self.Seed > 0) then
diff --git a/src/prometheus/randomLiterals.lua b/src/prometheus/randomLiterals.lua
index 6f7dad11..97011e92 100644
--- a/src/prometheus/randomLiterals.lua
+++ b/src/prometheus/randomLiterals.lua
@@ -1,6 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
--- Library for Creating Random Literals
+-- randomLiterals.lua
+--
+-- This Script provides a library for creating random literals
local Ast = require("prometheus.ast");
local RandomStrings = require("prometheus.randomStrings");
diff --git a/src/prometheus/randomStrings.lua b/src/prometheus/randomStrings.lua
index 6530bdda..15e11e37 100644
--- a/src/prometheus/randomStrings.lua
+++ b/src/prometheus/randomStrings.lua
@@ -1,3 +1,9 @@
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- randomStrings.lua
+--
+-- This Script provides a library for generating random strings
+
local Ast = require("prometheus.ast")
local utils = require("prometheus.util")
local charset = utils.chararray("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890")
diff --git a/src/prometheus/scope.lua b/src/prometheus/scope.lua
index fad21f60..a0a7bca3 100644
--- a/src/prometheus/scope.lua
+++ b/src/prometheus/scope.lua
@@ -1,6 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- scope.lua
+--
+-- This Script provides a class for the Scope of a Lua Script
local logger = require("logger");
local config = require("config");
@@ -251,7 +253,7 @@ function Scope:addReferenceToHigherScope(scope, id, n, b)
end
local scopeReferences = self.variablesFromHigherScopes[scope];
if scopeReferences[id] then
- scopeReferences[id] = scopeReferences[id] + n;
+ scopeReferences[id] = scopeReferences[id] + n;
else
scopeReferences[id] = n;
end
@@ -274,7 +276,7 @@ function Scope:removeReferenceToHigherScope(scope, id, n, b)
end
local scopeReferences = self.variablesFromHigherScopes[scope];
if scopeReferences[id] then
- scopeReferences[id] = scopeReferences[id] - n;
+ scopeReferences[id] = scopeReferences[id] - n;
else
scopeReferences[id] = 0;
end
diff --git a/src/prometheus/step.lua b/src/prometheus/step.lua
index 4168f2d6..8d83fcbe 100644
--- a/src/prometheus/step.lua
+++ b/src/prometheus/step.lua
@@ -2,7 +2,7 @@
--
-- step.lua
--
--- This file Provides the base class for Obfuscation Steps
+-- This Script provides the base class for Obfuscation Steps
local logger = require("logger");
local util = require("prometheus.util");
diff --git a/src/prometheus/steps.lua b/src/prometheus/steps.lua
index dd9638f2..ae9ac1a8 100644
--- a/src/prometheus/steps.lua
+++ b/src/prometheus/steps.lua
@@ -1,3 +1,9 @@
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- steps.lua
+--
+-- This Script provides a collection of obfuscation steps.
+
return {
WrapInFunction = require("prometheus.steps.WrapInFunction"),
SplitStrings = require("prometheus.steps.SplitStrings"),
@@ -9,4 +15,4 @@ return {
NumbersToExpressions = require("prometheus.steps.NumbersToExpressions"),
AddVararg = require("prometheus.steps.AddVararg"),
WatermarkCheck = require("prometheus.steps.WatermarkCheck"),
-}
+}
\ No newline at end of file
diff --git a/src/prometheus/steps/AddVararg.lua b/src/prometheus/steps/AddVararg.lua
index 8e219a53..b16b72de 100644
--- a/src/prometheus/steps/AddVararg.lua
+++ b/src/prometheus/steps/AddVararg.lua
@@ -13,12 +13,9 @@ local AddVararg = Step:extend();
AddVararg.Description = "This Step Adds Vararg to all Functions";
AddVararg.Name = "Add Vararg";
-AddVararg.SettingsDescriptor = {
-}
+AddVararg.SettingsDescriptor = {}
-function AddVararg:init(settings)
-
-end
+function AddVararg:init(_) end
function AddVararg:apply(ast)
visitast(ast, nil, function(node)
diff --git a/src/prometheus/steps/AntiTamper.lua b/src/prometheus/steps/AntiTamper.lua
index d35cb525..e83fcb01 100644
--- a/src/prometheus/steps/AntiTamper.lua
+++ b/src/prometheus/steps/AntiTamper.lua
@@ -11,8 +11,7 @@ local Enums = require("prometheus.enums")
local logger = require("logger")
local AntiTamper = Step:extend()
-AntiTamper.Description =
- "This Step Breaks your Script when it is modified. This is only effective when using the new VM."
+AntiTamper.Description = "This Step Breaks your Script when it is modified. This is only effective when using the new VM."
AntiTamper.Name = "Anti Tamper"
AntiTamper.SettingsDescriptor = {
diff --git a/src/prometheus/steps/ConstantArray.lua b/src/prometheus/steps/ConstantArray.lua
index 7aaefb2d..cac3b927 100644
--- a/src/prometheus/steps/ConstantArray.lua
+++ b/src/prometheus/steps/ConstantArray.lua
@@ -11,8 +11,8 @@ local Step = require("prometheus.step");
local Ast = require("prometheus.ast");
local Scope = require("prometheus.scope");
local visitast = require("prometheus.visitast");
-local util = require("prometheus.util")
-local Parser = require("prometheus.parser");
+local util = require("prometheus.util")
+local Parser = require("prometheus.parser");
local enums = require("prometheus.enums")
local LuaVersion = enums.LuaVersion;
@@ -23,8 +23,8 @@ ConstantArray.Description = "This Step will Extract all Constants and put them i
ConstantArray.Name = "Constant Array";
ConstantArray.SettingsDescriptor = {
- Treshold = {
- name = "Treshold",
+ Threshold = {
+ name = "Threshold",
description = "The relative amount of nodes that will be affected",
type = "number",
default = 1,
@@ -33,24 +33,24 @@ ConstantArray.SettingsDescriptor = {
},
StringsOnly = {
name = "StringsOnly",
- description = "Wether to only Extract Strings",
+ description = "Whether to only Extract Strings",
type = "boolean",
default = false,
},
Shuffle = {
name = "Shuffle",
- description = "Wether to shuffle the order of Elements in the Array",
+ description = "Whether to shuffle the order of Elements in the Array",
type = "boolean",
default = true,
},
Rotate = {
name = "Rotate",
- description = "Wether to rotate the String Array by a specific (random) amount. This will be undone on runtime.",
+ description = "Whether to rotate the String Array by a specific (random) amount. This will be undone on runtime.",
type = "boolean",
default = true,
},
- LocalWrapperTreshold = {
- name = "LocalWrapperTreshold",
+ LocalWrapperThreshold = {
+ name = "LocalWrapperThreshold",
description = "The relative amount of nodes functions, that will get local wrappers",
type = "number",
default = 1,
@@ -59,7 +59,7 @@ ConstantArray.SettingsDescriptor = {
},
LocalWrapperCount = {
name = "LocalWrapperCount",
- description = "The number of Local wrapper Functions per scope. This only applies if LocalWrapperTreshold is greater than 0",
+ description = "The number of Local wrapper Functions per scope. This only applies if LocalWrapperThreshold is greater than 0",
type = "number",
min = 0,
max = 512,
@@ -87,7 +87,7 @@ ConstantArray.SettingsDescriptor = {
default = "base64",
values = {
"none",
- "base64",
+ "base64"
},
}
}
@@ -100,7 +100,7 @@ local function callNameGenerator(generatorFunction, ...)
end
function ConstantArray:init(settings)
-
+
end
function ConstantArray:createArray()
@@ -135,7 +135,7 @@ function ConstantArray:indexing(index, data)
Ast.StringExpression(wrapper.index)
), args);
else
- data.scope:addReferenceToHigherScope(self.rootScope, self.wrapperId);
+ data.scope:addReferenceToHigherScope(self.rootScope, self.wrapperId);
return Ast.FunctionCallExpression(Ast.VariableExpression(self.rootScope, self.wrapperId), {
Ast.NumberExpression(index - self.wrapperOffset);
});
@@ -167,7 +167,7 @@ local function reverse(t, i, j)
i, j = i+1, j-1
end
end
-
+
local function rotate(t, d, n)
n = n or #t
d = (d or 1) % n
@@ -198,7 +198,7 @@ function ConstantArray:addRotateCode(ast, shift)
data.scope:removeReferenceToHigherScope(node.scope, node.id);
data.scope:addReferenceToHigherScope(self.rootScope, self.arrId);
node.scope = self.rootScope;
- node.id = self.arrId;
+ node.id = self.arrId;
end
end
end)
@@ -271,7 +271,7 @@ function ConstantArray:addDecodeCode(ast)
data.scope:removeReferenceToHigherScope(node.scope, node.id);
data.scope:addReferenceToHigherScope(self.rootScope, self.arrId);
node.scope = self.rootScope;
- node.id = self.arrId;
+ node.id = self.arrId;
end
if(node.scope:getVariableName(node.id) == "LOOKUP_TABLE") then
@@ -280,7 +280,7 @@ function ConstantArray:addDecodeCode(ast)
end
end
end)
-
+
table.insert(ast.body.statements, 1, forStat);
end
end
@@ -298,7 +298,7 @@ end
function ConstantArray:encode(str)
if self.Encoding == "base64" then
- return ((str:gsub('.', function(x)
+ return ((str:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
@@ -313,7 +313,7 @@ end
function ConstantArray:apply(ast, pipeline)
self.rootScope = ast.body.scope;
- self.arrId = self.rootScope:addVariable();
+ self.arrId = self.rootScope:addVariable();
self.base64chars = table.concat(util.shuffle{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
@@ -323,12 +323,12 @@ function ConstantArray:apply(ast, pipeline)
});
self.constants = {};
- self.lookup = {};
+ self.lookup = {};
-- Extract Constants
visitast(ast, nil, function(node, data)
-- Apply only to some nodes
- if math.random() <= self.Treshold then
+ if math.random() <= self.Threshold then
node.__apply_constant_array = true;
if node.kind == AstKind.StringExpression then
self:addConstant(node.value);
@@ -336,7 +336,7 @@ function ConstantArray:apply(ast, pipeline)
if node.isConstant then
if node.value ~= nil then
self:addConstant(node.value);
- end
+ end
end
end
end
@@ -345,7 +345,7 @@ function ConstantArray:apply(ast, pipeline)
-- Shuffle Array
if self.Shuffle then
self.constants = util.shuffle(self.constants);
- self.lookup = {};
+ self.lookup = {};
for i, v in ipairs(self.constants) do
self.lookup[v] = i;
end
@@ -353,11 +353,11 @@ function ConstantArray:apply(ast, pipeline)
-- Set Wrapper Function Offset
self.wrapperOffset = math.random(-self.MaxWrapperOffset, self.MaxWrapperOffset);
- self.wrapperId = self.rootScope:addVariable();
+ self.wrapperId = self.rootScope:addVariable();
visitast(ast, function(node, data)
-- Add Local Wrapper Functions
- if self.LocalWrapperCount > 0 and node.kind == AstKind.Block and node.isFunctionBlock and math.random() <= self.LocalWrapperTreshold then
+ if self.LocalWrapperCount > 0 and node.kind == AstKind.Block and node.isFunctionBlock and math.random() <= self.LocalWrapperThreshold then
local id = node.scope:addVariable()
data.functionData.local_wrappers = {
id = id;
@@ -375,9 +375,9 @@ function ConstantArray:apply(ast, pipeline)
local argPos = math.random(1, self.LocalWrapperArgCount);
data.functionData.local_wrappers[i] = {
- arg = argPos,
+ arg = argPos,
index = name,
- offset = offset,
+ offset = offset,
};
data.functionData.__used = false;
end
@@ -407,7 +407,7 @@ function ConstantArray:apply(ast, pipeline)
local wrapper = wrappers[i];
local argPos = wrapper.arg;
local offset = wrapper.offset;
- local name = wrapper.index;
+ local name = wrapper.index;
local funcScope = Scope:new(node.scope);
@@ -461,7 +461,7 @@ function ConstantArray:apply(ast, pipeline)
local steps = util.shuffle({
-- Add Wrapper Function Code
- function()
+ function()
local funcScope = Scope:new(self.rootScope);
-- Add Reference to Array
funcScope:addReferenceToHigherScope(self.rootScope, self.arrId);
@@ -512,10 +512,9 @@ function ConstantArray:apply(ast, pipeline)
table.insert(ast.body.statements, 1, Ast.LocalVariableDeclaration(self.rootScope, {self.arrId}, {self:createArray()}));
self.rootScope = nil;
- self.arrId = nil;
-
+ self.arrId = nil;
self.constants = nil;
- self.lookup = nil;
+ self.lookup = nil;
end
return ConstantArray;
\ No newline at end of file
diff --git a/src/prometheus/steps/EncryptStrings.lua b/src/prometheus/steps/EncryptStrings.lua
index af4e5c80..db2a7bc0 100644
--- a/src/prometheus/steps/EncryptStrings.lua
+++ b/src/prometheus/steps/EncryptStrings.lua
@@ -6,13 +6,10 @@
local Step = require("prometheus.step")
local Ast = require("prometheus.ast")
-local Scope = require("prometheus.scope")
-local RandomStrings = require("prometheus.randomStrings")
local Parser = require("prometheus.parser")
local Enums = require("prometheus.enums")
-local logger = require("logger")
local visitast = require("prometheus.visitast");
-local util = require("prometheus.util")
+local util = require("prometheus.util")
local AstKind = Ast.AstKind;
local EncryptStrings = Step:extend()
@@ -21,10 +18,10 @@ EncryptStrings.Name = "Encrypt Strings"
EncryptStrings.SettingsDescriptor = {}
-function EncryptStrings:init(settings) end
+function EncryptStrings:init(_) end
-function EncryptStrings:CreateEncrypionService()
+function EncryptStrings:CreateEncryptionService()
local usedSeeds = {};
local secret_key_6 = math.random(0, 63) -- 6-bit arbitrary integer (0..63)
@@ -107,17 +104,16 @@ function EncryptStrings:CreateEncrypionService()
local function genCode()
local code = [[
do
- local floor = math.floor
- local random = math.random;
- local remove = table.remove;
- local char = string.char;
- local state_45 = 0
- local state_8 = 2
- local digits = {}
- local charmap = {};
- local i = 0;
-
- local nums = {};
+ ]] .. table.concat(util.shuffle{
+ "local floor = math.floor",
+ "local random = math.random",
+ "local remove = table.remove",
+ "local char = string.char",
+ "local state_45 = 0",
+ "local state_8 = 2",
+ "local charmap = {}",
+ "local nums = {}"
+ }, "\n") .. [[
for i = 1, 256 do
nums[i] = i;
end
@@ -136,17 +132,19 @@ do
state_8 = state_8 * ]] .. tostring(param_mul_8) .. [[ % 257
until state_8 ~= 1
local r = state_8 % 32
- local n = floor(state_45 / 2 ^ (13 - (state_8 - r) / 32)) % 2 ^ 32 / 2 ^ r
- local rnd = floor(n % 1 * 2 ^ 32) + floor(n)
+ local shift = 13 - (state_8 - r) / 32
+ local n = floor(state_45 / 2 ^ shift) % 4294967296 / 2 ^ r
+ local rnd = floor(n % 1 * 4294967296) + floor(n)
local low_16 = rnd % 65536
local high_16 = (rnd - low_16) / 65536
- local b1 = low_16 % 256
- local b2 = (low_16 - b1) / 256
- local b3 = high_16 % 256
- local b4 = (high_16 - b3) / 256
- prev_values = { b1, b2, b3, b4 }
+ prev_values = { low_16 % 256, (low_16 - low_16 % 256) / 256, high_16 % 256, (high_16 - high_16 % 256) / 256 }
end
- return table.remove(prev_values)
+
+
+ local prevValuesLen = #prev_values;
+ local removed = prev_values[prevValuesLen];
+ prev_values[prevValuesLen] = nil;
+ return removed;
end
local realStrings = {};
@@ -156,18 +154,20 @@ do
});
function DECRYPT(str, seed)
local realStringsLocal = realStrings;
- if(realStringsLocal[seed]) then else
+ if(realStringsLocal[seed]) then return seed; else
prev_values = {};
local chars = charmap;
state_45 = seed % 35184372088832
state_8 = seed % 255 + 2
- local len = string.len(str);
+ local len = #str;
realStringsLocal[seed] = "";
local prevVal = ]] .. tostring(secret_key_8) .. [[;
- for i=1, len do
+ local s = "";
+ for i=1, len, 1 do
prevVal = (string.byte(str, i) + get_next_pseudo_random_byte() + prevVal) % 256
- realStringsLocal[seed] = realStringsLocal[seed] .. chars[prevVal + 1];
+ s = s .. chars[prevVal + 1];
end
+ realStringsLocal[seed] = s;
end
return seed;
end
@@ -186,8 +186,8 @@ end]]
}
end
-function EncryptStrings:apply(ast, pipeline)
- local Encryptor = self:CreateEncrypionService();
+function EncryptStrings:apply(ast, _)
+ local Encryptor = self:CreateEncryptionService();
local code = Encryptor.genCode();
local newAst = Parser:new({ LuaVersion = Enums.LuaVersion.Lua51 }):parse(code);
@@ -196,7 +196,7 @@ function EncryptStrings:apply(ast, pipeline)
local scope = ast.body.scope;
local decryptVar = scope:addVariable();
local stringsVar = scope:addVariable();
-
+
doStat.body.scope:setParent(ast.body.scope);
visitast(newAst, nil, function(node, data)
@@ -205,7 +205,7 @@ function EncryptStrings:apply(ast, pipeline)
data.scope:removeReferenceToHigherScope(node.scope, node.id);
data.scope:addReferenceToHigherScope(scope, decryptVar);
node.scope = scope;
- node.id = decryptVar;
+ node.id = decryptVar;
end
end
if(node.kind == AstKind.AssignmentVariable or node.kind == AstKind.VariableExpression) then
@@ -213,7 +213,7 @@ function EncryptStrings:apply(ast, pipeline)
data.scope:removeReferenceToHigherScope(node.scope, node.id);
data.scope:addReferenceToHigherScope(scope, stringsVar);
node.scope = scope;
- node.id = stringsVar;
+ node.id = stringsVar;
end
end
end)
diff --git a/src/prometheus/steps/NumbersToExpressions.lua b/src/prometheus/steps/NumbersToExpressions.lua
index 996cda98..bdc21ea7 100644
--- a/src/prometheus/steps/NumbersToExpressions.lua
+++ b/src/prometheus/steps/NumbersToExpressions.lua
@@ -3,80 +3,129 @@
-- NumbersToExpressions.lua
--
-- This Script provides an Obfuscation Step, that converts Number Literals to expressions
-unpack = unpack or table.unpack;
+unpack = unpack or table.unpack
-local Step = require("prometheus.step");
-local Ast = require("prometheus.ast");
-local Scope = require("prometheus.scope");
-local visitast = require("prometheus.visitast");
-local util = require("prometheus.util")
+local Step = require("prometheus.step")
+local Ast = require("prometheus.ast")
+local visitast = require("prometheus.visitast")
+local util = require("prometheus.util")
-local AstKind = Ast.AstKind;
+local AstKind = Ast.AstKind
-local NumbersToExpressions = Step:extend();
-NumbersToExpressions.Description = "This Step Converts number Literals to Expressions";
-NumbersToExpressions.Name = "Numbers To Expressions";
+local NumbersToExpressions = Step:extend()
+NumbersToExpressions.Description = "This Step Converts number Literals to Expressions"
+NumbersToExpressions.Name = "Numbers To Expressions"
NumbersToExpressions.SettingsDescriptor = {
- Treshold = {
- type = "number",
- default = 1,
- min = 0,
- max = 1,
- },
- InternalTreshold = {
- type = "number",
- default = 0.2,
- min = 0,
- max = 0.8,
- }
+ Threshold = {
+ type = "number",
+ default = 1,
+ min = 0,
+ max = 1,
+ },
+ InternalThreshold = {
+ type = "number",
+ default = 0.2,
+ min = 0,
+ max = 0.8,
+ },
}
+--[[
+ This function removes trailing zeros from a floating point number
+]]
+local function filterNumber(number)
+ local formatted = string.format("%.50f", number)
+ formatted = formatted:gsub("%.?0+$", "")
+ if formatted:sub(-1) == "." then
+ formatted = formatted:sub(1, -2)
+ end
+ return formatted
+end
+
+local function generateModuloExpression(n)
+ local rhs = n + math.random(1, 100)
+ local multiplier = math.random(1, 10)
+ local lhs = n + (multiplier * rhs)
+ return lhs, rhs
+end
+
function NumbersToExpressions:init(settings)
self.ExpressionGenerators = {
- function(val, depth) -- Addition
- local val2 = math.random(-2^20, 2^20);
- local diff = val - val2;
- if tonumber(tostring(diff)) + tonumber(tostring(val2)) ~= val then
- return false;
- end
- return Ast.AddExpression(self:CreateNumberExpression(val2, depth), self:CreateNumberExpression(diff, depth), false);
- end,
- function(val, depth) -- Subtraction
- local val2 = math.random(-2^20, 2^20);
- local diff = val + val2;
- if tonumber(tostring(diff)) - tonumber(tostring(val2)) ~= val then
- return false;
- end
- return Ast.SubExpression(self:CreateNumberExpression(diff, depth), self:CreateNumberExpression(val2, depth), false);
- end
- }
+ function(val, depth) -- Addition
+ local val2 = math.random(-2 ^ 20, 2 ^ 20)
+ local diff = val - val2
+ if tonumber(tostring(diff)) + tonumber(tostring(val2)) ~= val then
+ return false
+ end
+ return Ast.AddExpression(
+ self:CreateNumberExpression(val2, depth),
+ self:CreateNumberExpression(diff, depth),
+ false
+ )
+ end,
+ function(val, depth) -- Subtraction
+ local val2 = math.random(-2 ^ 20, 2 ^ 20)
+ local diff = val + val2
+ if tonumber(tostring(diff)) - tonumber(tostring(val2)) ~= val then
+ return false
+ end
+ return Ast.SubExpression(
+ self:CreateNumberExpression(diff, depth),
+ self:CreateNumberExpression(val2, depth),
+ false
+ )
+ end,
+ function(val, depth) -- Multiplication
+ local val2 = math.random(-2 ^ 20, 2 ^ 20)
+ local product = val * val2
+ if tonumber(tostring(product)) ~= val then
+ return false
+ end
+ return Ast.MulExpression(
+ self:CreateNumberExpression(val2, depth),
+ self:CreateNumberExpression(product, depth),
+ false
+ )
+ end,
+ function(val, depth) -- Advanced Modulo
+ if val <= 0 then
+ return false
+ end
+ local lhs, rhs = generateModuloExpression(val)
+ return Ast.ModExpression(
+ Ast.NumberExpression(filterNumber(lhs)),
+ Ast.NumberExpression(filterNumber(rhs)),
+ false
+ )
+ end,
+ }
end
function NumbersToExpressions:CreateNumberExpression(val, depth)
- if depth > 0 and math.random() >= self.InternalTreshold or depth > 15 then
- return Ast.NumberExpression(val)
- end
+ if depth > 0 and math.random() >= self.InternalThreshold or depth > 15 then
+ return Ast.NumberExpression(val)
+ end
- local generators = util.shuffle({unpack(self.ExpressionGenerators)});
- for i, generator in ipairs(generators) do
- local node = generator(val, depth + 1);
- if node then
- return node;
- end
- end
+ local generators = util.shuffle({ unpack(self.ExpressionGenerators) })
+ for i, generator in ipairs(generators) do
+ local node = generator(val, depth + 1)
+ if node then
+ return node
+ end
+ end
- return Ast.NumberExpression(val)
+ return Ast.NumberExpression(val)
end
function NumbersToExpressions:apply(ast)
visitast(ast, nil, function(node, data)
- if node.kind == AstKind.NumberExpression then
- if math.random() <= self.Treshold then
- return self:CreateNumberExpression(node.value, 0);
- end
- end
- end)
+ if node.kind == AstKind.NumberExpression then
+ if math.random() <= self.Threshold then
+ return self:CreateNumberExpression(node.value, 0)
+ end
+ end
+ end)
end
-return NumbersToExpressions;
\ No newline at end of file
+return NumbersToExpressions
diff --git a/src/prometheus/steps/ProxifyLocals.lua b/src/prometheus/steps/ProxifyLocals.lua
index e6b5459b..3b484420 100644
--- a/src/prometheus/steps/ProxifyLocals.lua
+++ b/src/prometheus/steps/ProxifyLocals.lua
@@ -12,11 +12,11 @@ local RandomLiterals = require("prometheus.randomLiterals")
local AstKind = Ast.AstKind;
-local ProifyLocals = Step:extend();
-ProifyLocals.Description = "This Step wraps all locals into Proxy Objects";
-ProifyLocals.Name = "Proxify Locals";
+local ProxifyLocals = Step:extend();
+ProxifyLocals.Description = "This Step wraps all locals into Proxy Objects";
+ProxifyLocals.Name = "Proxify Locals";
-ProifyLocals.SettingsDescriptor = {
+ProxifyLocals.SettingsDescriptor = {
LiteralType = {
name = "LiteralType",
description = "The type of the randomly generated literals",
@@ -83,14 +83,12 @@ local MetatableExpressions = {
}
}
-function ProifyLocals:init(settings)
-
-end
+function ProxifyLocals:init(_) end
local function generateLocalMetatableInfo(pipeline)
local usedOps = {};
local info = {};
- for i, v in ipairs({"setValue","getValue", "index"}) do
+ for i, v in ipairs({"setValue", "getValue", "index"}) do
local rop;
repeat
rop = MetatableExpressions[math.random(#MetatableExpressions)];
@@ -104,7 +102,7 @@ local function generateLocalMetatableInfo(pipeline)
return info;
end
-function ProifyLocals:CreateAssignmentExpression(info, expr, parentScope)
+function ProxifyLocals:CreateAssignmentExpression(info, expr, parentScope)
local metatableVals = {};
-- Setvalue Entry
@@ -164,7 +162,7 @@ function ProifyLocals:CreateAssignmentExpression(info, expr, parentScope)
);
end
-function ProifyLocals:apply(ast, pipeline)
+function ProxifyLocals:apply(ast, pipeline)
local localMetatableInfos = {};
local function getLocalMetatableInfo(scope, id)
-- Global Variables should not be transformed
@@ -193,12 +191,12 @@ function ProifyLocals:apply(ast, pipeline)
-- Create Setmetatable Variable
self.setMetatableVarScope = ast.body.scope;
- self.setMetatableVarId = ast.body.scope:addVariable();
+ self.setMetatableVarId = ast.body.scope:addVariable();
-- Create Empty Function Variable
- self.emptyFunctionScope = ast.body.scope;
- self.emptyFunctionId = ast.body.scope:addVariable();
- self.emptyFunctionUsed = false;
+ self.emptyFunctionScope = ast.body.scope;
+ self.emptyFunctionId = ast.body.scope:addVariable();
+ self.emptyFunctionUsed = false;
-- Add Empty Function Declaration
table.insert(ast.body.statements, 1, Ast.LocalVariableDeclaration(self.emptyFunctionScope, {self.emptyFunctionId}, {
@@ -248,7 +246,7 @@ function ProifyLocals:apply(ast, pipeline)
for i, id in ipairs(node.ids) do
local expr = node.expressions[i] or Ast.NilExpression();
local localMetatableInfo = getLocalMetatableInfo(node.scope, id);
- -- Apply Only to Some Variables if Treshold is non 1
+ -- Apply Only to Some Variables if Threshold is non 1
if localMetatableInfo then
local newExpr = self:CreateAssignmentExpression(localMetatableInfo, expr, node.scope);
node.expressions[i] = newExpr;
@@ -259,7 +257,7 @@ function ProifyLocals:apply(ast, pipeline)
-- Variable Expression
if(node.kind == AstKind.VariableExpression and not node.__ignoreProxifyLocals) then
local localMetatableInfo = getLocalMetatableInfo(node.scope, node.id);
- -- Apply Only to Some Variables if Treshold is non 1
+ -- Apply Only to Some Variables if Threshold is non 1
if localMetatableInfo then
local literal;
if self.LiteralType == "dictionary" then
@@ -278,7 +276,7 @@ function ProifyLocals:apply(ast, pipeline)
-- Assignment Variable for Assignment Statement
if(node.kind == AstKind.AssignmentVariable) then
local localMetatableInfo = getLocalMetatableInfo(node.scope, node.id);
- -- Apply Only to Some Variables if Treshold is non 1
+ -- Apply Only to Some Variables if Threshold is non 1
if localMetatableInfo then
return Ast.AssignmentIndexing(node, Ast.StringExpression(localMetatableInfo.valueName));
end
@@ -287,7 +285,7 @@ function ProifyLocals:apply(ast, pipeline)
-- Local Function Declaration
if(node.kind == AstKind.LocalFunctionDeclaration) then
local localMetatableInfo = getLocalMetatableInfo(node.scope, node.id);
- -- Apply Only to Some Variables if Treshold is non 1
+ -- Apply Only to Some Variables if Threshold is non 1
if localMetatableInfo then
local funcLiteral = Ast.FunctionLiteralExpression(node.args, node.body);
local newExpr = self:CreateAssignmentExpression(localMetatableInfo, funcLiteral, node.scope);
@@ -310,4 +308,4 @@ function ProifyLocals:apply(ast, pipeline)
}));
end
-return ProifyLocals;
\ No newline at end of file
+return ProxifyLocals;
\ No newline at end of file
diff --git a/src/prometheus/steps/SplitStrings.lua b/src/prometheus/steps/SplitStrings.lua
index a9a5a5f8..6dfffd17 100644
--- a/src/prometheus/steps/SplitStrings.lua
+++ b/src/prometheus/steps/SplitStrings.lua
@@ -18,8 +18,8 @@ SplitStrings.Description = "This Step splits Strings to a specific or random len
SplitStrings.Name = "Split Strings";
SplitStrings.SettingsDescriptor = {
- Treshold = {
- name = "Treshold",
+ Threshold = {
+ name = "Threshold",
description = "The relative amount of nodes that will be affected",
type = "number",
default = 1,
@@ -56,7 +56,7 @@ SplitStrings.SettingsDescriptor = {
CustomFunctionType = {
name = "CustomFunctionType",
description = "The Type of Function code injection This Option only applies when custom Concatenation is selected.\
-Note that when chosing inline, the code size may increase significantly!",
+Note that when choosing inline, the code size may increase significantly!",
type = "enum",
values = {
"global",
@@ -83,7 +83,7 @@ local function generateTableConcatNode(chunks, data)
end
local tb = Ast.TableConstructorExpression(chunkNodes);
data.scope:addReferenceToHigherScope(data.tableConcatScope, data.tableConcatId);
- return Ast.FunctionCallExpression(Ast.VariableExpression(data.tableConcatScope, data.tableConcatId), {tb});
+ return Ast.FunctionCallExpression(Ast.VariableExpression(data.tableConcatScope, data.tableConcatId), {tb});
end
local function generateStrCatNode(chunks)
@@ -127,32 +127,32 @@ local function generateCustomNodeArgs(chunks, data, variant)
shuffledIndices[i] = i;
end
util.shuffle(shuffledIndices);
-
+
for i, v in ipairs(shuffledIndices) do
shuffled[v] = chunks[i];
end
-
+
-- Custom Function Type 1
if variant == 1 then
local args = {};
local tbNodes = {};
-
+
for i, v in ipairs(shuffledIndices) do
table.insert(args, Ast.TableEntry(Ast.NumberExpression(v)));
end
-
+
for i, chunk in ipairs(shuffled) do
table.insert(tbNodes, Ast.TableEntry(Ast.StringExpression(chunk)));
end
-
+
local tb = Ast.TableConstructorExpression(tbNodes);
-
+
table.insert(args, Ast.TableEntry(tb));
return {Ast.TableConstructorExpression(args)};
-
+
-- Custom Function Type 2
else
-
+
local args = {};
for i, v in ipairs(shuffledIndices) do
table.insert(args, Ast.TableEntry(Ast.NumberExpression(v)));
@@ -162,7 +162,7 @@ local function generateCustomNodeArgs(chunks, data, variant)
end
return {Ast.TableConstructorExpression(args)};
end
-
+
end
local function generateCustomFunctionLiteral(parentScope, variant)
@@ -177,7 +177,7 @@ local function generateCustomFunctionLiteral(parentScope, variant)
local funcArgs = funcDeclNode.args;
funcBody.scope:setParent(parentScope);
return Ast.FunctionLiteralExpression(funcArgs, funcBody);
-
+
-- Custom Function Type 2
else
local funcDeclNode = parser:parse(custom2Code).body.statements[1];
@@ -192,7 +192,7 @@ local function generateGlobalCustomFunctionDeclaration(ast, data)
local parser = Parser:new({
LuaVersion = LuaVersion.Lua52;
});
-
+
-- Custom Function Type 1
if data.customFunctionVariant == 1 then
local astScope = ast.body.scope;
@@ -220,8 +220,8 @@ end
function SplitStrings:apply(ast, pipeline)
local data = {};
-
-
+
+
if(self.ConcatenationType == "table") then
local scope = ast.body.scope;
local id = scope:addVariable();
@@ -237,14 +237,14 @@ function SplitStrings:apply(ast, pipeline)
data.customFunctionVariant = self:variant();
end
end
-
-
+
+
local customLocalFunctionsCount = self.CustomLocalFunctionsCount;
local self2 = self;
-
- visitAst(ast, function(node, data)
+
+ visitAst(ast, function(node, data)
-- Previsit Function
-
+
-- Create Local Function declarations
if(self.ConcatenationType == "custom" and data.customFunctionType == "local" and node.kind == Ast.AstKind.Block and node.isFunctionBlock) then
data.functionData.localFunctions = {};
@@ -260,10 +260,10 @@ function SplitStrings:apply(ast, pipeline)
});
end
end
-
+
end, function(node, data)
-- PostVisit Function
-
+
-- Create actual function literals for local customFunctionType
if(self.ConcatenationType == "custom" and data.customFunctionType == "local" and node.kind == Ast.AstKind.Block and node.isFunctionBlock) then
for i, func in ipairs(data.functionData.localFunctions) do
@@ -273,23 +273,23 @@ function SplitStrings:apply(ast, pipeline)
end
end
end
-
-
+
+
-- Apply Only to String nodes
if(node.kind == Ast.AstKind.StringExpression) then
local str = node.value;
local chunks = {};
local i = 1;
-
+
-- Split String into Parts of length between MinLength and MaxLength
while i <= string.len(str) do
local len = math.random(self.MinLength, self.MaxLength);
table.insert(chunks, string.sub(str, i, i + len - 1));
i = i + len;
end
-
+
if(#chunks > 1) then
- if math.random() < self.Treshold then
+ if math.random() < self.Threshold then
if self.ConcatenationType == "strcat" then
node = generateStrCatNode(chunks);
elseif self.ConcatenationType == "table" then
@@ -318,17 +318,17 @@ function SplitStrings:apply(ast, pipeline)
end
end
end
-
+
return node, true;
end
end, data)
-
-
+
+
if(self.ConcatenationType == "table") then
local globalScope = data.globalScope;
local tableScope, tableId = globalScope:resolve("table")
ast.body.scope:addReferenceToHigherScope(globalScope, tableId);
- table.insert(ast.body.statements, 1, Ast.LocalVariableDeclaration(data.tableConcatScope, {data.tableConcatId},
+ table.insert(ast.body.statements, 1, Ast.LocalVariableDeclaration(data.tableConcatScope, {data.tableConcatId},
{Ast.IndexExpression(Ast.VariableExpression(tableScope, tableId), Ast.StringExpression("concat"))}));
elseif(self.ConcatenationType == "custom" and self.CustomFunctionType == "global") then
table.insert(ast.body.statements, 1, generateGlobalCustomFunctionDeclaration(ast, data));
diff --git a/src/prometheus/steps/Vmify.lua b/src/prometheus/steps/Vmify.lua
index e1e1fffa..bd1f0d5d 100644
--- a/src/prometheus/steps/Vmify.lua
+++ b/src/prometheus/steps/Vmify.lua
@@ -12,17 +12,14 @@ local Vmify = Step:extend();
Vmify.Description = "This Step will Compile your script into a fully-custom (not a half custom like other lua obfuscators) Bytecode Format and emit a vm for executing it.";
Vmify.Name = "Vmify";
-Vmify.SettingsDescriptor = {
-}
+Vmify.SettingsDescriptor = {}
-function Vmify:init(settings)
-
-end
+function Vmify:init(_) end
function Vmify:apply(ast)
-- Create Compiler
local compiler = Compiler:new();
-
+
-- Compile the Script into a bytecode vm
return compiler:compile(ast);
end
diff --git a/src/prometheus/steps/WatermarkCheck.lua b/src/prometheus/steps/WatermarkCheck.lua
index c50158cc..d12a83b6 100644
--- a/src/prometheus/steps/WatermarkCheck.lua
+++ b/src/prometheus/steps/WatermarkCheck.lua
@@ -29,9 +29,7 @@ local function callNameGenerator(generatorFunction, ...)
return generatorFunction(...);
end
-function WatermarkCheck:init(settings)
-
-end
+function WatermarkCheck:init(_) end
function WatermarkCheck:apply(ast, pipeline)
self.CustomVariable = "_" .. callNameGenerator(pipeline.namegenerator, math.random(10000000000, 100000000000));
diff --git a/src/prometheus/steps/WrapInFunction.lua b/src/prometheus/steps/WrapInFunction.lua
index 850a3059..26c2b7be 100644
--- a/src/prometheus/steps/WrapInFunction.lua
+++ b/src/prometheus/steps/WrapInFunction.lua
@@ -23,9 +23,7 @@ WrapInFunction.SettingsDescriptor = {
}
}
-function WrapInFunction:init(settings)
-
-end
+function WrapInFunction:init(_) end
function WrapInFunction:apply(ast)
for i = 1, self.Iterations, 1 do
diff --git a/src/prometheus/tokenizer.lua b/src/prometheus/tokenizer.lua
index 865bc95d..c6b2a324 100644
--- a/src/prometheus/tokenizer.lua
+++ b/src/prometheus/tokenizer.lua
@@ -28,12 +28,12 @@ Tokenizer.ANNOTATION_START_CHARS = lookupify(chararray("!@"))
Tokenizer.Conventions = Enums.Conventions;
Tokenizer.TokenKind = {
- Eof = "Eof",
+ Eof = "Eof",
Keyword = "Keyword",
- Symbol = "Symbol",
- Ident = "Identifier",
- Number = "Number",
- String = "String",
+ Symbol = "Symbol",
+ Ident = "Identifier",
+ Number = "Number",
+ String = "String",
}
Tokenizer.EOF_TOKEN = {
@@ -49,13 +49,13 @@ local function token(self, startPos, kind, value)
local annotations = self.annotations
self.annotations = {};
return {
- kind = kind,
- value = value,
+ kind = kind,
+ value = value,
startPos = startPos,
- endPos = self.index,
- source = self.source:sub(startPos + 1, self.index),
- line = line,
- linePos = linePos,
+ endPos = self.index,
+ source = self.source:sub(startPos + 1, self.index),
+ line = line,
+ linePos = linePos,
annotations = annotations,
}
end
@@ -72,7 +72,7 @@ end
function Tokenizer:getPosition(i)
local column = self.columnMap[i]
- if not column then --// `i` is bigger than self.length, this shouldnt happen, but it did. (Theres probably some error in the tokenizer, cant find it.)
+ if not column then --// `i` is bigger than self.length, this shouldn't happen, but it did. (Theres probably some error in the tokenizer, cant find it.)
column = self.columnMap[#self.columnMap]
end
@@ -106,42 +106,42 @@ function Tokenizer:new(settings)
local conventions = Tokenizer.Conventions[luaVersion];
if(conventions == nil) then
- logger:error("The Lua Version \"" .. luaVersion .. "\" is not recognised by the Tokenizer! Please use one of the following: \"" .. table.concat(keys(Tokenizer.Conventions), "\",\"") .. "\"");
+ logger:error("The Lua Version \"" .. luaVersion .. "\" is not recognized by the Tokenizer! Please use one of the following: \"" .. table.concat(keys(Tokenizer.Conventions), "\",\"") .. "\"");
end
local tokenizer = {
- index = 0, -- Index where the current char is read
+ index = 0, -- Index where the current char is read
length = 0,
source = "", -- Source to Tokenize
luaVersion = luaVersion, -- LuaVersion to be used while Tokenizing
conventions = conventions;
- NumberChars = conventions.NumberChars,
+ NumberChars = conventions.NumberChars,
NumberCharsLookup = lookupify(conventions.NumberChars),
- Keywords = conventions.Keywords,
- KeywordsLookup = lookupify(conventions.Keywords),
+ Keywords = conventions.Keywords,
+ KeywordsLookup = lookupify(conventions.Keywords),
BinaryNumberChars = conventions.BinaryNumberChars,
BinaryNumberCharsLookup = lookupify(conventions.BinaryNumberChars);
- BinaryNums = conventions.BinaryNums,
- HexadecimalNums = conventions.HexadecimalNums,
- HexNumberChars = conventions.HexNumberChars,
+ BinaryNums = conventions.BinaryNums,
+ HexadecimalNums = conventions.HexadecimalNums,
+ HexNumberChars = conventions.HexNumberChars,
HexNumberCharsLookup = lookupify(conventions.HexNumberChars),
- DecimalExponent = conventions.DecimalExponent,
+ DecimalExponent = conventions.DecimalExponent,
DecimalSeperators = conventions.DecimalSeperators,
- IdentChars = conventions.IdentChars,
- IdentCharsLookup = lookupify(conventions.IdentChars),
+ IdentChars = conventions.IdentChars,
+ IdentCharsLookup = lookupify(conventions.IdentChars),
- EscapeSequences = conventions.EscapeSequences,
- NumericalEscapes = conventions.NumericalEscapes,
+ EscapeSequences = conventions.EscapeSequences,
+ NumericalEscapes = conventions.NumericalEscapes,
EscapeZIgnoreNextWhitespace = conventions.EscapeZIgnoreNextWhitespace,
- HexEscapes = conventions.HexEscapes,
- UnicodeEscapes = conventions.UnicodeEscapes,
+ HexEscapes = conventions.HexEscapes,
+ UnicodeEscapes = conventions.UnicodeEscapes,
- SymbolChars = conventions.SymbolChars,
+ SymbolChars = conventions.SymbolChars,
SymbolCharsLookup = lookupify(conventions.SymbolChars),
- MaxSymbolLength = conventions.MaxSymbolLength,
- Symbols = conventions.Symbols,
- SymbolsLookup = lookupify(conventions.Symbols),
+ MaxSymbolLength = conventions.MaxSymbolLength,
+ Symbols = conventions.Symbols,
+ SymbolsLookup = lookupify(conventions.Symbols),
StringStartLookup = lookupify({"\"", "\'"}),
annotations = {},
@@ -299,7 +299,7 @@ end
-- Lex the next token as a Number
function Tokenizer:number()
local startPos = self.index;
- local source = expect(self, setmetatable({["."] = true}, {__index = self.NumberCharsLookup}));
+ local source = expect(self, setmetatable({["."] = true}, {__index = self.NumberCharsLookup}));
if source == "0" then
if self.BinaryNums and is(self, lookupify(self.BinaryNums)) then
diff --git a/src/prometheus/unparser.lua b/src/prometheus/unparser.lua
index 315cd66c..c932fd11 100644
--- a/src/prometheus/unparser.lua
+++ b/src/prometheus/unparser.lua
@@ -12,8 +12,8 @@
--
local config = require("config");
-local Ast = require("prometheus.ast");
-local Enums = require("prometheus.enums");
+local Ast = require("prometheus.ast");
+local Enums = require("prometheus.enums");
local util = require("prometheus.util");
local logger = require("logger");
@@ -42,7 +42,7 @@ function Unparser:new(settings)
prettyPrint = settings and settings.PrettyPrint or false;
notIdentPattern = "[^" .. table.concat(conventions.IdentChars, "") .. "]";
numberPattern = "^[" .. table.concat(conventions.NumberChars, "") .. "]";
- highlight = settings and settings.Highlight or false;
+ highlight = settings and settings.Highlight or false;
keywordsLookup = lookupify(conventions.Keywords);
}
@@ -151,7 +151,6 @@ function Unparser:unparseStatement(statement, tabbing)
elseif(statement.kind == AstKind.BreakStatement) then
code = "break";
-
-- Do Statement
elseif(statement.kind == AstKind.DoStatement) then
local bodyCode = self:unparseBlock(statement.body, tabbing);
@@ -165,7 +164,6 @@ function Unparser:unparseStatement(statement, tabbing)
local bodyCode = self:unparseBlock(statement.body, tabbing);
-
code = "while" .. self:whitespaceIfNeeded(expressionCode) .. expressionCode .. self:whitespaceIfNeeded2(expressionCode)
.. "do" .. self:whitespaceIfNeeded(bodyCode, self:newline(true))
.. bodyCode .. self:newline(false)
@@ -404,37 +402,16 @@ function Unparser:unparseStatement(statement, tabbing)
return self:tabs(tabbing, false) .. code;
end
-local function randomTrueNode()
- local op = math.random(1, 2);
- if(op == 1) then
- -- Less than
- local a = math.random(1, 9)
- local b = math.random(0, a - 1);
- return tostring(a) .. ">" .. tostring(b);
- else
- -- Greater than
- local a = math.random(1, 9)
- local b = math.random(0, a - 1);
- return tostring(b) .. "<" .. tostring(a);
- end
-end
-
-local function randomFalseNode()
- local op = math.random(1, 2);
- if(op == 1) then
- -- Less than
- local a = math.random(1, 9)
- local b = math.random(0, a - 1);
- return tostring(b) .. ">" .. tostring(a);
- else
- -- Greater than
- local a = math.random(1, 9)
- local b = math.random(0, a - 1);
- return tostring(a) .. "<" .. tostring(b);
+function Unparser:unparseExpression(expression, tabbing)
+ if expression.isParenthesizedExpression then
+ local unwrapped = {}
+ for k, v in pairs(expression) do
+ unwrapped[k] = v
+ end
+ unwrapped.isParenthesizedExpression = nil
+ return "(" .. self:unparseExpression(unwrapped, tabbing) .. ")"
end
-end
-function Unparser:unparseExpression(expression, tabbing)
local code = "";
if(expression.kind == AstKind.BooleanExpression) then
@@ -497,83 +474,18 @@ function Unparser:unparseExpression(expression, tabbing)
return lhs .. self:whitespaceIfNeeded2(lhs) .. "and" .. self:whitespaceIfNeeded(rhs) .. rhs;
end
- k = AstKind.LessThanExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "<" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.GreaterThanExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. ">" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.LessThanOrEqualsExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "<=" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.GreaterThanOrEqualsExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. ">=" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.NotEqualsExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "~=" .. self:optionalWhitespace() .. rhs;
- end
+ local comparisonOps = {
+ [AstKind.LessThanExpression] = "<",
+ [AstKind.GreaterThanExpression] = ">",
+ [AstKind.LessThanOrEqualsExpression] = "<=",
+ [AstKind.GreaterThanOrEqualsExpression] = ">=",
+ [AstKind.NotEqualsExpression] = "~=",
+ [AstKind.EqualsExpression] = "==",
+ }
- k = AstKind.EqualsExpression;
- if(expression.kind == k) then
+ local op = comparisonOps[expression.kind]
+ if op then
+ k = expression.kind
local lhs = self:unparseExpression(expression.lhs, tabbing);
if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
lhs = "(" .. lhs .. ")";
@@ -584,7 +496,7 @@ function Unparser:unparseExpression(expression, tabbing)
rhs = "(" .. rhs .. ")";
end
- return lhs .. self:optionalWhitespace() .. "==" .. self:optionalWhitespace() .. rhs;
+ return lhs .. self:optionalWhitespace() .. op .. self:optionalWhitespace() .. rhs;
end
k = AstKind.StrCatExpression;
@@ -606,72 +518,18 @@ function Unparser:unparseExpression(expression, tabbing)
return lhs .. self:optionalWhitespace() .. ".." .. self:optionalWhitespace() .. rhs;
end
- k = AstKind.AddExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "+" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.SubExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- if string.sub(rhs, 1, 1) == "-" then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "-" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.MulExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "*" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.DivExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- rhs = "(" .. rhs .. ")";
- end
-
- return lhs .. self:optionalWhitespace() .. "/" .. self:optionalWhitespace() .. rhs;
- end
+ local arithmeticOps = {
+ [AstKind.AddExpression] = "+",
+ [AstKind.SubExpression] = "-",
+ [AstKind.MulExpression] = "*",
+ [AstKind.DivExpression] = "/",
+ [AstKind.ModExpression] = "%",
+ [AstKind.PowExpression] = "^",
+ }
- k = AstKind.ModExpression;
- if(expression.kind == k) then
+ local op = arithmeticOps[expression.kind]
+ if op then
+ k = expression.kind
local lhs = self:unparseExpression(expression.lhs, tabbing);
if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
lhs = "(" .. lhs .. ")";
@@ -682,22 +540,11 @@ function Unparser:unparseExpression(expression, tabbing)
rhs = "(" .. rhs .. ")";
end
- return lhs .. self:optionalWhitespace() .. "%" .. self:optionalWhitespace() .. rhs;
- end
-
- k = AstKind.PowExpression;
- if(expression.kind == k) then
- local lhs = self:unparseExpression(expression.lhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.lhs.kind) >= Ast.astKindExpressionToNumber(k)) then
- lhs = "(" .. lhs .. ")";
- end
-
- local rhs = self:unparseExpression(expression.rhs, tabbing);
- if(Ast.astKindExpressionToNumber(expression.rhs.kind) >= Ast.astKindExpressionToNumber(k)) then
+ if op == "-" and string.sub(rhs, 1, 1) == "-" then
rhs = "(" .. rhs .. ")";
end
- return lhs .. self:optionalWhitespace() .. "^" .. self:optionalWhitespace() .. rhs;
+ return lhs .. self:optionalWhitespace() .. op .. self:optionalWhitespace() .. rhs;
end
-- Unary Expressions
@@ -738,7 +585,7 @@ function Unparser:unparseExpression(expression, tabbing)
k = AstKind.IndexExpression;
if(expression.kind == k or expression.kind == AstKind.AssignmentIndexing) then
local base = self:unparseExpression(expression.base, tabbing);
- if(expression.base.kind == AstKind.VarargExpression or Ast.astKindExpressionToNumber(expression.base.kind) > Ast.astKindExpressionToNumber(k)) then
+ if(expression.base.kind == AstKind.VarargExpression or Ast.astKindExpressionToNumber(expression.base.kind) > Ast.astKindExpressionToNumber(k) or expression.base.kind == AstKind.StringExpression or expression.base.kind == AstKind.NumberExpression or expression.base.kind == AstKind.NilExpression) then
base = "(" .. base .. ")";
end
diff --git a/src/prometheus/util.lua b/src/prometheus/util.lua
index 704bab28..c69e4175 100644
--- a/src/prometheus/util.lua
+++ b/src/prometheus/util.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
-- util.lua
--- This file Provides some utility functions
+--
+-- This Script provides some utility functions for Prometheus.
local function lookupify(tb)
local tb2 = {};
diff --git a/src/prometheus/visitast.lua b/src/prometheus/visitast.lua
index 847bf493..0cb6300b 100644
--- a/src/prometheus/visitast.lua
+++ b/src/prometheus/visitast.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
--- util.lua
--- This file Provides a Utility function for visiting each node of an ast
+-- visitast.lua
+--
+-- This Script provides a utility function for visiting each node of an AST.
local Ast = require("prometheus.ast");
local util = require("prometheus.util");
@@ -29,10 +30,10 @@ function visitAst(ast, previsit, postvisit, data)
return ast;
end
end
-
+
-- Is Function Block because global scope is treated like a Function
visitBlock(ast.body, previsit, postvisit, data, true);
-
+
if(type(postvisit) == "function") then
ast = postvisit(ast, data) or ast;
end
@@ -64,7 +65,7 @@ function visitBlock(block, previsit, postvisit, data, isFunctionBlock)
return block
end
end
-
+
local i = 1;
while i <= #block.statements do
local statement = table.remove(block.statements, i);
@@ -94,7 +95,7 @@ function visitStatement(statement, previsit, postvisit, data)
return statement;
end
end
-
+
-- Visit Child Nodes of Statement
if(statement.kind == AstKind.ReturnStatement) then
for i, expression in ipairs(statement.args) do
@@ -164,7 +165,7 @@ function visitStatement(statement, previsit, postvisit, data)
return unpack(statements);
end
end
-
+
return statement;
end
@@ -194,23 +195,23 @@ function visitExpression(expression, previsit, postvisit, data)
return expression;
end
end
-
+
if(binaryExpressions[expression.kind]) then
expression.lhs = visitExpression(expression.lhs, previsit, postvisit, data);
expression.rhs = visitExpression(expression.rhs, previsit, postvisit, data);
end
-
+
if(expression.kind == AstKind.NotExpression or expression.kind == AstKind.NegateExpression or expression.kind == AstKind.LenExpression) then
expression.rhs = visitExpression(expression.rhs, previsit, postvisit, data);
end
-
+
if(expression.kind == AstKind.PassSelfFunctionCallExpression or expression.kind == AstKind.FunctionCallExpression) then
expression.base = visitExpression(expression.base, previsit, postvisit, data);
for i, arg in ipairs(expression.args) do
expression.args[i] = visitExpression(arg, previsit, postvisit, data);
end
end
-
+
if(expression.kind == AstKind.FunctionLiteralExpression) then
local parentFunctionData = data.functionData;
data.functionData = {
@@ -221,7 +222,7 @@ function visitExpression(expression, previsit, postvisit, data)
expression.body = visitBlock(expression.body, previsit, postvisit, data, true);
data.functionData = parentFunctionData;
end
-
+
if(expression.kind == AstKind.TableConstructorExpression) then
for i, entry in ipairs(expression.entries) do
if entry.kind == AstKind.KeyedTableEntry then
@@ -230,7 +231,7 @@ function visitExpression(expression, previsit, postvisit, data)
entry.value = visitExpression(entry.value, previsit, postvisit, data);
end
end
-
+
if(expression.kind == AstKind.IndexExpression or expression.kind == AstKind.AssignmentIndexing) then
expression.base = visitExpression(expression.base, previsit, postvisit, data);
expression.index = visitExpression(expression.index, previsit, postvisit, data);
diff --git a/tests.lua b/tests.lua
index ffa16a4b..e3f612fe 100644
--- a/tests.lua
+++ b/tests.lua
@@ -1,7 +1,8 @@
-- This Script is Part of the Prometheus Obfuscator by Levno_710
--
--- test.lua
--- This file will Perform tests using all lua files within the tests directory
+-- tests.lua
+--
+-- This Script will Perform tests using all lua files within the tests directory
-- Require Prometheus
local Prometheus = require("src.prometheus")
@@ -10,9 +11,9 @@ local Prometheus = require("src.prometheus")
-- logger.logLevel = logger.LogLevel.Debug;
-- Config Variables - Later passed as Parameters
-local noColors = false; -- Wether Colors in the Console output should be enabled
-local isWindows = true; -- Wether the Test are Performed on a Windows or Linux System
-local ciMode = false; -- Wether the Test error are ignored or not
+local noColors = false; -- Whether Colors in the Console output should be enabled
+local isWindows = true; -- 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
@@ -38,9 +39,9 @@ local pipeline = Prometheus.Pipeline:new({
});
-- "Mangled" for names like this : a, b, c, d, ...
--- "MangledShuffled" is the same except the chars come in a different order - Recomended
--- "Il" for weird names like this : IlIIl1llI11l1 - Recomended to make less readable
--- "Number" for names like this : _1, _2, _3, ... - Not recomended
+-- "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()
@@ -80,20 +81,20 @@ local function shallowcopy(orig)
end
local function validate(a, b)
- local outa = "";
- local outb = "";
+ local outa = "";
+ local outb = "";
local enva = shallowcopy(getfenv(a));
local envb = shallowcopy(getfenv(a));
enva.print = function(...)
- for i, v in ipairs({...}) do
+ for _, v in ipairs({...}) do
outa = outa .. tostring(v);
end
end
envb.print = function(...)
- for i, v in ipairs({...}) do
+ for _, v in ipairs({...}) do
outb = outb .. tostring(v);
end
end
@@ -110,10 +111,9 @@ end
local presets = Prometheus.Presets;
local testdir = "./tests/"
-local failed = {};
Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error;
local fc = 0;
-for i, filename in ipairs(scandir(testdir)) do
+for _, filename in ipairs(scandir(testdir)) do
local path = testdir .. filename;
local file = io.open(path,"r");
@@ -141,7 +141,7 @@ for i, filename in ipairs(scandir(testdir)) do
if not validated then
print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. "): " .. name);
- print("[OUTA] ", outa);
+ print("[OUTA] ", outa);
print("[OUTB] ", outb);
print("[SOURCE]", obfuscated);
fc = fc + 1;
diff --git a/tests/ambiguous-call.lua b/tests/ambiguous-call.lua
index 38a08b2b..d79595e6 100644
--- a/tests/ambiguous-call.lua
+++ b/tests/ambiguous-call.lua
@@ -1,5 +1,8 @@
--- Reproduction for issue #203 where the parser misreads the following
--- as arguments to the previous literal assignment.
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- ambiguous-call.lua
+--
+-- This Test demonstrates a reproduction for issue #203 where the parser misreads the following as arguments to the previous literal assignment.
local counter = 1
(function()
diff --git a/tests/closures.lua b/tests/closures.lua
index 4b057532..8ad93e16 100644
--- a/tests/closures.lua
+++ b/tests/closures.lua
@@ -1,3 +1,9 @@
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- closures.lua
+--
+-- This Test demonstrates deterministic closure behavior.
+
local arr = {}
for i = 1, 100 do
local x;
@@ -7,6 +13,6 @@ for i = 1, 100 do
end
end
-for i, func in ipairs(arr) do
+for _, func in ipairs(arr) do
print(func())
end
\ No newline at end of file
diff --git a/tests/coroutines.lua b/tests/coroutines.lua
index a1f5961f..4138af9a 100644
--- a/tests/coroutines.lua
+++ b/tests/coroutines.lua
@@ -1,4 +1,9 @@
--- Deterministic coroutine driven sequence generator
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- coroutines.lua
+--
+-- This Test demonstrates a deterministic coroutine driven sequence generator.
+
local function squares(limit)
return coroutine.create(function()
for i = 1, limit do
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua
index a5ba7e1f..06733bad 100644
--- a/tests/fibonacci.lua
+++ b/tests/fibonacci.lua
@@ -1,4 +1,9 @@
--- Print the fibonacci sequence
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- fibonacci.lua
+--
+-- This Test demonstrates a simple fibonacci sequence.
+
local function fibonacci(max)
local a, b = 0, 1
while a < max do
diff --git a/tests/iterator.lua b/tests/iterator.lua
index 7bfe2b90..85df45d1 100644
--- a/tests/iterator.lua
+++ b/tests/iterator.lua
@@ -1,4 +1,9 @@
--- Custom iterator that creates a predictable countdown
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- iterator.lua
+--
+-- This Test demonstrates a custom iterator that creates a predictable countdown.
+
local function countdown(startValue, step)
local value = startValue + step
return function()
diff --git a/tests/loops.lua b/tests/loops.lua
index be8cad6b..aefd3afc 100644
--- a/tests/loops.lua
+++ b/tests/loops.lua
@@ -1,3 +1,9 @@
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- loops.lua
+--
+-- This Test demonstrates a simple loop that creates a predictable sequence.
+
local x = {};
for i = 1, 100 do
x[i] = i;
diff --git a/tests/matrix.lua b/tests/matrix.lua
index eb1bcb51..18e8f08a 100644
--- a/tests/matrix.lua
+++ b/tests/matrix.lua
@@ -1,4 +1,9 @@
--- Deterministic 2x2 matrix multiplication example
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- matrix.lua
+--
+-- This Test demonstrates a deterministic 2x2 matrix multiplication example.
+
local function multiply(a, b)
local result = {
{ a[1][1] * b[1][1] + a[1][2] * b[2][1], a[1][1] * b[1][2] + a[1][2] * b[2][2] },
diff --git a/tests/metatables.lua b/tests/metatables.lua
index 419a7d4e..d9e7d944 100644
--- a/tests/metatables.lua
+++ b/tests/metatables.lua
@@ -1,4 +1,9 @@
--- Example showcasing metamethod driven vector arithmetic
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- metatables.lua
+--
+-- This Test demonstrates a metamethod driven vector arithmetic.
+
local Vector = {}
Vector.__index = Vector
diff --git a/tests/multi-return.lua b/tests/multi-return.lua
new file mode 100644
index 00000000..a78e0dd2
--- /dev/null
+++ b/tests/multi-return.lua
@@ -0,0 +1,85 @@
+--============================================================
+-- Multi-Return Test Suite
+-- Target: Compiler
+-- Author: SpinnySpiwal
+-- Purpose: Ensure multi-return behavior is not adversely affected by the new dynamic emission system.
+--============================================================
+
+local function half(number)
+ local divided = number / 2
+ return divided, divided
+end
+
+local a, b = half(10)
+assert(a == 5 and b == 5, "Test 1 failed: basic multi-return")
+print("Test 1 passed: basic multi-return", a, b)
+
+local function mixedReturn()
+ return 42, "hello", true, nil
+end
+
+local num, str, bool, nilVal = mixedReturn()
+assert(num == 42 and str == "hello" and bool == true and nilVal == nil, "Test 2 failed: mixed types")
+print("Test 2 passed: mixed types", num, str, bool, nilVal)
+
+local function threeValues()
+ return 1, 2, 3
+end
+
+local first = threeValues()
+assert(first == 1, "Test 3 failed: discarding extra values")
+print("Test 3 passed: discarding extra values", first)
+
+local x, y, z, w = threeValues()
+assert(x == 1 and y == 2 and z == 3 and w == nil, "Test 4 failed: extra variables get nil")
+print("Test 4 passed: extra variables get nil", x, y, z, w)
+
+local function pair()
+ return "a", "b"
+end
+
+local t1 = { pair() }
+assert(t1[1] == "a" and t1[2] == "b", "Test 5 failed: multi-return in table (last)")
+print("Test 5 passed: multi-return in table (last)", t1[1], t1[2])
+
+local t2 = { pair(), "c" }
+assert(t2[1] == "a" and t2[2] == "c" and t2[3] == nil, "Test 6 failed: multi-return not last")
+print("Test 6 passed: multi-return not last", t2[1], t2[2])
+
+local function double(a, b)
+ return a * 2, b * 2
+end
+
+local d1, d2 = double(threeValues())
+assert(d1 == 2 and d2 == 4, "Test 7 failed: nested multi-return")
+print("Test 7 passed: nested multi-return", d1, d2)
+
+local function fiveValues()
+ return 10, 20, 30, 40, 50
+end
+
+local count = select("#", fiveValues())
+assert(count == 5, "Test 8 failed: select count")
+print("Test 8 passed: select count", count)
+
+local fourth = select(4, fiveValues())
+assert(fourth == 40, "Test 9 failed: select specific")
+print("Test 9 passed: select specific", fourth)
+
+local function varargReturn(...)
+ return ...
+end
+
+local v1, v2, v3 = varargReturn(100, 200, 300)
+assert(v1 == 100 and v2 == 200 and v3 == 300, "Test 10 failed: vararg return")
+print("Test 10 passed: vararg return", v1, v2, v3)
+
+local function sum(a, b, c)
+ return (a or 0) + (b or 0) + (c or 0)
+end
+
+local result = sum(threeValues())
+assert(result == 6, "Test 11 failed: multi-return as arguments")
+print("Test 11 passed: multi-return as arguments", result)
+
+print("All multi-return tests passed!")
\ No newline at end of file
diff --git a/tests/primes.lua b/tests/primes.lua
index 3040574e..d07d6543 100644
--- a/tests/primes.lua
+++ b/tests/primes.lua
@@ -1,4 +1,9 @@
--- print first n primes
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- primes.lua
+--
+-- This Test demonstrates a deterministic prime number generator.
+
local function primes(n)
local function isPrime(n)
for i = 2, math.sqrt(n) do
diff --git a/tests/repeat-test.lua b/tests/repeat-test.lua
index 8111f09e..e9577469 100644
--- a/tests/repeat-test.lua
+++ b/tests/repeat-test.lua
@@ -1,5 +1,5 @@
--============================================================
--- Repeat–Until Semantics Test Suite
+-- Repeat-Until Semantics Test Suite
-- Target: Vmify
-- Author: Zaenalos
-- Purpose: Validate correct scope, control flow, and condition
diff --git a/tests/state-machine.lua b/tests/state-machine.lua
index c99e18b6..1c925a01 100644
--- a/tests/state-machine.lua
+++ b/tests/state-machine.lua
@@ -1,4 +1,9 @@
--- Simple deterministic finite-state machine demonstration
+-- This Script is Part of the Prometheus Obfuscator by Levno_710
+--
+-- state-machine.lua
+--
+-- This Test demonstrates a simple deterministic finite-state machine.
+
local transitions = {
idle = { start = "running" },
running = { pause = "paused", stop = "stopped" },
diff --git a/tests/strings.lua b/tests/strings.lua
index 1adf0dad..9dfd8afa 100644
--- a/tests/strings.lua
+++ b/tests/strings.lua
@@ -1,4 +1,9 @@
--- Deterministic text statistics for repeated words
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- strings.lua
+--
+-- This Test demonstrates a deterministic text statistics for repeated words and prints the results.
+
local passage = "lorem ipsum dolor sit amet ipsum lorem"
local counts = {}
diff --git a/tests/syntax.lua b/tests/syntax.lua
new file mode 100644
index 00000000..f893ab91
--- /dev/null
+++ b/tests/syntax.lua
@@ -0,0 +1,14 @@
+--============================================================
+-- Syntax Test Suite
+-- Target: Unparser
+-- Author: SpinnySpiwal
+-- Purpose: Validate appropriate unparser functionality, specifically in unseen edge cases.
+--============================================================
+
+local char = ("").char
+print(char == string.char and "yes" or "no")
+local pc, _ = pcall(function()
+ return (0)[char]
+end)
+
+print(pc == false and "yes" or "no")
\ No newline at end of file
diff --git a/tests/table-merge.lua b/tests/table-merge.lua
index c1fe0338..f50ffb26 100644
--- a/tests/table-merge.lua
+++ b/tests/table-merge.lua
@@ -1,4 +1,9 @@
--- Demonstrate deterministic table merging and traversal
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- table-merge.lua
+--
+-- This Test demonstrates a deterministic table merging and traversal.
+
local breakfast = { eggs = 4, bacon = 3 }
local lunch = { bacon = 1, toast = 5 }
diff --git a/tests/upvalues.lua b/tests/upvalues.lua
index 81162afc..7d1ea23c 100644
--- a/tests/upvalues.lua
+++ b/tests/upvalues.lua
@@ -1,4 +1,9 @@
--- Deterministic tests covering closure upvalues in nested functions and loops
+-- This Test is Part of the Prometheus Obfuscator by Levno_710
+--
+-- upvalues.lua
+--
+-- This Test demonstrates a deterministic tests covering closure upvalues in nested functions and loops.
+
local function emitList(label, list)
print(label .. ":" .. table.concat(list, ","))
end