Skip to content

Commit 46d3571

Browse files
authored
Merge pull request #104 from oxince/master
2 parents f67ec5f + 1e06024 commit 46d3571

File tree

4 files changed

+99
-9
lines changed

4 files changed

+99
-9
lines changed

src/presets.lua

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ return {
3434
Seed = 0;
3535
-- Obfuscation steps
3636
Steps = {
37+
{
38+
Name = "WatermarkCheck";
39+
Settings = {
40+
Content = "This Script was obfuscated using the Weak Preset of Prometheus Obfuscator by Levno_710";
41+
}
42+
},
3743
{
3844
Name = "Vmify";
3945
Settings = {
@@ -68,6 +74,12 @@ return {
6874
Seed = 0;
6975
-- Obfuscation steps
7076
Steps = {
77+
{
78+
Name = "WatermarkCheck";
79+
Settings = {
80+
Content = "This Script was obfuscated using the Medium Preset of Prometheus Obfuscator by Levno_710";
81+
}
82+
},
7183
{
7284
Name = "EncryptStrings";
7385
Settings = {
@@ -108,12 +120,6 @@ return {
108120

109121
}
110122
},
111-
{
112-
Name = "Watermark";
113-
Settings = {
114-
Content = "This Script was obfuscated using the Medium Preset of Prometheus Obfuscator by Levno_710"
115-
}
116-
}
117123
}
118124
};
119125
["Strong"] = {
@@ -129,6 +135,12 @@ return {
129135
Seed = 0;
130136
-- Obfuscation steps
131137
Steps = {
138+
{
139+
Name = "WatermarkCheck";
140+
Settings = {
141+
Content = "This Script was obfuscated using the Strong Preset of Prometheus Obfuscator by Levno_710";
142+
}
143+
},
132144
{
133145
Name = "Vmify";
134146
Settings = {

src/prometheus/steps.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ return {
88
EncryptStrings = require("prometheus.steps.EncryptStrings");
99
NumbersToExpressions = require("prometheus.steps.NumbersToExpressions");
1010
AddVararg = require("prometheus.steps.AddVararg");
11-
Watermark = require("prometheus.steps.Watermark");
11+
WatermarkCheck = require("prometheus.steps.WatermarkCheck");
1212
}

src/prometheus/steps/Watermark.lua

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ Watermark.SettingsDescriptor = {
1919
type = "string",
2020
default = "This Script is Part of the Prometheus Obfuscator by Levno_710",
2121
},
22+
CustomVariable = {
23+
name = "Custom Variable",
24+
description = "The Variable that will be used for the Watermark",
25+
type = "string",
26+
default = "_WATERMARK",
27+
}
2228
}
2329

2430
function Watermark:init(settings)
@@ -28,8 +34,30 @@ end
2834
function Watermark:apply(ast)
2935
local body = ast.body;
3036
if string.len(self.Content) > 0 then
31-
local watermark = body.scope:addVariable();
32-
table.insert(body.statements, 1, Ast.LocalVariableDeclaration(body.scope, {watermark}, {Ast.StringExpression(self.Content)}));
37+
local scope, variable = ast.globalScope:resolve(self.CustomVariable);
38+
local watermark = Ast.AssignmentVariable(ast.globalScope, variable);
39+
40+
-- body.scope:addReferenceToHigherScope(ast.globalScope, variable);
41+
-- table.insert(body.statements, 1, Ast.AssignmentStatement({watermark}, {Ast.StringExpression(self.Content)}));
42+
43+
local functionScope = Scope:new(body.scope);
44+
functionScope:addReferenceToHigherScope(ast.globalScope, variable);
45+
46+
local arg = functionScope:addVariable();
47+
local statement = Ast.PassSelfFunctionCallStatement(Ast.StringExpression(self.Content), "gsub", {
48+
Ast.StringExpression(".+"),
49+
Ast.FunctionLiteralExpression({
50+
Ast.VariableExpression(functionScope, arg)
51+
}, Ast.Block({
52+
Ast.AssignmentStatement({
53+
watermark
54+
}, {
55+
Ast.VariableExpression(functionScope, arg)
56+
})
57+
}, functionScope))
58+
});
59+
60+
table.insert(ast.body.statements, 1, statement)
3361
end
3462
end
3563

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
-- This Script is Part of the Prometheus Obfuscator by Levno_710
2+
--
3+
-- WatermarkCheck.lua
4+
--
5+
-- This Script provides a Step that will add a watermark to the script
6+
7+
local Step = require("prometheus.step");
8+
local Ast = require("prometheus.ast");
9+
local Scope = require("prometheus.scope");
10+
local Watermark = require("prometheus.steps.Watermark");
11+
12+
local WatermarkCheck = Step:extend();
13+
WatermarkCheck.Description = "This Step will add a watermark to the script";
14+
WatermarkCheck.Name = "WatermarkCheck";
15+
16+
WatermarkCheck.SettingsDescriptor = {
17+
Content = {
18+
name = "Content",
19+
description = "The Content of the WatermarkCheck",
20+
type = "string",
21+
default = "This Script is Part of the Prometheus Obfuscator by Levno_710",
22+
},
23+
}
24+
25+
local function callNameGenerator(generatorFunction, ...)
26+
if(type(generatorFunction) == "table") then
27+
generatorFunction = generatorFunction.generateName;
28+
end
29+
return generatorFunction(...);
30+
end
31+
32+
function WatermarkCheck:init(settings)
33+
34+
end
35+
36+
function WatermarkCheck:apply(ast, pipeline)
37+
self.CustomVariable = "_" .. callNameGenerator(pipeline.namegenerator, math.random(10000000000, 100000000000));
38+
pipeline:addStep(Watermark:new(self));
39+
40+
local body = ast.body;
41+
local watermarkExpression = Ast.StringExpression(self.Content);
42+
local scope, variable = ast.globalScope:resolve(self.CustomVariable);
43+
local watermark = Ast.VariableExpression(ast.globalScope, variable);
44+
local notEqualsExpression = Ast.NotEqualsExpression(watermark, watermarkExpression);
45+
local ifBody = Ast.Block({Ast.ReturnStatement({})}, Scope:new(ast.body.scope));
46+
47+
table.insert(body.statements, 1, Ast.IfStatement(notEqualsExpression, ifBody, {}, nil));
48+
end
49+
50+
return WatermarkCheck;

0 commit comments

Comments
 (0)