Decompile Luac

Use a hex editor or command-line tool:

# Check magic number and version
hexdump -C file.luac | head -n 1

Example output (Lua 5.1): 1b 4c 75 61 51 00 → Magic \x1bLua + version 0x51 (Lua 5.1)

Version mapping:

Use a dedicated tool: luac-version or file command (modern Unix may detect). decompile luac


| Problem | Likely cause | Fix | |---------|--------------|-----| | unrecognized version | Wrong Lua version | Detect and use correct tool | | no debug info | Stripped locals/names | Decompiled code has generic names (e.g., _1, _2) | | compressed luac | Stripped or pre-compressed | Try lua-lz or unluac --rawstring | | invalid instruction | Corrupted file or encrypted | Check file header, XOR/obfuscation? | | unluac fails on 5.4 | Newer opcodes | Use --rawstring or wait for updates |


This is the most important section. Decompilation exists in a legal grey area.

| Method | Output | Use case | |--------|--------|----------| | Decompilation | High-level Lua source | Recover logic, modify behavior | | Disassembly (luac -l) | Opcode listing (GETGLOBAL, CALL, etc.) | Understanding bytecode, debugging decompiler bugs | | Re-execution (sandbox) | Runtime behavior | Observe network calls, file I/O without decompiling | Use a hex editor or command-line tool: #

Hybrid approach: Disassemble first to locate suspicious sections, then decompile only those.


If decompilers fail (common with obfuscated or custom Lua runtimes), you may need to inspect bytecode directly:

luac -l -p myfile.luac > bytecode.txt

This prints all instructions. You can then: Example output (Lua 5

| Tool | Lua versions | Best for | |---------------------|-------------------|----------------------------------------| | unluac | 5.0 – 5.4 | Most reliable, Java-based | | LuaDec | 5.1, 5.2, 5.3 | CLI tool, good for batch | | LuaJIT-decompiler| LuaJIT 2.0/2.1 | IR-level reconstruction | | LuaRev | 5.1 – 5.4 | Web-based (experimental) |

For general use, I recommend unluac.

Check the license and ownership of the software before decompiling. Decompiling is generally considered a "gray area" legally. It is acceptable for personal use, data recovery, or interoperability in many jurisdictions, but redistributing decompiled code or using it to cheat in online games is often illegal or violates Terms of Service.