Skip to content

Commit 6e0a584

Browse files
authored
Merge pull request #13 from levno-710/develop
2 parents d052915 + 965b661 commit 6e0a584

File tree

11 files changed

+243
-83
lines changed

11 files changed

+243
-83
lines changed

doc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ description: Prometheus is an Lua Obfuscator, that is written in pure Lua.
77
Prometheus can obfuscate Lua51 as well as Roblox's LuaU, which is an optionally typed superset of Lua51.
88

99
Show Prometheus on [github](https://github.com/levno-710/Prometheus).
10+
11+
This Documentation only applies to the newest version of Prometheus.

doc/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [Installation](getting-started/installation.md)
88
* [Obfuscating your first script](getting-started/obfuscating-your-first-script.md)
99
* [Command Line Options](getting-started/command-line-options.md)
10+
* [Presets](getting-started/presets.md)
1011
* [Writing a custom Config File](getting-started/writing-a-custom-config-file.md)
1112
* [The Config Object](getting-started/the-config-object.md)
1213

doc/getting-started/command-line-options.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The following table provides a brief overview over the command line options:
44

5-
| Option | Usage | |
6-
| ----------------------------- | ---------------------------------------- | - |
7-
| --preset \[name]; --p \[path] | Specify the config preset to be used | |
8-
| --config \[path]; --c \[path] | Specify the path to a custom config file | |
9-
| --out \[path]; --o \[path] | Specify the path of the output file | |
10-
| --nocolors | Disable ansi colors escape sequences | |
5+
| Option | Usage | |
6+
| ----------------------------- | ----------------------------------------------------------- | - |
7+
| --preset \[name]; --p \[path] | Specify the config preset to be used; [Details](presets.md) | |
8+
| --config \[path]; --c \[path] | Specify the path to a custom config file | |
9+
| --out \[path]; --o \[path] | Specify the path of the output file | |
10+
| --nocolors | Disable ansi colors escape sequences | |

doc/getting-started/obfuscating-your-first-script.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ print("Hello, World")
3434
```
3535
{% endcode %}
3636

37-
As you can see, the file hasn't changed at all. That is because by default prometheus is just a minifier and the code we gave it was already as small as possible. To actually obfuscate the file, prometheus must be told which obfuscation steps it should apply in which order. In order to do this, the cli provides the `--preset` option which allows you to specify the name of a predefined configuration. There are currently only two presets:
37+
As you can see, the file hasn't changed at all. That is because by default prometheus is just a minifier and the code we gave it was already as small as possible. To actually obfuscate the file, prometheus must be told which obfuscation steps it should apply in which order. In order to do this, the cli provides the `--preset` option which allows you to specify the name of a predefined configuration. There are currently the following presets:
3838

3939
* Minify
40+
* Vm
41+
* Weak
42+
* Medium
4043
* Strong
4144

4245
In order to perform the obfuscation, you need to specify that Prometheus should use the Strong preset:
@@ -46,3 +49,5 @@ lua ./cli.lua --preset Strong ./hello_world.lua
4649
```
4750

4851
The `hello_world.obfuscated.lua` should now become around 20kB in size, but when running, it should still print "Hello World".
52+
53+
Note that using the "Strong" preset is not recommended for large projects as bigger files will get around 15x in size.

doc/getting-started/presets.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Presets
2+
3+
The following table provides an overview over the presets
4+
5+
| name | usage | size | speed |
6+
| ------ | -------------------------------------------------------------------------------------------------------- | ------ | ------- |
7+
| Minify | Simply minifies your source file | tiny | fastest |
8+
| Vm | Compiles your source file using a custom compiler and implements a vm for running the generated bytecode | big | slow |
9+
| Weak | Extracts all Strings from your Program and puts them into a table at the beginning of the Program | small | fast |
10+
| Medium | Applies more advanced obfuscation techniques. | medium | medium |
11+
| Strong | Applies almost all obfuscation techniques that prometheus provides. | huge | slowest |

doc/steps/proxifylocals.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ description: This Step wraps all locals into Proxy Objects
66

77
### Settings
88

9-
None
9+
| Name | type | description | values |
10+
| ----------- | ---- | ------------------------------------------- | --------------------------------------- |
11+
| LiteralType | enum | The type of the randomly generated literals | "dictionary", "number", "string", "any" |
1012

1113
### Example
1214

@@ -19,7 +21,7 @@ print(x)
1921

2022
{% code title="out.lua" %}
2123
```lua
22-
-- No Settings
24+
-- LiteralType = "dictionary"
2325
local n = setmetatable
2426
local D =
2527
n(

doc/steps/splitstrings.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ description: This Step splits Strings to a specific or random length
66

77
### Settings
88

9-
| Name | type | description | Values |
10-
| -------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
11-
| Treshold | number | The relative amount of nodes that will be affected | 0 <= x <= 1 |
12-
| MinLength | number | The minimal length for the chunks in that the Strings are splitted | x > 0 |
13-
| MaxLength | number | The maximal length for the chunks in that the Strings are splitted | x >= MinLength |
14-
| ConcatenationType | enum | The Functions used for Concatenation. Note that when using coustom, the String Array will also be Shuffled | "strcat", "table", "coustom" |
15-
| CoustomFunctionType | enum | <p>The Type of Function code injection This Option only applies when coustom Concatenation is selected.<br>Note that when chosing inline, the code size may increase significantly!</p> | "global", "local", "inline" |
16-
| CoustomLocalFunctionsCount | number | The number of local functions per scope. This option only applies when CoustomFunctionType = local | x > 0 |
9+
| Name | type | description | Values |
10+
| ------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
11+
| Treshold | number | The relative amount of nodes that will be affected | 0 <= x <= 1 |
12+
| MinLength | number | The minimal length for the chunks in that the Strings are splitted | x > 0 |
13+
| MaxLength | number | The maximal length for the chunks in that the Strings are splitted | x >= MinLength |
14+
| ConcatenationType | enum | The Functions used for Concatenation. Note that when using coustom, the String Array will also be Shuffled | "strcat", "table", "custom" |
15+
| CustomFunctionType | enum | <p>The Type of Function code injection This Option only applies when coustom Concatenation is selected.<br>Note that when chosing inline, the code size may increase significantly!</p> | "global", "local", "inline" |
16+
| CustomLocalFunctionsCount | number | The number of local functions per scope. This option only applies when CoustomFunctionType = local | x > 0 |
1717

1818
### Example
1919

src/obfuscator/randomLiterals.lua

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,33 @@ local RandomStrings = require("obfuscator.randomStrings");
77

88
local RandomLiterals = {};
99

10-
function RandomLiterals.String()
11-
return RandomStrings.randomStringNode();
10+
local function callNameGenerator(generatorFunction, ...)
11+
if(type(generatorFunction) == "table") then
12+
generatorFunction = generatorFunction.generateName;
13+
end
14+
return generatorFunction(...);
15+
end
16+
17+
function RandomLiterals.String(pipeline)
18+
return Ast.StringExpression(callNameGenerator(pipeline.namegenerator, math.random(1, 4096)));
19+
end
20+
21+
function RandomLiterals.Dictionary()
22+
return RandomStrings.randomStringNode(true);
1223
end
1324

1425
function RandomLiterals.Number()
1526
return Ast.NumberExpression(math.random(-8388608, 8388607));
1627
end
1728

18-
function RandomLiterals.Any()
19-
local type = math.random(1, 2);
29+
function RandomLiterals.Any(pipeline)
30+
local type = math.random(1, 3);
2031
if type == 1 then
21-
return RandomLiterals.String();
32+
return RandomLiterals.String(pipeline);
2233
elseif type == 2 then
2334
return RandomLiterals.Number();
35+
elseif type == 3 then
36+
return RandomLiterals.Dictionary();
2437
end
2538
end
2639

src/obfuscator/steps/ProxifyLocals.lua

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ ProifyLocals.Description = "This Step wraps all locals into Proxy Objects";
1717
ProifyLocals.Name = "Proxify Locals";
1818

1919
ProifyLocals.SettingsDescriptor = {
20-
20+
LiteralType = {
21+
name = "LiteralType",
22+
description = "The type of the randomly generated literals",
23+
type = "enum",
24+
values = {
25+
"dictionary",
26+
"number",
27+
"string",
28+
"any",
29+
},
30+
default = "string",
31+
},
2132
}
2233

2334
local function shallowcopy(orig)
@@ -249,7 +260,17 @@ function ProifyLocals:apply(ast, pipeline)
249260
local localMetatableInfo = getLocalMetatableInfo(node.scope, node.id);
250261
-- Apply Only to Some Variables if Treshold is non 1
251262
if localMetatableInfo then
252-
return localMetatableInfo.getValue.constructor(node, RandomLiterals.Any());
263+
local literal;
264+
if self.LiteralType == "dictionary" then
265+
literal = RandomLiterals.Dictionary();
266+
elseif self.LiteralType == "number" then
267+
literal = RandomLiterals.Number();
268+
elseif self.LiteralType == "string" then
269+
literal = RandomLiterals.String(pipeline);
270+
else
271+
literal = RandomLiterals.Any(pipeline);
272+
end
273+
return localMetatableInfo.getValue.constructor(node, literal);
253274
end
254275
end
255276

0 commit comments

Comments
 (0)