lua-obfuscator 1.0.0
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/dist/index.d.ts +14 -0
- package/dist/index.js +58 -0
- package/dist/prometheus/LICENSE +661 -0
- package/dist/prometheus/benchmark.lua +34 -0
- package/dist/prometheus/build.bat +10 -0
- package/dist/prometheus/cli.lua +12 -0
- package/dist/prometheus/doc/README.md +11 -0
- package/dist/prometheus/doc/SUMMARY.md +27 -0
- package/dist/prometheus/doc/advanced/using-prometheus-in-your-lua-application.md +31 -0
- package/dist/prometheus/doc/getting-started/command-line-options.md +13 -0
- package/dist/prometheus/doc/getting-started/installation.md +11 -0
- package/dist/prometheus/doc/getting-started/obfuscating-your-first-script.md +50 -0
- package/dist/prometheus/doc/getting-started/presets.md +10 -0
- package/dist/prometheus/doc/getting-started/the-config-object.md +58 -0
- package/dist/prometheus/doc/getting-started/writing-a-custom-config-file.md +56 -0
- package/dist/prometheus/doc/steps/anti-tamper.md +11 -0
- package/dist/prometheus/doc/steps/constantarray.md +71 -0
- package/dist/prometheus/doc/steps/encryptstrings.md +86 -0
- package/dist/prometheus/doc/steps/proxifylocals.md +47 -0
- package/dist/prometheus/doc/steps/splitstrings.md +40 -0
- package/dist/prometheus/doc/steps/vmify.md +9 -0
- package/dist/prometheus/doc/steps/wrapinfunction.md +29 -0
- package/dist/prometheus/prometheus-main.lua +1 -0
- package/dist/prometheus/readme.md +57 -0
- package/dist/prometheus/readme.txt +5 -0
- package/dist/prometheus/src/cli.lua +154 -0
- package/dist/prometheus/src/colors.lua +61 -0
- package/dist/prometheus/src/config.lua +35 -0
- package/dist/prometheus/src/highlightlua.lua +61 -0
- package/dist/prometheus/src/logger.lua +62 -0
- package/dist/prometheus/src/presets.lua +174 -0
- package/dist/prometheus/src/prometheus/ast.lua +792 -0
- package/dist/prometheus/src/prometheus/bit.lua +521 -0
- package/dist/prometheus/src/prometheus/compiler/compiler.lua +2365 -0
- package/dist/prometheus/src/prometheus/enums.lua +106 -0
- package/dist/prometheus/src/prometheus/namegenerators/Il.lua +41 -0
- package/dist/prometheus/src/prometheus/namegenerators/confuse.lua +169 -0
- package/dist/prometheus/src/prometheus/namegenerators/mangled.lua +26 -0
- package/dist/prometheus/src/prometheus/namegenerators/mangled_shuffled.lua +35 -0
- package/dist/prometheus/src/prometheus/namegenerators/number.lua +11 -0
- package/dist/prometheus/src/prometheus/namegenerators.lua +7 -0
- package/dist/prometheus/src/prometheus/parser.lua +969 -0
- package/dist/prometheus/src/prometheus/pipeline.lua +250 -0
- package/dist/prometheus/src/prometheus/randomLiterals.lua +41 -0
- package/dist/prometheus/src/prometheus/randomStrings.lua +24 -0
- package/dist/prometheus/src/prometheus/scope.lua +332 -0
- package/dist/prometheus/src/prometheus/step.lua +79 -0
- package/dist/prometheus/src/prometheus/steps/AddVararg.lua +33 -0
- package/dist/prometheus/src/prometheus/steps/AntiTamper.lua +194 -0
- package/dist/prometheus/src/prometheus/steps/ConstantArray.lua +521 -0
- package/dist/prometheus/src/prometheus/steps/EncryptStrings.lua +239 -0
- package/dist/prometheus/src/prometheus/steps/NumbersToExpressions.lua +82 -0
- package/dist/prometheus/src/prometheus/steps/ProxifyLocals.lua +313 -0
- package/dist/prometheus/src/prometheus/steps/SplitStrings.lua +338 -0
- package/dist/prometheus/src/prometheus/steps/Vmify.lua +30 -0
- package/dist/prometheus/src/prometheus/steps/Watermark.lua +61 -0
- package/dist/prometheus/src/prometheus/steps/WatermarkCheck.lua +50 -0
- package/dist/prometheus/src/prometheus/steps/WrapInFunction.lua +45 -0
- package/dist/prometheus/src/prometheus/steps.lua +12 -0
- package/dist/prometheus/src/prometheus/tokenizer.lua +546 -0
- package/dist/prometheus/src/prometheus/unparser.lua +866 -0
- package/dist/prometheus/src/prometheus/util.lua +297 -0
- package/dist/prometheus/src/prometheus/visitast.lua +245 -0
- package/dist/prometheus/src/prometheus.lua +71 -0
- package/dist/prometheus/tests/closures.lua +12 -0
- package/dist/prometheus/tests/fibonacci.lua +10 -0
- package/dist/prometheus/tests/loops.lua +8 -0
- package/dist/prometheus/tests/primes.lua +18 -0
- package/dist/prometheus/tests.lua +149 -0
- package/package.json +25 -0
- package/src/index.ts +76 -0
- package/src/prometheus/.editorconfig +4 -0
- package/src/prometheus/.gitattributes +2 -0
- package/src/prometheus/.gitbook.yaml +1 -0
- package/src/prometheus/.github/ISSUE_TEMPLATE/bug_report.md +25 -0
- package/src/prometheus/.github/workflows/Build.yml +49 -0
- package/src/prometheus/.github/workflows/Test.yml +19 -0
- package/src/prometheus/LICENSE +661 -0
- package/src/prometheus/benchmark.lua +34 -0
- package/src/prometheus/build.bat +10 -0
- package/src/prometheus/cli.lua +12 -0
- package/src/prometheus/doc/README.md +11 -0
- package/src/prometheus/doc/SUMMARY.md +27 -0
- package/src/prometheus/doc/advanced/using-prometheus-in-your-lua-application.md +31 -0
- package/src/prometheus/doc/getting-started/command-line-options.md +13 -0
- package/src/prometheus/doc/getting-started/installation.md +11 -0
- package/src/prometheus/doc/getting-started/obfuscating-your-first-script.md +50 -0
- package/src/prometheus/doc/getting-started/presets.md +10 -0
- package/src/prometheus/doc/getting-started/the-config-object.md +58 -0
- package/src/prometheus/doc/getting-started/writing-a-custom-config-file.md +56 -0
- package/src/prometheus/doc/steps/anti-tamper.md +11 -0
- package/src/prometheus/doc/steps/constantarray.md +71 -0
- package/src/prometheus/doc/steps/encryptstrings.md +86 -0
- package/src/prometheus/doc/steps/proxifylocals.md +47 -0
- package/src/prometheus/doc/steps/splitstrings.md +40 -0
- package/src/prometheus/doc/steps/vmify.md +9 -0
- package/src/prometheus/doc/steps/wrapinfunction.md +29 -0
- package/src/prometheus/prometheus-main.lua +1 -0
- package/src/prometheus/readme.md +57 -0
- package/src/prometheus/readme.txt +5 -0
- package/src/prometheus/src/cli.lua +154 -0
- package/src/prometheus/src/colors.lua +61 -0
- package/src/prometheus/src/highlightlua.lua +61 -0
- package/src/prometheus/src/logger.lua +62 -0
- package/src/prometheus/src/presets.lua +174 -0
- package/src/prometheus/src/prometheus/ast.lua +792 -0
- package/src/prometheus/src/prometheus/bit.lua +521 -0
- package/src/prometheus/src/prometheus/compiler/compiler.lua +2365 -0
- package/src/prometheus/src/prometheus/enums.lua +106 -0
- package/src/prometheus/src/prometheus/namegenerators/Il.lua +41 -0
- package/src/prometheus/src/prometheus/namegenerators/confuse.lua +169 -0
- package/src/prometheus/src/prometheus/namegenerators/mangled.lua +26 -0
- package/src/prometheus/src/prometheus/namegenerators/mangled_shuffled.lua +35 -0
- package/src/prometheus/src/prometheus/namegenerators/number.lua +11 -0
- package/src/prometheus/src/prometheus/namegenerators.lua +7 -0
- package/src/prometheus/src/prometheus/parser.lua +969 -0
- package/src/prometheus/src/prometheus/pipeline.lua +250 -0
- package/src/prometheus/src/prometheus/randomLiterals.lua +41 -0
- package/src/prometheus/src/prometheus/randomStrings.lua +24 -0
- package/src/prometheus/src/prometheus/scope.lua +332 -0
- package/src/prometheus/src/prometheus/step.lua +79 -0
- package/src/prometheus/src/prometheus/steps/AddVararg.lua +33 -0
- package/src/prometheus/src/prometheus/steps/AntiTamper.lua +194 -0
- package/src/prometheus/src/prometheus/steps/ConstantArray.lua +521 -0
- package/src/prometheus/src/prometheus/steps/EncryptStrings.lua +239 -0
- package/src/prometheus/src/prometheus/steps/NumbersToExpressions.lua +82 -0
- package/src/prometheus/src/prometheus/steps/ProxifyLocals.lua +313 -0
- package/src/prometheus/src/prometheus/steps/SplitStrings.lua +338 -0
- package/src/prometheus/src/prometheus/steps/Vmify.lua +30 -0
- package/src/prometheus/src/prometheus/steps/Watermark.lua +61 -0
- package/src/prometheus/src/prometheus/steps/WatermarkCheck.lua +50 -0
- package/src/prometheus/src/prometheus/steps/WrapInFunction.lua +45 -0
- package/src/prometheus/src/prometheus/steps.lua +12 -0
- package/src/prometheus/src/prometheus/tokenizer.lua +546 -0
- package/src/prometheus/src/prometheus/unparser.lua +866 -0
- package/src/prometheus/src/prometheus/util.lua +297 -0
- package/src/prometheus/src/prometheus/visitast.lua +245 -0
- package/src/prometheus/src/prometheus.lua +71 -0
- package/src/prometheus/tests/closures.lua +12 -0
- package/src/prometheus/tests/fibonacci.lua +10 -0
- package/src/prometheus/tests/loops.lua +8 -0
- package/src/prometheus/tests/primes.lua +18 -0
- package/src/prometheus/tests.lua +149 -0
- package/tsconfig.json +13 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type PrometheusPreset = 'Minify' | 'Weak' | 'Medium' | 'Strong';
|
|
2
|
+
interface PrometheusConfig {
|
|
3
|
+
LuaVersion?: 'Lua51' | 'LuaU';
|
|
4
|
+
VarNamePrefix?: string;
|
|
5
|
+
NameGenerator?: 'Mangled' | 'MangledShuffled' | 'Il' | 'Number';
|
|
6
|
+
PrettyPrint?: boolean;
|
|
7
|
+
Seed?: number;
|
|
8
|
+
Steps: Array<{
|
|
9
|
+
Name: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function obfuscate(text: string, config?: PrometheusPreset | PrometheusConfig): Promise<string>;
|
|
14
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { LuaFactory } from 'wasmoon';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const prometheusPath = path.join(__dirname, '../dist/prometheus');
|
|
7
|
+
const factory = new LuaFactory();
|
|
8
|
+
function mountDirectory(dir, prefix = '') {
|
|
9
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
10
|
+
for (const entry of entries) {
|
|
11
|
+
const fullPath = path.join(dir, entry.name);
|
|
12
|
+
const luaPath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
13
|
+
if (entry.isDirectory()) {
|
|
14
|
+
mountDirectory(fullPath, luaPath);
|
|
15
|
+
}
|
|
16
|
+
else if (entry.name.endsWith('.lua')) {
|
|
17
|
+
console.log('mounting:', luaPath);
|
|
18
|
+
factory.mountFile(luaPath, fs.readFileSync(fullPath));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
mountDirectory(prometheusPath);
|
|
23
|
+
export async function obfuscate(text, config = 'Strong') {
|
|
24
|
+
const lua = await factory.createEngine();
|
|
25
|
+
try {
|
|
26
|
+
await lua.doString(`arg = {}`);
|
|
27
|
+
lua.global.set('__input_code', text);
|
|
28
|
+
let configExpr;
|
|
29
|
+
if (typeof config === 'string') {
|
|
30
|
+
lua.global.set('__preset_name', config);
|
|
31
|
+
configExpr = 'Prometheus.Presets[__preset_name]';
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
lua.global.set('__custom_config', config);
|
|
35
|
+
configExpr = '__custom_config';
|
|
36
|
+
}
|
|
37
|
+
const obfuscated = await lua.doString(`
|
|
38
|
+
local Prometheus = require("src.prometheus")
|
|
39
|
+
Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error
|
|
40
|
+
|
|
41
|
+
local cfg = ${configExpr}
|
|
42
|
+
if cfg == nil then
|
|
43
|
+
error("Invalid preset or config")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
local pipeline = Prometheus.Pipeline:fromConfig(cfg)
|
|
47
|
+
local result = pipeline:apply(__input_code)
|
|
48
|
+
return result
|
|
49
|
+
`);
|
|
50
|
+
if (typeof obfuscated !== 'string') {
|
|
51
|
+
throw new Error('Prometheus returned invalid result');
|
|
52
|
+
}
|
|
53
|
+
return obfuscated;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
lua.global.close();
|
|
57
|
+
}
|
|
58
|
+
}
|