Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Dockerfile

test-results
__pycache__

# Local reference implementation
.reference-obfuscator/
29 changes: 26 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,33 @@ web/playwright-report
.vite

# Ignore Local Test Files
test.lua
test.obfuscated.lua
config.lua
/test.lua
/test.obfuscated.lua
/config.lua

# Lua test logs and reproduction artifacts
/test-results/
__pycache__/

# Local reference implementation, not part of Prometheus
/.reference-obfuscator/

# Local runtimes, uploaded archives, and generated debugging output
/.tools/
/scratch/
/Prometheus*.zip
/src.zip
/lune
/lune-*.zip
/luau
/luau-compile
/luau-*.zip
/LuaJIT-*/
/luajit-source.tar.gz
*.obfuscated.lua
*.obfuscated.luau
*.out.luau
*.log
*.tmp
.DS_Store
Thumbs.db
18 changes: 17 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Thanks for contributing to Prometheus.

## Running Tests

Tests run inside a Docker container with lua5.1 and Luau:
The obfuscator source must remain valid Lua 5.1 and run in both Lua 5.1 and
LuaJIT. `LuaVersion` selects the input/output dialect; Luau is a target runtime,
not a dependency of the obfuscator host. Tests run inside a Docker container
with Lua 5.1, LuaJIT, and the official Luau runtime:

```bash
./scripts/run-tests.sh # Run all tests (default: 10 iterations)
Expand All @@ -22,6 +25,19 @@ Tests run inside a Docker container with lua5.1 and Luau:
./scripts/run-tests.sh -v # Verbose output
```

The Docker build runs Luau syntax and execution checks with both Lua 5.1 and
LuaJIT as the obfuscator host. The same checks can be run directly:

```bash
LUA51=luajit python3 tests/harness/luau-syntax.py
LUA51=luajit python3 tests/harness/luau.py
LUA51=luajit python3 tests/harness/luau-recent.py
luajit tests/harness/luau-strings.lua
```

`LUAU` and `LUAU_COMPILE` select the target runtime and compiler. The recent
syntax checks require a Luau version with value exports and integer literals.

### Test File Metadata

Test files can include metadata comments at the top of the file:
Expand Down
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
lua5.1 \
luajit \
python3 \
patch \
git \
Expand All @@ -14,8 +15,8 @@ RUN --mount=type=secret,id=ca-bundle \
if [ -f /run/secrets/ca-bundle ]; then export CURL_CA_BUNDLE=/run/secrets/ca-bundle; fi; \
curl -fsSLo /tmp/luau-ubuntu.zip \
https://github.com/luau-lang/luau/releases/latest/download/luau-ubuntu.zip \
&& unzip -j /tmp/luau-ubuntu.zip luau -d /usr/local/bin \
&& chmod +x /usr/local/bin/luau \
&& unzip -j /tmp/luau-ubuntu.zip luau luau-compile -d /usr/local/bin \
&& chmod +x /usr/local/bin/luau /usr/local/bin/luau-compile \
&& rm /tmp/luau-ubuntu.zip

# Verify installations
Expand All @@ -25,6 +26,16 @@ WORKDIR /app
COPY . /app

