lua-obfuscator 1.0.4 → 3.0.1

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.
Files changed (76) hide show
  1. package/README.md +59 -0
  2. package/dist/index.cjs +4552 -0
  3. package/dist/index.d.cts +399 -0
  4. package/dist/index.d.ts +397 -12
  5. package/dist/index.js +4505 -65
  6. package/package.json +24 -19
  7. package/.github/workflows/release.yml +0 -40
  8. package/dist/prometheus/LICENSE +0 -661
  9. package/dist/prometheus/benchmark.lua +0 -34
  10. package/dist/prometheus/build.bat +0 -10
  11. package/dist/prometheus/cli.lua +0 -12
  12. package/dist/prometheus/doc/README.md +0 -11
  13. package/dist/prometheus/doc/SUMMARY.md +0 -27
  14. package/dist/prometheus/doc/advanced/using-prometheus-in-your-lua-application.md +0 -31
  15. package/dist/prometheus/doc/getting-started/command-line-options.md +0 -13
  16. package/dist/prometheus/doc/getting-started/installation.md +0 -11
  17. package/dist/prometheus/doc/getting-started/obfuscating-your-first-script.md +0 -50
  18. package/dist/prometheus/doc/getting-started/presets.md +0 -10
  19. package/dist/prometheus/doc/getting-started/the-config-object.md +0 -58
  20. package/dist/prometheus/doc/getting-started/writing-a-custom-config-file.md +0 -56
  21. package/dist/prometheus/doc/steps/anti-tamper.md +0 -11
  22. package/dist/prometheus/doc/steps/constantarray.md +0 -71
  23. package/dist/prometheus/doc/steps/encryptstrings.md +0 -86
  24. package/dist/prometheus/doc/steps/proxifylocals.md +0 -47
  25. package/dist/prometheus/doc/steps/splitstrings.md +0 -40
  26. package/dist/prometheus/doc/steps/vmify.md +0 -9
  27. package/dist/prometheus/doc/steps/wrapinfunction.md +0 -29
  28. package/dist/prometheus/prometheus-main.lua +0 -1
  29. package/dist/prometheus/readme.md +0 -57
  30. package/dist/prometheus/readme.txt +0 -5
  31. package/dist/prometheus/src/cli.lua +0 -154
  32. package/dist/prometheus/src/colors.lua +0 -61
  33. package/dist/prometheus/src/config.lua +0 -35
  34. package/dist/prometheus/src/highlightlua.lua +0 -61
  35. package/dist/prometheus/src/logger.lua +0 -62
  36. package/dist/prometheus/src/presets.lua +0 -174
  37. package/dist/prometheus/src/prometheus/ast.lua +0 -792
  38. package/dist/prometheus/src/prometheus/bit.lua +0 -521
  39. package/dist/prometheus/src/prometheus/compiler/compiler.lua +0 -2365
  40. package/dist/prometheus/src/prometheus/enums.lua +0 -106
  41. package/dist/prometheus/src/prometheus/namegenerators/Il.lua +0 -41
  42. package/dist/prometheus/src/prometheus/namegenerators/confuse.lua +0 -169
  43. package/dist/prometheus/src/prometheus/namegenerators/mangled.lua +0 -26
  44. package/dist/prometheus/src/prometheus/namegenerators/mangled_shuffled.lua +0 -35
  45. package/dist/prometheus/src/prometheus/namegenerators/number.lua +0 -11
  46. package/dist/prometheus/src/prometheus/namegenerators.lua +0 -7
  47. package/dist/prometheus/src/prometheus/parser.lua +0 -969
  48. package/dist/prometheus/src/prometheus/pipeline.lua +0 -250
  49. package/dist/prometheus/src/prometheus/randomLiterals.lua +0 -41
  50. package/dist/prometheus/src/prometheus/randomStrings.lua +0 -24
  51. package/dist/prometheus/src/prometheus/scope.lua +0 -332
  52. package/dist/prometheus/src/prometheus/step.lua +0 -79
  53. package/dist/prometheus/src/prometheus/steps/AddVararg.lua +0 -33
  54. package/dist/prometheus/src/prometheus/steps/AntiTamper.lua +0 -194
  55. package/dist/prometheus/src/prometheus/steps/ConstantArray.lua +0 -521
  56. package/dist/prometheus/src/prometheus/steps/EncryptStrings.lua +0 -239
  57. package/dist/prometheus/src/prometheus/steps/NumbersToExpressions.lua +0 -82
  58. package/dist/prometheus/src/prometheus/steps/ProxifyLocals.lua +0 -313
  59. package/dist/prometheus/src/prometheus/steps/SplitStrings.lua +0 -338
  60. package/dist/prometheus/src/prometheus/steps/Vmify.lua +0 -30
  61. package/dist/prometheus/src/prometheus/steps/Watermark.lua +0 -61
  62. package/dist/prometheus/src/prometheus/steps/WatermarkCheck.lua +0 -50
  63. package/dist/prometheus/src/prometheus/steps/WrapInFunction.lua +0 -45
  64. package/dist/prometheus/src/prometheus/steps.lua +0 -12
  65. package/dist/prometheus/src/prometheus/tokenizer.lua +0 -546
  66. package/dist/prometheus/src/prometheus/unparser.lua +0 -866
  67. package/dist/prometheus/src/prometheus/util.lua +0 -297
  68. package/dist/prometheus/src/prometheus/visitast.lua +0 -245
  69. package/dist/prometheus/src/prometheus.lua +0 -71
  70. package/dist/prometheus/tests/closures.lua +0 -12
  71. package/dist/prometheus/tests/fibonacci.lua +0 -10
  72. package/dist/prometheus/tests/loops.lua +0 -8
  73. package/dist/prometheus/tests/primes.lua +0 -18
  74. package/dist/prometheus/tests.lua +0 -149
  75. package/src/index.ts +0 -100
  76. package/tsconfig.json +0 -13
