Skip to content

Commit 4a49822

Browse files
levno-710gitbook-bot
authored andcommitted
GitBook: [#26] No subject
1 parent 142f12c commit 4a49822

13 files changed

+641
-12
lines changed

doc/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ 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-
NOTE: This documentation is currently being developed, so do not expect a full documentation yet.

doc/SUMMARY.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@
55
## Getting Started
66

77
* [Installation](getting-started/installation.md)
8+
* [Obfuscating your first script](getting-started/obfuscating-your-first-script.md)
9+
* [Command Line Options](getting-started/command-line-options.md)
10+
* [Writing a custom Config File](getting-started/writing-a-custom-config-file.md)
11+
* [The Config Object](getting-started/the-config-object.md)
812

9-
***
13+
## Steps
1014

11-
* [Obfuscating your first script](obfuscating-your-first-script.md)
12-
* [Command Line Options](command-line-options.md)
15+
* [WrapInFunction](steps/wrapinfunction.md)
16+
* [Vmify](steps/vmify.md)
17+
* [SplitStrings](steps/splitstrings.md)
18+
* [ProxifyLocals](steps/proxifylocals.md)
19+
* [LocalsToTable](steps/localstotable.md)
20+
* [ConstantArray](steps/constantarray.md)
21+
22+
## advanced
23+
24+
* [Using Prometheus in your Lua Application](advanced/using-prometheus-in-your-lua-application.md)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Using Prometheus in your Lua Application
2+
3+
Prometheus can also be used as a library for your custom Lua Applications instead of using it's cli tool. 
4+
5+
In order to do that you'll first need to clone the github repo:
6+
7+
```batch
8+
git clone "https://github.com/levno-710/Prometheus.git"
9+
```
10+
11+
After that, you'll need to copy everything within the src folder to your project. Let's say you created a folder named `prometheus`, where all the Prometheus files are located. You can the use the following code to obfuscate a string:
12+
13+
{% code title="use_prometheus.lua" %}
14+
```lua
15+
local Prometheus = require("prometheus.prometheus")
16+
17+
-- If you don't want console output
18+
Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error
19+
20+
-- Your code
21+
local code = 'print("Hello, World!")'
22+
23+
-- Create a Pipeline using the Strong preset
24+
local pipeline = Prometheus.Pipeline:fromConfig(Prometheus.Presets.Strong)
25+
26+
-- Apply the obfuscation and print the result
27+
print(pipeline:apply(code));
28+
```
29+
{% endcode %}
30+
31+
Instead of passing the Strong preset you could also pass a custom [Config Object](../getting-started/the-config-object.md).
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Command Line Options
22

3-
There are currently not that many command line options. The following table provides a brief overview:
3+
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 coustom 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 | |
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 | |
File renamed without changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# The Config Object
2+
3+
Prometheus takes a configuration objetct. In this object there can be many properties applied. \
4+
The following table provides an overview:
5+
6+
| Property | type | possible values | default |
7+
| ------------- | ------- | -------------------------------------------- | ----------------- |
8+
| LuaVersion | string | "Lua51", "LuaU" | "Lua51" |
9+
| PrettyPrint | boolean | true, false | false |
10+
| VarNamePrefix | string | any | "" |
11+
| NameGenerator | string | "Mangled", "MangledShuffled", "Il", "Number" | "MangledShuffled" |
12+
| Seed | number | any | 0 |
13+
| Steps | table | StepConfig\[] | {} |
14+
15+
As this table shows, all properties in the config object are optional as they have a default value.
16+
17+
As an example, here is the code for the minify preset:
18+
19+
```lua
20+
{
21+
-- The default LuaVersion is Lua51
22+
LuaVersion = "Lua51";
23+
-- For minifying no VarNamePrefix is applied
24+
VarNamePrefix = "";
25+
-- Name Generator for Variables
26+
NameGenerator = "MangledShuffled";
27+
-- No pretty printing
28+
PrettyPrint = false;
29+
-- Seed is generated based on current time
30+
Seed = 0;
31+
-- No obfuscation steps
32+
Steps = {
33+
34+
}
35+
};
36+
```
37+
38+
### Steps
39+
40+
The most important property is the Steps property. This property must be a table of so called Step Configs. A Step in Prometheus describes a single transformation applied to your script by the Prometheus obfuscation pipeline. A StepConfiguration consists of the Name of the Step as well as settings for the step. All Steps will later be applied in the order they are defined. A single Step can be defined twice and will then be applied twice.
41+
42+
```lua
43+
-- Obfuscation steps
44+
Steps = {
45+
{
46+
-- This obfuscation step puts all constants into an array at the beginning of the code
47+
Name = "ConstantArray";
48+
Settings = {
49+
-- Apply to Strings only
50+
StringsOnly = true;
51+
-- Apply to all Constants, 0.5 would only affect 50% of strings
52+
Treshold = 1;
53+
}
54+
},
55+
}
56+
```
57+
58+
Under [Steps](broken-reference), you can find all current Steps, their names as well as the possible options.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Writing a custom Config File
2+
3+
Configuration Files for Prometheus are just lua modules, that return a single object, which contains the configuration. Let's say we have the following config file:
4+
5+
{% code title="config.lua" %}
6+
```lua
7+
return {
8+
-- The default LuaVersion is Lua51
9+
LuaVersion = "Lua51"; -- or "LuaU"
10+
-- All Variables will start with this prefix
11+
VarNamePrefix = "";
12+
-- Name Generator for Variables that look like this: b, a, c, D, t, G
13+
NameGenerator = "MangledShuffled";
14+
-- No pretty printing
15+
PrettyPrint = false;
16+
-- Seed is generated based on current time
17+
-- When specifying a seed that is not 0, you will get the same output every time
18+
Seed = 0;
19+
-- Obfuscation steps
20+
Steps = {
21+
{
22+
-- This obfuscation step puts all constants into an array at the beginning of the code
23+
Name = "ConstantArray";
24+
Settings = {
25+
-- Apply to Strings only
26+
StringsOnly = true;
27+
-- Apply to all Constants, 0.5 would only affect 50% of strings
28+
Treshold = 1;
29+
}
30+
},
31+
}
32+
}
33+
```
34+
{% endcode %}
35+
36+
One can now obfuscate a script using this configuration by running:
37+
38+
```batch
39+
lua ./cli.lua --config config.lua hello_world.lua
40+
```
41+
42+
You should get the following output:
43+
44+
{% code title="hello_world.obfuscated.lua" %}
45+
```lua
46+
local N={"Hello, World!"}local function k(k)return N[k+40058]end print(k(-40057))
47+
```
48+
{% endcode %}
49+
50+
As you can see, the only transformation that was applied to our Hello World example was putting all strings (in this case only `"Hello, World!"` into an array and creating a wrapper function for retrieving the value.
51+
52+
### How does the Config File work?
53+
54+
The config file is simply a lua file, that returns the configuration object. Please note that this lua file is sandboxed by Prometheus when loading the configuration, meaning that you can't use any predefined functions like `tostring` or the libraries like `math`.
55+
56+
See [The Config Object](the-config-object.md) to learn what this configuration object consists of.

doc/steps/constantarray.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
description: >-
3+
This Step will Extract all Constants and put them into an Array at the
4+
beginning of the script
5+
---
6+
7+
# ConstantArray
8+
9+
### Settings
10+
11+
| Name | type | description |
12+
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
13+
| Treshold | number | The relative amount of nodes that will be affected" |
14+
| StringsOnly | boolean | Wether to only Extract Strings |
15+
| Shuffle | boolean | Wether to shuffle the order of Elements in the Array |
16+
| Rotate | boolean | Wether to rotate the String Array by a specific (random) amount. This will be undone on runtime. |
17+
| LocalWrapperTreshold | number | The relative amount of nodes functions, that will get local wrappers |
18+
| LocalWrapperCount | number | The number of Local wrapper Functions per scope. This only applies if LocalWrapperTreshold is greater than 0 |
19+
| LocalWrapperArgCount | number | The number of Arguments to the Local wrapper Functions |
20+
| MaxWrapperOffset | number | The Max Offset for the Wrapper Functions |
21+
22+
### Example
23+
24+
{% code title="in.lua" %}
25+
```lua
26+
print("1")
27+
print("2")
28+
print("3")
29+
print("4")
30+
```
31+
{% endcode %}
32+
33+
{% code title="out.lua" %}
34+
```lua
35+
-- LocalWrapperCount = 3
36+
-- LocalWrapperArgCount = 5
37+
local F = {"4", "3", "2", "1"}
38+
do
39+
local y, G = 1, 4
40+
while y < G do
41+
F[y], F[G] = F[G], F[y]
42+
y, G = y + 1, G - 1
43+
end
44+
y, G = 1, 3
45+
while y < G do
46+
F[y], F[G] = F[G], F[y]
47+
y, G = y + 1, G - 1
48+
end
49+
y, G = 4, 4
50+
while y < G do
51+
F[y], F[G] = F[G], F[y]
52+
y, G = y + 1, G - 1
53+
end
54+
end
55+
local function y(y)
56+
return F[y + 440]
57+
end
58+
local G = {cb = function(F, G, R, p, b)
59+
return y(G - 2277)
60+
end, n = function(F, G, R, p, b)
61+
return y(p + 47178)
62+
end, B = function(F, G, R, p, b)
63+
return y(F + 31775)
64+
end}
65+
print(G.cb(1575, 1840, 2367, 1293, 1280))
66+
print(G.B(-32213, -31781, -31538, -32780, -32728))
67+
print(G.B(-32214, -33004, -31973, -32125, -31855))
68+
print(G.B(-32211, -31884, -31217, -32222, -31210))
69+
70+
```
71+
{% endcode %}

doc/steps/localstotable.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
description: >-
3+
This Step will wrap all Locals in each scope into a table. (Not recommended
4+
due to memory issues)
5+
---
6+
7+
# LocalsToTable
8+
9+
### Settings
10+
11+
| Name | type | description |
12+
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
13+
| Treshold | number | The relative amount of scopes that will be affected |
14+
| RemapIndices | boolean | When this option is set to true, new table indices will be generated instead of using the id's generated by the parser |
15+
16+
### Example
17+
18+
{% code title="in.lua" %}
19+
```lua
20+
local a, b, c = 1, 2, 3
21+
print(a + b + c)
22+
```
23+
{% endcode %}
24+
25+
{% code title="out.lua" %}
26+
```lua
27+
-- Treshold = 1
28+
-- RemapIndices = true
29+
local G = {}
30+
G[3], G[1], G[2] = 1, 2, 3
31+
print(G[3] + (G[1] + G[2]))
32+
```
33+
{% endcode %}

doc/steps/proxifylocals.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
description: This Step wraps all locals into Proxy Objects
3+
---
4+
5+
# ProxifyLocals
6+
7+
### Settings
8+
9+
None
10+
11+
### Example
12+
13+
{% code title="in.lua" %}
14+
```lua
15+
local x = "Hello, World!"
16+
print(x)
17+
```
18+
{% endcode %}
19+
20+
{% code title="out.lua" %}
21+
```lua
22+
-- No Settings
23+
local n = setmetatable
24+
local D =
25+
n(
26+
{Wz = function()
27+
end},
28+
{__div = function(R, n)
29+
R.Wz = n
30+
end, __concat = function(R, n)
31+
return R.Wz
32+
end}
33+
)
34+
local R =
35+
n(
36+
{Js = "Hello, World!"},
37+
{__add = function(R, n)
38+
R.Js = n
39+
end, __index = function(R, n)
40+
return rawget(R, "Js")
41+
end}
42+
)
43+
print(R.Muirgen)
44+
```
45+
{% endcode %}

0 commit comments

Comments
 (0)