lua-obfuscator 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -18
- package/dist/prometheus/LICENSE +661 -661
- package/dist/prometheus/build.bat +9 -9
- package/dist/prometheus/doc/README.md +11 -11
- package/dist/prometheus/doc/SUMMARY.md +27 -27
- package/dist/prometheus/doc/advanced/using-prometheus-in-your-lua-application.md +31 -31
- package/dist/prometheus/doc/getting-started/command-line-options.md +13 -13
- package/dist/prometheus/doc/getting-started/installation.md +11 -11
- package/dist/prometheus/doc/getting-started/obfuscating-your-first-script.md +50 -50
- package/dist/prometheus/doc/getting-started/presets.md +10 -10
- package/dist/prometheus/doc/getting-started/the-config-object.md +58 -58
- package/dist/prometheus/doc/getting-started/writing-a-custom-config-file.md +56 -56
- package/dist/prometheus/doc/steps/anti-tamper.md +11 -11
- package/dist/prometheus/doc/steps/constantarray.md +71 -71
- package/dist/prometheus/doc/steps/encryptstrings.md +86 -86
- package/dist/prometheus/doc/steps/proxifylocals.md +47 -47
- package/dist/prometheus/doc/steps/splitstrings.md +40 -40
- package/dist/prometheus/doc/steps/vmify.md +9 -9
- package/dist/prometheus/doc/steps/wrapinfunction.md +29 -29
- package/dist/prometheus/readme.md +57 -57
- package/dist/prometheus/readme.txt +4 -4
- package/package.json +5 -1
- package/src/index.ts +93 -75
- package/tsconfig.json +12 -12
- package/src/prometheus/.editorconfig +0 -4
- package/src/prometheus/.gitattributes +0 -2
- package/src/prometheus/.gitbook.yaml +0 -1
- package/src/prometheus/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
- package/src/prometheus/.github/workflows/Build.yml +0 -49
- package/src/prometheus/.github/workflows/Test.yml +0 -19
- package/src/prometheus/LICENSE +0 -661
- package/src/prometheus/benchmark.lua +0 -34
- package/src/prometheus/build.bat +0 -10
- package/src/prometheus/cli.lua +0 -12
- package/src/prometheus/doc/README.md +0 -11
- package/src/prometheus/doc/SUMMARY.md +0 -27
- package/src/prometheus/doc/advanced/using-prometheus-in-your-lua-application.md +0 -31
- package/src/prometheus/doc/getting-started/command-line-options.md +0 -13
- package/src/prometheus/doc/getting-started/installation.md +0 -11
- package/src/prometheus/doc/getting-started/obfuscating-your-first-script.md +0 -50
- package/src/prometheus/doc/getting-started/presets.md +0 -10
- package/src/prometheus/doc/getting-started/the-config-object.md +0 -58
- package/src/prometheus/doc/getting-started/writing-a-custom-config-file.md +0 -56
- package/src/prometheus/doc/steps/anti-tamper.md +0 -11
- package/src/prometheus/doc/steps/constantarray.md +0 -71
- package/src/prometheus/doc/steps/encryptstrings.md +0 -86
- package/src/prometheus/doc/steps/proxifylocals.md +0 -47
- package/src/prometheus/doc/steps/splitstrings.md +0 -40
- package/src/prometheus/doc/steps/vmify.md +0 -9
- package/src/prometheus/doc/steps/wrapinfunction.md +0 -29
- package/src/prometheus/prometheus-main.lua +0 -1
- package/src/prometheus/readme.md +0 -57
- package/src/prometheus/readme.txt +0 -5
- package/src/prometheus/src/cli.lua +0 -154
- package/src/prometheus/src/colors.lua +0 -61
- package/src/prometheus/src/highlightlua.lua +0 -61
- package/src/prometheus/src/logger.lua +0 -62
- package/src/prometheus/src/presets.lua +0 -174
- package/src/prometheus/src/prometheus/ast.lua +0 -792
- package/src/prometheus/src/prometheus/bit.lua +0 -521
- package/src/prometheus/src/prometheus/compiler/compiler.lua +0 -2365
- package/src/prometheus/src/prometheus/enums.lua +0 -106
- package/src/prometheus/src/prometheus/namegenerators/Il.lua +0 -41
- package/src/prometheus/src/prometheus/namegenerators/confuse.lua +0 -169
- package/src/prometheus/src/prometheus/namegenerators/mangled.lua +0 -26
- package/src/prometheus/src/prometheus/namegenerators/mangled_shuffled.lua +0 -35
- package/src/prometheus/src/prometheus/namegenerators/number.lua +0 -11
- package/src/prometheus/src/prometheus/namegenerators.lua +0 -7
- package/src/prometheus/src/prometheus/parser.lua +0 -969
- package/src/prometheus/src/prometheus/pipeline.lua +0 -250
- package/src/prometheus/src/prometheus/randomLiterals.lua +0 -41
- package/src/prometheus/src/prometheus/randomStrings.lua +0 -24
- package/src/prometheus/src/prometheus/scope.lua +0 -332
- package/src/prometheus/src/prometheus/step.lua +0 -79
- package/src/prometheus/src/prometheus/steps/AddVararg.lua +0 -33
- package/src/prometheus/src/prometheus/steps/AntiTamper.lua +0 -194
- package/src/prometheus/src/prometheus/steps/ConstantArray.lua +0 -521
- package/src/prometheus/src/prometheus/steps/EncryptStrings.lua +0 -239
- package/src/prometheus/src/prometheus/steps/NumbersToExpressions.lua +0 -82
- package/src/prometheus/src/prometheus/steps/ProxifyLocals.lua +0 -313
- package/src/prometheus/src/prometheus/steps/SplitStrings.lua +0 -338
- package/src/prometheus/src/prometheus/steps/Vmify.lua +0 -30
- package/src/prometheus/src/prometheus/steps/Watermark.lua +0 -61
- package/src/prometheus/src/prometheus/steps/WatermarkCheck.lua +0 -50
- package/src/prometheus/src/prometheus/steps/WrapInFunction.lua +0 -45
- package/src/prometheus/src/prometheus/steps.lua +0 -12
- package/src/prometheus/src/prometheus/tokenizer.lua +0 -546
- package/src/prometheus/src/prometheus/unparser.lua +0 -866
- package/src/prometheus/src/prometheus/util.lua +0 -297
- package/src/prometheus/src/prometheus/visitast.lua +0 -245
- package/src/prometheus/src/prometheus.lua +0 -71
- package/src/prometheus/tests/closures.lua +0 -12
- package/src/prometheus/tests/fibonacci.lua +0 -10
- package/src/prometheus/tests/loops.lua +0 -8
- package/src/prometheus/tests/primes.lua +0 -18
- package/src/prometheus/tests.lua +0 -149
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
-- This Script is Part of the Prometheus Obfuscator by Levno_710
|
|
2
|
-
--
|
|
3
|
-
-- util.lua
|
|
4
|
-
-- This file Provides some utility functions
|
|
5
|
-
|
|
6
|
-
local logger = require("logger");
|
|
7
|
-
local bit32 = require("prometheus.bit").bit32;
|
|
8
|
-
|
|
9
|
-
local MAX_UNPACK_COUNT = 195;
|
|
10
|
-
|
|
11
|
-
local function lookupify(tb)
|
|
12
|
-
local tb2 = {};
|
|
13
|
-
for _, v in ipairs(tb) do
|
|
14
|
-
tb2[v] = true
|
|
15
|
-
end
|
|
16
|
-
return tb2
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
local function unlookupify(tb)
|
|
20
|
-
local tb2 = {};
|
|
21
|
-
for v, _ in pairs(tb) do
|
|
22
|
-
table.insert(tb2, v);
|
|
23
|
-
end
|
|
24
|
-
return tb2;
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
local function escape(str)
|
|
28
|
-
return str:gsub(".", function(char)
|
|
29
|
-
if char:match("[^ %-~\n\t\a\b\v\r\"\']") then -- Check if non Printable ASCII Character
|
|
30
|
-
return string.format("\\%03d", string.byte(char))
|
|
31
|
-
end
|
|
32
|
-
if(char == "\\") then
|
|
33
|
-
return "\\\\";
|
|
34
|
-
end
|
|
35
|
-
if(char == "\n") then
|
|
36
|
-
return "\\n";
|
|
37
|
-
end
|
|
38
|
-
if(char == "\r") then
|
|
39
|
-
return "\\r";
|
|
40
|
-
end
|
|
41
|
-
if(char == "\t") then
|
|
42
|
-
return "\\t";
|
|
43
|
-
end
|
|
44
|
-
if(char == "\a") then
|
|
45
|
-
return "\\a";
|
|
46
|
-
end
|
|
47
|
-
if(char == "\b") then
|
|
48
|
-
return "\\b";
|
|
49
|
-
end
|
|
50
|
-
if(char == "\v") then
|
|
51
|
-
return "\\v";
|
|
52
|
-
end
|
|
53
|
-
if(char == "\"") then
|
|
54
|
-
return "\\\"";
|
|
55
|
-
end
|
|
56
|
-
if(char == "\'") then
|
|
57
|
-
return "\\\'";
|
|
58
|
-
end
|
|
59
|
-
return char;
|
|
60
|
-
end)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
local function chararray(str)
|
|
64
|
-
local tb = {};
|
|
65
|
-
for i = 1, str:len(), 1 do
|
|
66
|
-
table.insert(tb, str:sub(i, i));
|
|
67
|
-
end
|
|
68
|
-
return tb;
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
local function keys(tb)
|
|
72
|
-
local keyset={}
|
|
73
|
-
local n=0
|
|
74
|
-
for k,v in pairs(tb) do
|
|
75
|
-
n=n+1
|
|
76
|
-
keyset[n]=k
|
|
77
|
-
end
|
|
78
|
-
return keyset
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
local utf8char;
|
|
82
|
-
do
|
|
83
|
-
local string_char = string.char
|
|
84
|
-
function utf8char(cp)
|
|
85
|
-
if cp < 128 then
|
|
86
|
-
return string_char(cp)
|
|
87
|
-
end
|
|
88
|
-
local suffix = cp % 64
|
|
89
|
-
local c4 = 128 + suffix
|
|
90
|
-
cp = (cp - suffix) / 64
|
|
91
|
-
if cp < 32 then
|
|
92
|
-
return string_char(192 + cp, c4)
|
|
93
|
-
end
|
|
94
|
-
suffix = cp % 64
|
|
95
|
-
local c3 = 128 + suffix
|
|
96
|
-
cp = (cp - suffix) / 64
|
|
97
|
-
if cp < 16 then
|
|
98
|
-
return string_char(224 + cp, c3, c4)
|
|
99
|
-
end
|
|
100
|
-
suffix = cp % 64
|
|
101
|
-
cp = (cp - suffix) / 64
|
|
102
|
-
return string_char(240 + cp, 128 + suffix, c3, c4)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
local function shuffle(tb)
|
|
107
|
-
for i = #tb, 2, -1 do
|
|
108
|
-
local j = math.random(i)
|
|
109
|
-
tb[i], tb[j] = tb[j], tb[i]
|
|
110
|
-
end
|
|
111
|
-
return tb
|
|
112
|
-
end
|
|
113
|
-
local function shuffle_string(str)
|
|
114
|
-
local len = #str
|
|
115
|
-
local t = {}
|
|
116
|
-
for i = 1, len do
|
|
117
|
-
t[i] = string.sub(str, i, i)
|
|
118
|
-
end
|
|
119
|
-
for i = 1, len do
|
|
120
|
-
local j = math.random(i, len)
|
|
121
|
-
t[i], t[j] = t[j], t[i]
|
|
122
|
-
end
|
|
123
|
-
return table.concat(t)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
local function readDouble(bytes)
|
|
127
|
-
local sign = 1
|
|
128
|
-
local mantissa = bytes[2] % 2^4
|
|
129
|
-
for i = 3, 8 do
|
|
130
|
-
mantissa = mantissa * 256 + bytes[i]
|
|
131
|
-
end
|
|
132
|
-
if bytes[1] > 127 then sign = -1 end
|
|
133
|
-
local exponent = (bytes[1] % 128) * 2^4 + math.floor(bytes[2] / 2^4)
|
|
134
|
-
|
|
135
|
-
if exponent == 0 then
|
|
136
|
-
return 0
|
|
137
|
-
end
|
|
138
|
-
mantissa = (math.ldexp(mantissa, -52) + 1) * sign
|
|
139
|
-
return math.ldexp(mantissa, exponent - 1023)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
local function writeDouble(num)
|
|
143
|
-
local bytes = {0,0,0,0, 0,0,0,0}
|
|
144
|
-
if num == 0 then
|
|
145
|
-
return bytes
|
|
146
|
-
end
|
|
147
|
-
local anum = math.abs(num)
|
|
148
|
-
|
|
149
|
-
local mantissa, exponent = math.frexp(anum)
|
|
150
|
-
exponent = exponent - 1
|
|
151
|
-
mantissa = mantissa * 2 - 1
|
|
152
|
-
local sign = num ~= anum and 128 or 0
|
|
153
|
-
exponent = exponent + 1023
|
|
154
|
-
|
|
155
|
-
bytes[1] = sign + math.floor(exponent / 2^4)
|
|
156
|
-
mantissa = mantissa * 2^4
|
|
157
|
-
local currentmantissa = math.floor(mantissa)
|
|
158
|
-
mantissa = mantissa - currentmantissa
|
|
159
|
-
bytes[2] = (exponent % 2^4) * 2^4 + currentmantissa
|
|
160
|
-
for i= 3, 8 do
|
|
161
|
-
mantissa = mantissa * 2^8
|
|
162
|
-
currentmantissa = math.floor(mantissa)
|
|
163
|
-
mantissa = mantissa - currentmantissa
|
|
164
|
-
bytes[i] = currentmantissa
|
|
165
|
-
end
|
|
166
|
-
return bytes
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
local function writeU16(u16)
|
|
170
|
-
if (u16 < 0 or u16 > 65535) then
|
|
171
|
-
logger:error(string.format("u16 out of bounds: %d", u16));
|
|
172
|
-
end
|
|
173
|
-
local lower = bit32.band(u16, 255);
|
|
174
|
-
local upper = bit32.rshift(u16, 8);
|
|
175
|
-
return {lower, upper}
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
local function readU16(arr)
|
|
179
|
-
return bit32.bor(arr[1], bit32.lshift(arr[2], 8));
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
local function writeU24(u24)
|
|
183
|
-
if(u24 < 0 or u24 > 16777215) then
|
|
184
|
-
logger:error(string.format("u24 out of bounds: %d", u24));
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
local arr = {};
|
|
188
|
-
for i = 0, 2 do
|
|
189
|
-
arr[i + 1] = bit32.band(bit32.rshift(u24, 8 * i), 255);
|
|
190
|
-
end
|
|
191
|
-
return arr;
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
local function readU24(arr)
|
|
195
|
-
local val = 0;
|
|
196
|
-
|
|
197
|
-
for i = 0, 2 do
|
|
198
|
-
val = bit32.bor(val, bit32.lshift(arr[i + 1], 8 * i));
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
return val;
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
local function writeU32(u32)
|
|
205
|
-
if(u32 < 0 or u32 > 4294967295) then
|
|
206
|
-
logger:error(string.format("u32 out of bounds: %d", u32));
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
local arr = {};
|
|
210
|
-
for i = 0, 3 do
|
|
211
|
-
arr[i + 1] = bit32.band(bit32.rshift(u32, 8 * i), 255);
|
|
212
|
-
end
|
|
213
|
-
return arr;
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
local function readU32(arr)
|
|
217
|
-
local val = 0;
|
|
218
|
-
|
|
219
|
-
for i = 0, 3 do
|
|
220
|
-
val = bit32.bor(val, bit32.lshift(arr[i + 1], 8 * i));
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
return val;
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
local function bytesToString(arr)
|
|
227
|
-
local lenght = arr.n or #arr;
|
|
228
|
-
|
|
229
|
-
if lenght < MAX_UNPACK_COUNT then
|
|
230
|
-
return string.char(table.unpack(arr))
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
local str = "";
|
|
234
|
-
local overflow = lenght % MAX_UNPACK_COUNT;
|
|
235
|
-
|
|
236
|
-
for i = 1, (#arr - overflow) / MAX_UNPACK_COUNT do
|
|
237
|
-
str = str .. string.char(table.unpack(arr, (i - 1) * MAX_UNPACK_COUNT + 1, i * MAX_UNPACK_COUNT));
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
return str..(overflow > 0 and string.char(table.unpack(arr, lenght - overflow + 1, lenght)) or "");
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
local function isNaN(n)
|
|
244
|
-
return type(n) == "number" and n ~= n;
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
local function isInt(n)
|
|
248
|
-
return math.floor(n) == n;
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
local function isU32(n)
|
|
252
|
-
return n >= 0 and n <= 4294967295 and isInt(n);
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
local function toBits(num)
|
|
256
|
-
-- returns a table of bits, least significant first.
|
|
257
|
-
local t={} -- will contain the bits
|
|
258
|
-
local rest;
|
|
259
|
-
while num>0 do
|
|
260
|
-
rest=math.fmod(num,2)
|
|
261
|
-
t[#t+1]=rest
|
|
262
|
-
num=(num-rest)/2
|
|
263
|
-
end
|
|
264
|
-
return t
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
local function readonly(obj)
|
|
269
|
-
local r = newproxy(true);
|
|
270
|
-
getmetatable(r).__index = obj;
|
|
271
|
-
return r;
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
lookupify = lookupify,
|
|
276
|
-
unlookupify = unlookupify,
|
|
277
|
-
escape = escape,
|
|
278
|
-
chararray = chararray,
|
|
279
|
-
keys = keys,
|
|
280
|
-
shuffle = shuffle,
|
|
281
|
-
shuffle_string = shuffle_string,
|
|
282
|
-
readDouble = readDouble,
|
|
283
|
-
writeDouble = writeDouble,
|
|
284
|
-
readU16 = readU16,
|
|
285
|
-
writeU16 = writeU16,
|
|
286
|
-
readU32 = readU32,
|
|
287
|
-
writeU32 = writeU32,
|
|
288
|
-
readU24 = readU24,
|
|
289
|
-
writeU24 = writeU24,
|
|
290
|
-
isNaN = isNaN,
|
|
291
|
-
isU32 = isU32,
|
|
292
|
-
isInt = isInt,
|
|
293
|
-
utf8char = utf8char,
|
|
294
|
-
toBits = toBits,
|
|
295
|
-
bytesToString = bytesToString,
|
|
296
|
-
readonly = readonly,
|
|
297
|
-
}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
-- This Script is Part of the Prometheus Obfuscator by Levno_710
|
|
2
|
-
--
|
|
3
|
-
-- util.lua
|
|
4
|
-
-- This file Provides a Utility function for visiting each node of an ast
|
|
5
|
-
|
|
6
|
-
local Ast = require("prometheus.ast");
|
|
7
|
-
local util = require("prometheus.util");
|
|
8
|
-
|
|
9
|
-
local AstKind = Ast.AstKind;
|
|
10
|
-
local lookupify = util.lookupify;
|
|
11
|
-
|
|
12
|
-
local visitAst, visitBlock, visitStatement, visitExpression;
|
|
13
|
-
|
|
14
|
-
function visitAst(ast, previsit, postvisit, data)
|
|
15
|
-
ast.isAst = true;
|
|
16
|
-
data = data or {};
|
|
17
|
-
data.scopeStack = {};
|
|
18
|
-
data.functionData = {
|
|
19
|
-
depth = 0;
|
|
20
|
-
scope = ast.body.scope;
|
|
21
|
-
node = ast;
|
|
22
|
-
};
|
|
23
|
-
data.scope = ast.globalScope;
|
|
24
|
-
data.globalScope = ast.globalScope;
|
|
25
|
-
if(type(previsit) == "function") then
|
|
26
|
-
local node, skip = previsit(ast, data);
|
|
27
|
-
ast = node or ast;
|
|
28
|
-
if skip then
|
|
29
|
-
return ast;
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
-- Is Function Block because global scope is treated like a Function
|
|
34
|
-
visitBlock(ast.body, previsit, postvisit, data, true);
|
|
35
|
-
|
|
36
|
-
if(type(postvisit) == "function") then
|
|
37
|
-
ast = postvisit(ast, data) or ast;
|
|
38
|
-
end
|
|
39
|
-
return ast;
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
local compundStats = lookupify{
|
|
43
|
-
AstKind.CompoundAddStatement,
|
|
44
|
-
AstKind.CompoundSubStatement,
|
|
45
|
-
AstKind.CompoundMulStatement,
|
|
46
|
-
AstKind.CompoundDivStatement,
|
|
47
|
-
AstKind.CompoundModStatement,
|
|
48
|
-
AstKind.CompoundPowStatement,
|
|
49
|
-
AstKind.CompoundConcatStatement,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function visitBlock(block, previsit, postvisit, data, isFunctionBlock)
|
|
53
|
-
block.isBlock = true;
|
|
54
|
-
block.isFunctionBlock = isFunctionBlock or false;
|
|
55
|
-
data.scope = block.scope;
|
|
56
|
-
local parentBlockData = data.blockData;
|
|
57
|
-
data.blockData = {};
|
|
58
|
-
table.insert(data.scopeStack, block.scope);
|
|
59
|
-
if(type(previsit) == "function") then
|
|
60
|
-
local node, skip = previsit(block, data);
|
|
61
|
-
block = node or block;
|
|
62
|
-
if skip then
|
|
63
|
-
data.scope = table.remove(data.scopeStack);
|
|
64
|
-
return block
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
local i = 1;
|
|
69
|
-
while i <= #block.statements do
|
|
70
|
-
local statement = table.remove(block.statements, i);
|
|
71
|
-
i = i - 1;
|
|
72
|
-
local returnedStatements = {visitStatement(statement, previsit, postvisit, data)};
|
|
73
|
-
for j, statement in ipairs(returnedStatements) do
|
|
74
|
-
i = i + 1;
|
|
75
|
-
table.insert(block.statements, i, statement);
|
|
76
|
-
end
|
|
77
|
-
i = i + 1;
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
if(type(postvisit) == "function") then
|
|
81
|
-
block = postvisit(block, data) or block;
|
|
82
|
-
end
|
|
83
|
-
data.scope = table.remove(data.scopeStack);
|
|
84
|
-
data.blockData = parentBlockData;
|
|
85
|
-
return block;
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
function visitStatement(statement, previsit, postvisit, data)
|
|
89
|
-
statement.isStatement = true;
|
|
90
|
-
if(type(previsit) == "function") then
|
|
91
|
-
local node, skip = previsit(statement, data);
|
|
92
|
-
statement = node or statement;
|
|
93
|
-
if skip then
|
|
94
|
-
return statement;
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
-- Visit Child Nodes of Statement
|
|
99
|
-
if(statement.kind == AstKind.ReturnStatement) then
|
|
100
|
-
for i, expression in ipairs(statement.args) do
|
|
101
|
-
statement.args[i] = visitExpression(expression, previsit, postvisit, data);
|
|
102
|
-
end
|
|
103
|
-
elseif(statement.kind == AstKind.PassSelfFunctionCallStatement or statement.kind == AstKind.FunctionCallStatement) then
|
|
104
|
-
statement.base = visitExpression(statement.base, previsit, postvisit, data);
|
|
105
|
-
for i, expression in ipairs(statement.args) do
|
|
106
|
-
statement.args[i] = visitExpression(expression, previsit, postvisit, data);
|
|
107
|
-
end
|
|
108
|
-
elseif(statement.kind == AstKind.AssignmentStatement) then
|
|
109
|
-
for i, primaryExpr in ipairs(statement.lhs) do
|
|
110
|
-
statement.lhs[i] = visitExpression(primaryExpr, previsit, postvisit, data);
|
|
111
|
-
end
|
|
112
|
-
for i, expression in ipairs(statement.rhs) do
|
|
113
|
-
statement.rhs[i] = visitExpression(expression, previsit, postvisit, data);
|
|
114
|
-
end
|
|
115
|
-
elseif(statement.kind == AstKind.FunctionDeclaration or statement.kind == AstKind.LocalFunctionDeclaration) then
|
|
116
|
-
local parentFunctionData = data.functionData;
|
|
117
|
-
data.functionData = {
|
|
118
|
-
depth = parentFunctionData.depth + 1;
|
|
119
|
-
scope = statement.body.scope;
|
|
120
|
-
node = statement;
|
|
121
|
-
};
|
|
122
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data, true);
|
|
123
|
-
data.functionData = parentFunctionData;
|
|
124
|
-
elseif(statement.kind == AstKind.DoStatement) then
|
|
125
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data, false);
|
|
126
|
-
elseif(statement.kind == AstKind.WhileStatement) then
|
|
127
|
-
statement.condition = visitExpression(statement.condition, previsit, postvisit, data);
|
|
128
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data, false);
|
|
129
|
-
elseif(statement.kind == AstKind.RepeatStatement) then
|
|
130
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data);
|
|
131
|
-
statement.condition = visitExpression(statement.condition, previsit, postvisit, data);
|
|
132
|
-
elseif(statement.kind == AstKind.ForStatement) then
|
|
133
|
-
statement.initialValue = visitExpression(statement.initialValue, previsit, postvisit, data);
|
|
134
|
-
statement.finalValue = visitExpression(statement.finalValue, previsit, postvisit, data);
|
|
135
|
-
statement.incrementBy = visitExpression(statement.incrementBy, previsit, postvisit, data);
|
|
136
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data, false);
|
|
137
|
-
elseif(statement.kind == AstKind.ForInStatement) then
|
|
138
|
-
for i, expression in ipairs(statement.expressions) do
|
|
139
|
-
statement.expressions[i] = visitExpression(expression, previsit, postvisit, data);
|
|
140
|
-
end
|
|
141
|
-
visitBlock(statement.body, previsit, postvisit, data, false);
|
|
142
|
-
elseif(statement.kind == AstKind.IfStatement) then
|
|
143
|
-
statement.condition = visitExpression(statement.condition, previsit, postvisit, data);
|
|
144
|
-
statement.body = visitBlock(statement.body, previsit, postvisit, data, false);
|
|
145
|
-
for i, eif in ipairs(statement.elseifs) do
|
|
146
|
-
eif.condition = visitExpression(eif.condition, previsit, postvisit, data);
|
|
147
|
-
eif.body = visitBlock(eif.body, previsit, postvisit, data, false);
|
|
148
|
-
end
|
|
149
|
-
if(statement.elsebody) then
|
|
150
|
-
statement.elsebody = visitBlock(statement.elsebody, previsit, postvisit, data, false);
|
|
151
|
-
end
|
|
152
|
-
elseif(statement.kind == AstKind.LocalVariableDeclaration) then
|
|
153
|
-
for i, expression in ipairs(statement.expressions) do
|
|
154
|
-
statement.expressions[i] = visitExpression(expression, previsit, postvisit, data);
|
|
155
|
-
end
|
|
156
|
-
elseif compundStats[statement.kind] then
|
|
157
|
-
statement.lhs = visitExpression(statement.lhs, previsit, postvisit, data);
|
|
158
|
-
statement.rhs = visitExpression(statement.rhs, previsit, postvisit, data);
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
if(type(postvisit) == "function") then
|
|
162
|
-
local statements = {postvisit(statement, data)};
|
|
163
|
-
if #statements > 0 then
|
|
164
|
-
return unpack(statements);
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
return statement;
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
local binaryExpressions = lookupify{
|
|
172
|
-
AstKind.OrExpression,
|
|
173
|
-
AstKind.AndExpression,
|
|
174
|
-
AstKind.LessThanExpression,
|
|
175
|
-
AstKind.GreaterThanExpression,
|
|
176
|
-
AstKind.LessThanOrEqualsExpression,
|
|
177
|
-
AstKind.GreaterThanOrEqualsExpression,
|
|
178
|
-
AstKind.NotEqualsExpression,
|
|
179
|
-
AstKind.EqualsExpression,
|
|
180
|
-
AstKind.StrCatExpression,
|
|
181
|
-
AstKind.AddExpression,
|
|
182
|
-
AstKind.SubExpression,
|
|
183
|
-
AstKind.MulExpression,
|
|
184
|
-
AstKind.DivExpression,
|
|
185
|
-
AstKind.ModExpression,
|
|
186
|
-
AstKind.PowExpression,
|
|
187
|
-
}
|
|
188
|
-
function visitExpression(expression, previsit, postvisit, data)
|
|
189
|
-
expression.isExpression = true;
|
|
190
|
-
if(type(previsit) == "function") then
|
|
191
|
-
local node, skip = previsit(expression, data);
|
|
192
|
-
expression = node or expression;
|
|
193
|
-
if skip then
|
|
194
|
-
return expression;
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
if(binaryExpressions[expression.kind]) then
|
|
199
|
-
expression.lhs = visitExpression(expression.lhs, previsit, postvisit, data);
|
|
200
|
-
expression.rhs = visitExpression(expression.rhs, previsit, postvisit, data);
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
if(expression.kind == AstKind.NotExpression or expression.kind == AstKind.NegateExpression or expression.kind == AstKind.LenExpression) then
|
|
204
|
-
expression.rhs = visitExpression(expression.rhs, previsit, postvisit, data);
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
if(expression.kind == AstKind.PassSelfFunctionCallExpression or expression.kind == AstKind.FunctionCallExpression) then
|
|
208
|
-
expression.base = visitExpression(expression.base, previsit, postvisit, data);
|
|
209
|
-
for i, arg in ipairs(expression.args) do
|
|
210
|
-
expression.args[i] = visitExpression(arg, previsit, postvisit, data);
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
if(expression.kind == AstKind.FunctionLiteralExpression) then
|
|
215
|
-
local parentFunctionData = data.functionData;
|
|
216
|
-
data.functionData = {
|
|
217
|
-
depth = parentFunctionData.depth + 1;
|
|
218
|
-
scope = expression.body.scope;
|
|
219
|
-
node = expression;
|
|
220
|
-
};
|
|
221
|
-
expression.body = visitBlock(expression.body, previsit, postvisit, data, true);
|
|
222
|
-
data.functionData = parentFunctionData;
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
if(expression.kind == AstKind.TableConstructorExpression) then
|
|
226
|
-
for i, entry in ipairs(expression.entries) do
|
|
227
|
-
if entry.kind == AstKind.KeyedTableEntry then
|
|
228
|
-
entry.key = visitExpression(entry.key, previsit, postvisit, data);
|
|
229
|
-
end
|
|
230
|
-
entry.value = visitExpression(entry.value, previsit, postvisit, data);
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
if(expression.kind == AstKind.IndexExpression or expression.kind == AstKind.AssignmentIndexing) then
|
|
235
|
-
expression.base = visitExpression(expression.base, previsit, postvisit, data);
|
|
236
|
-
expression.index = visitExpression(expression.index, previsit, postvisit, data);
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
if(type(postvisit) == "function") then
|
|
240
|
-
expression = postvisit(expression, data) or expression;
|
|
241
|
-
end
|
|
242
|
-
return expression;
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
return visitAst;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
-- This Script is Part of the Prometheus Obfuscator by Levno_710
|
|
2
|
-
--
|
|
3
|
-
-- prometheus.lua
|
|
4
|
-
-- This file is the entrypoint for Prometheus
|
|
5
|
-
|
|
6
|
-
-- Configure package.path for require
|
|
7
|
-
local function script_path()
|
|
8
|
-
local str = debug.getinfo(2, "S").source:sub(2)
|
|
9
|
-
return str:match("(.*[/%\\])")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
local oldPkgPath = package.path;
|
|
13
|
-
package.path = script_path() .. "?.lua;" .. package.path;
|
|
14
|
-
|
|
15
|
-
-- Math.random Fix for Lua5.1
|
|
16
|
-
-- Check if fix is needed
|
|
17
|
-
if not pcall(function()
|
|
18
|
-
return math.random(1, 2^40);
|
|
19
|
-
end) then
|
|
20
|
-
local oldMathRandom = math.random;
|
|
21
|
-
math.random = function(a, b)
|
|
22
|
-
if not a and b then
|
|
23
|
-
return oldMathRandom();
|
|
24
|
-
end
|
|
25
|
-
if not b then
|
|
26
|
-
return math.random(1, a);
|
|
27
|
-
end
|
|
28
|
-
if a > b then
|
|
29
|
-
a, b = b, a;
|
|
30
|
-
end
|
|
31
|
-
local diff = b - a;
|
|
32
|
-
assert(diff >= 0);
|
|
33
|
-
if diff > 2 ^ 31 - 1 then
|
|
34
|
-
return math.floor(oldMathRandom() * diff + a);
|
|
35
|
-
else
|
|
36
|
-
return oldMathRandom(a, b);
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
-- newproxy polyfill
|
|
42
|
-
_G.newproxy = _G.newproxy or function(arg)
|
|
43
|
-
if arg then
|
|
44
|
-
return setmetatable({}, {});
|
|
45
|
-
end
|
|
46
|
-
return {};
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-- Require Prometheus Submodules
|
|
51
|
-
local Pipeline = require("prometheus.pipeline");
|
|
52
|
-
local highlight = require("highlightlua");
|
|
53
|
-
local colors = require("colors");
|
|
54
|
-
local Logger = require("logger");
|
|
55
|
-
local Presets = require("presets");
|
|
56
|
-
local Config = require("config");
|
|
57
|
-
local util = require("prometheus.util");
|
|
58
|
-
|
|
59
|
-
-- Restore package.path
|
|
60
|
-
package.path = oldPkgPath;
|
|
61
|
-
|
|
62
|
-
-- Export
|
|
63
|
-
return {
|
|
64
|
-
Pipeline = Pipeline;
|
|
65
|
-
colors = colors;
|
|
66
|
-
Config = util.readonly(Config); -- Readonly
|
|
67
|
-
Logger = Logger;
|
|
68
|
-
highlight = highlight;
|
|
69
|
-
Presets = Presets;
|
|
70
|
-
}
|
|
71
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
-- print first n primes
|
|
2
|
-
local function primes(n)
|
|
3
|
-
local function isPrime(n)
|
|
4
|
-
for i = 2, math.sqrt(n) do
|
|
5
|
-
if n % i == 0 then
|
|
6
|
-
return false
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
return true
|
|
10
|
-
end
|
|
11
|
-
for i = 2, n do
|
|
12
|
-
if isPrime(i) then
|
|
13
|
-
print(i)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
primes(20)
|