@@ -1,149 +0,0 @@
1
- -- This Script is Part of the Prometheus Obfuscator by Levno_710
2
- --
3
- -- test.lua
4
- -- This file will Perform tests using all lua files within the tests directory
5
-
6
- -- Require Prometheus
7
- local Prometheus = require("src.prometheus")
8
-
9
- -- Enable Debugging
10
- -- logger.logLevel = logger.LogLevel.Debug;
11
-
12
- -- Config Variables - Later passed as Parameters
13
- local noColors = false; -- Wether Colors in the Console output should be enabled
14
- local isWindows = true; -- Wether the Test are Performed on a Windows or Linux System
15
- local ciMode = false; -- Wether the Test error are ignored or not
16
-
17
- for _, currArg in pairs(arg) do
18
- if currArg == "--Linux" then
19
- isWindows = false
20
- end
21
- if currArg == "--CI" then
22
- ciMode = true
23
- end
24
- end
25
-
26
- -- Enable/Disable Console Colors - this may be needed because cmd.exe and powershell.exe do not support ANSI Color Escape Sequences. The Windows Terminal Application is needed
27
- Prometheus.colors.enabled = not noColors;
28
-
29
- -- Apply Obfuscation Pipeline
30
- local pipeline = Prometheus.Pipeline:new({
31
- Seed = 0; -- For Using Time as Seed
32
- VarNamePrefix = ""; -- No Custom Prefix
33
- });
34
-
35
- -- "Mangled" for names like this : a, b, c, d, ...
36
- -- "MangledShuffled" is the same except the chars come in a different order - Recomended
37
- -- "Il" for weird names like this : IlIIl1llI11l1 - Recomended to make less readable
38
- -- "Number" for names like this : _1, _2, _3, ... - Not recomended
39
- pipeline:setNameGenerator("MangledShuffled");
40
-
41
- print("Performing Prometheus Tests ...")
42
- local function scandir(directory)
43
- local i, t, popen = 0, {}, io.popen
44
- local pfile = popen(isWindows and 'dir "'..directory..'" /b' or 'ls -a "'..directory..'"')
45
- for filename in pfile:lines() do
46
- if string.sub(filename, -4) == ".lua" then
47
- i = i + 1
48
- t[i] = filename
49
- end
50
- end
51
- pfile:close()
52
- return t
53
- end
54
-
55
- local function shallowcopy(orig)
56
- local orig_type = type(orig)
57
- local copy
58
- if orig_type == 'table' then
59
- copy = {}
60
- for orig_key, orig_value in pairs(orig) do
61
- copy[orig_key] = orig_value
62
- end
63
- else -- number, string, boolean, etc
64
- copy = orig
65
- end
66
- return copy
67
- end
68
-
69
- local function validate(a, b)
70
- local outa = "";
71
- local outb = "";
72
-
73
- local enva = shallowcopy(getfenv(a));
74
- local envb = shallowcopy(getfenv(a));
75
-
76
- enva.print = function(...)
77
- for i, v in ipairs({...}) do
78
- outa = outa .. tostring(v);
79
- end
80
- end
81
-
82
- envb.print = function(...)
83
- for i, v in ipairs({...}) do
84
- outb = outb .. tostring(v);
85
- end
86
- end
87
-
88
- setfenv(a, enva);
89
- setfenv(b, envb);
90
-
91
- if(not pcall(a)) then error("Expected Reference Program not to Fail!") end
92
- if(not pcall(b)) then return false, outa, nil end
93
-
94
- return outa == outb, outa, outb
95
- end
96
-
97
-
98
- local presets = Prometheus.Presets;
99
- local testdir = "./tests/"
100
- local failed = {};
101
- Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error;
102
- local fc = 0;
103
- for i, filename in ipairs(scandir(testdir)) do
104
- local path = testdir .. filename;
105
- local file = io.open(path,"r");
106
-
107
- local code = file:read("*a");
108
- print(Prometheus.colors("[CURRENT] ", "magenta") .. filename);
109
- for name, preset in pairs(presets) do
110
- for i = #preset.Steps, 1, -1 do
111
- if preset.Steps[i].Name == "AntiTamper" then
112
- table.remove(preset.Steps, i);
113
- end
114
- end
115
- pipeline = Prometheus.Pipeline:fromConfig(preset);
116
- local obfuscated = pipeline:apply(code);
117
-
118
- local funca = loadstring(code);
119
- local funcb = loadstring(obfuscated);
120
-
121
- if funcb == nil then
122
- print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. "): " .. name .. ", Invalid Lua!");
123
- print("[SOURCE]", obfuscated);
124
- fc = fc + 1;
125
- else
126
- local validated, outa, outb = validate(funca, funcb);
127
-
128
- if not validated then
129
- print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. "): " .. name);
130
- print("[OUTA] ", outa);
131
- print("[OUTB] ", outb);
132
- print("[SOURCE]", obfuscated);
133
- fc = fc + 1;
134
- end
135
- end
136
- end
137
- file:close();
138
- end
139
-
140
- if fc < 1 then
141
- print(Prometheus.colors("[PASSED] ", "green") .. "All tests passed!");
142
- return 0;
143
- else
144
- print(Prometheus.colors("[FAILED] ", "red") .. "Some tests failed!");
145
- if ciMode then
146
- error("Test Failed!")
147
- end
148
- return -1;
149
- end
package/src/index.ts DELETED
@@ -1,100 +0,0 @@
1
- import { LuaFactory } from 'wasmoon'
2
- import fs from 'fs'
3
- import path from 'path'
4
- import { fileURLToPath } from 'url'
5
-
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
- const prometheusPath = path.join(__dirname, '../dist/prometheus')
8
-
9
- let factory: LuaFactory | null = null
10
- function getFactory(): LuaFactory {
11
- if (!factory) factory = new LuaFactory()
12
- return factory
13
- }
14
-
15
- let mountPromise: Promise<void> | null = null
16
-
17
- async function mountDirectory(dir: string, prefix: string = ''): Promise<void> {
18
- const entries = fs.readdirSync(dir, { withFileTypes: true })
19
- for (const entry of entries) {
20
- const fullPath = path.join(dir, entry.name)
21
- const luaPath = prefix ? `${prefix}/${entry.name}` : entry.name
22
- if (entry.isDirectory()) {
23
- await mountDirectory(fullPath, luaPath)
24
- } else if (entry.name.endsWith('.lua')) {
25
- await getFactory().mountFile(luaPath, fs.readFileSync(fullPath))
26
- }
27
- }
28
- }
29
-
30
- function ensureMounted(): Promise<void> {
31
- if (!mountPromise) {
32
- mountPromise = mountDirectory(prometheusPath).catch(err => {
33
- mountPromise = null
34
- throw err
35
- })
36
- }
37
- return mountPromise
38
- }
39
-
40
- type PrometheusPreset = 'Minify' | 'Weak' | 'Medium' | 'Strong'
41
-
42
- interface PrometheusConfig {
43
- LuaVersion?: 'Lua51' | 'LuaU'
44
- VarNamePrefix?: string
45
- NameGenerator?: 'Mangled' | 'MangledShuffled' | 'Il' | 'Number'
46
- PrettyPrint?: boolean
47
- Seed?: number
48
- Steps: Array<{ Name: string; [key: string]: unknown }>
49
- }
50
-
51
- export async function obfuscate(
52
- text: string,
53
- config: PrometheusPreset | PrometheusConfig = 'Strong',
54
- luaVersion?: 'Lua51' | 'LuaU'
55
- ): Promise<string> {
56
- await ensureMounted()
57
-
58
- const lua = await getFactory().createEngine()
59
- try {
60
- await lua.doString(`arg = {}`)
61
- lua.global.set('__input_code', text)
62
-
63
- let configExpr: string
64
- if (typeof config === 'string') {
65
- lua.global.set('__preset_name', config)
66
- configExpr = 'Prometheus.Presets[__preset_name]'
67
- } else {
68
- lua.global.set('__custom_config', config)
69
- configExpr = '__custom_config'
70
- }
71
-
72
- if (luaVersion !== undefined) {
73
- await lua.global.set('__lua_version', luaVersion)
74
- }
75
-
76
- const obfuscated = await lua.doString(`
77
- local Prometheus = require("src.prometheus")
78
- Prometheus.Logger.logLevel = Prometheus.Logger.LogLevel.Error
79
-
80
- local cfg = ${configExpr}
81
- if cfg == nil then
82
- error("Invalid preset or config")
83
- end
84
-
85
- if __lua_version ~= nil then
86
- cfg.LuaVersion = __lua_version
87
- end
88
-
89
- local pipeline = Prometheus.Pipeline:fromConfig(cfg)
90
- local result = pipeline:apply(__input_code)
91
- return result
92
- `)
93
- if (typeof obfuscated !== 'string') {
94
- throw new Error('Prometheus returned invalid result')
95
- }
96
- return obfuscated
97
- } finally {
98
- lua.global.close()
99
- }
100
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "declaration": true,
10
- "declarationDir": "./dist",
11
- "types": ["node"]
12
- }
13
- }