RUN lua5.1 tests/harness/metadata.lua \
&& timeout 60s lua5.1 tests/harness/luau-parser.lua \
&& python3 tests/harness/luau-syntax.py \
&& python3 tests/harness/luau.py \
&& python3 tests/harness/luau-recent.py \
&& lua5.1 tests/harness/luau-strings.lua \
&& LUA51=luajit python3 tests/harness/luau-syntax.py \
&& LUA51=luajit python3 tests/harness/luau.py \
&& LUA51=luajit python3 tests/harness/luau-recent.py \
&& luajit tests/harness/luau-strings.lua \
&& python3 tests/harness/cli.py \
&& timeout 60s lua5.1 tests/harness/numbers-to-expressions.lua \
&& timeout 60s lua5.1 tests/harness/cff-arity.lua \
&& timeout 60s lua5.1 tests/harness/cff-native.lua \
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ The project was inspired by the excellent [javascript-obfuscator](https://github
Currently, Prometheus supports:

- **Lua 5.1**
- **LuaU** *(basic support is available, but still not fully finished)*
- **Luau** *(partial support, including type erasure, interpolation, `const`, and generalized iteration; see [limitations](doc/reference/limitations.md#luau))*

To process Luau, pass `--luau` (or `--LuaU`) to the CLI or set `LuaVersion = "LuaU"` in
configuration. Type annotations, assertions, and type declarations are removed;
output still targets the Luau runtime. See [Luau limitations](doc/reference/limitations.md#luau).

Lua 5.1's legacy implicit `arg` table in vararg functions is unsupported.
Use `...` and `select('#', ...)` instead; see [Limitations](doc/reference/limitations.md).
Expand Down
7 changes: 5 additions & 2 deletions doc/guides/cli-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ prometheus-lua --preset Medium ./input.lua
If `--out` is not provided:

- `input.lua` -> `input.obfuscated.lua`
- `input.luau` -> `input.obfuscated.luau`
- `input` -> `input.obfuscated.lua`

## Common workflows
Expand All @@ -37,7 +38,7 @@ prometheus-lua --config ./prometheus.config.lua ./src/main.lua
Force Lua target:

```bash
prometheus-lua --preset Medium --LuaU ./src/main.lua
prometheus-lua --preset medium --luau ./src/main.luau
```

Enable pretty output:
Expand All @@ -48,6 +49,8 @@ prometheus-lua --preset Minify --pretty ./src/main.lua

## Notes

- Unknown `--...` options are ignored with a warning.
- Command, option, and preset names are case-insensitive; paths preserve their case.
- Options with values accept both `--preset medium` and `--preset=medium`.
- Unknown options and missing option values are errors.
- If no config/preset is passed, Prometheus falls back to `Minify`.
- `update` command uses the official installer script from GitHub.
15 changes: 10 additions & 5 deletions doc/reference/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
| `--preset` | `--p` | `<name>` | Use built-in preset by name |
| `--config` | `--c` | `<file>` | Load config Lua file |
| `--out` | `--o` | `<file>` | Output file path |
| `--Lua51` | - | none | Force Lua 5.1 conventions |
| `--LuaU` | - | none | Force LuaU conventions |
| `--lua51` | - | none | Force Lua 5.1 conventions |
| `--luau` | - | none | Force Luau conventions |
| `--pretty` | - | none | Pretty-print generated output |
| `--nocolors` | - | none | Disable ANSI colors |
| `--saveerrors` | - | none | Write parser/runtime errors to `<input>.error.txt` |

## Parsing behavior

- First non-option argument is treated as input file.
- A second non-option argument raises an error.
- Unknown options are ignored with a warning.
- Command names, option names, and built-in preset names are case-insensitive. Existing spellings
such as `--LuaU` and `--Lua51` continue to work.
- File paths and configuration values retain their original case.
- Options that take a value accept either `--option value` or `--option=value`.
- The first non-option argument is the input file; a second one is an error.
- Use `--` before an input filename beginning with `-`. For an option value
beginning with `-`, use `--option=value` or a path prefixed with `./`.
- Unknown options, missing values, and values supplied to flags are errors.
59 changes: 59 additions & 0 deletions doc/reference/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,65 @@ obfuscation:

Source code constructed or loaded at runtime is not automatically obfuscated.

## Luau

The obfuscator itself is written in Lua 5.1 and supports LuaJIT. `LuaVersion`
selects the input/output language; a Luau runtime is needed to execute Luau
output, not to run the obfuscator.

Use `--LuaU` or `LuaVersion = "LuaU"` for Luau input. Type declarations,
annotations, assertions (`::`), and type function declarations are removed;
Prometheus does not type-check them, evaluate `typeof` expressions in type
positions, or retain exported types for consumers. The type grammar is validated
before erasure, including type packs, generic parameter defaults, and union and
intersection grouping. Unknown type names remain syntactically valid; use Luau's
type checker to resolve names and verify type compatibility. Run the output on Luau.

Conditional expressions, including `elseif` branches, interpolated strings,
contextual [`const` declarations](https://rfcs.luau.org/const-keyword.html), and
generalized `for` iteration are supported. `const` bindings are checked for
reassignment and lowered to locals; tables
referenced by a `const` remain mutable. Interpolation uses Luau's `%*` string
formatting and therefore requires a Luau runtime for the transformed code.

Generalized iteration supports tables, `__iter`, callable objects, ordinary
iterator triples, and protected metatables in every preset. `Cff` and `Vmify`
retain native iterator initialization in a small function and compile the loop
body as a callback. This preserves the caller's coroutine, break/continue,
outer returns, iteration-local captures, and trailing nil return values without
reflecting on the object's metatable. Vararg/return transport uses the standard
`select` and `unpack` globals.

Floor division (`//` and `//=`) is supported in every preset and preserves
Luau's native `__idiv` metamethod. Contextual keywords such as `continue`,
`type`, `export`, and `const` remain valid identifiers outside their statement
contexts. Decimal, hexadecimal, and binary numerals support Luau's underscore
separators; malformed number tokens are rejected.

Luau accepts one optional semicolon after a statement, including a type
declaration. Leading or repeated empty semicolons are rejected. Varargs are
valid at chunk level and inside functions that declare `...`; an inner function
does not inherit its enclosing function's varargs. These checks also apply to
erased type syntax. Type function bodies must use syntax that the parser
supports even though those declarations are erased.

Explicit generic instantiation such as `identity<<number>>(value)` is validated
and erased. Function attributes `@native`, `@checked`, `@deprecated`, and their
`@[...]` forms are validated. Minify preserves function attributes. Virtualizing
a function changes its layout, so its original per-function compilation hints
do not directly describe the generated dispatcher. Header directives
`--!native` and `--!optimize 0/1/2` are preserved by every preset.

Recent Luau runtimes also support value exports (`export local`, `export const`,
and `export function`) and 64-bit integer literals such as `9007199254740993i`.
Exports are lowered to a module table with live bindings and a frozen module
return, including duplicate-export and top-level-return checks. Integer
literals retain their exact digits and bit patterns without converting them
to the obfuscator host's double-precision numbers. Their available operations
follow the selected Luau runtime; no arithmetic behavior is emulated by the
obfuscator. Lune 0.11.0 does not accept these newer input forms. Integer output
therefore requires a more recent Luau runtime.

## Replacing a running function's environment

Prometheus does not support replacing a function's environment while that
Expand Down
17 changes: 17 additions & 0 deletions prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
contexto: `src.zip` é o meu obfuscator, `prometheus.zip` é o prometheus que eu estou modificando para dar suporte a luau.
caso comente no codigo, comente em inglês. e adicione arquivos inuteis no .gitignore

- hybrid keywords
- no prometheus não temos a validação de se é uma "hybrid keyword" ou uma keyword normal. incluindo o "continue", e varias outras.
- floor division
- atualmente não possui suporte a floor division. o `src.zip` possui algumas coisas sobre.
- verificar vararg (não tenho certeza sobre esse problema)
- atualmente não existe nada que diga se a vararg está em um lugar valido
- caso se a vararg esteja dentro de uma função, mas a função não possui vararg, não é avisado (não da erro na ofuscação).
- semicolon
- a forma que o ";" é "pulado" em luau é completamente diferente de lua.
- em luau, é muito mais rigido sobre a declaração de Semicolon, e atualmente não possui essa verificação.
- numerais em luau (não tenho certeza sobre isso)
- o prometheus não possui suporte para numerais de luau

pequeno aviso: nem tudo em `src.zip` está correto, pois é uma versão mais antiga.
Loading