Decompile Luac
This monograph explains Lua bytecode (.luac), the principles and techniques for decompiling it back into readable Lua source, legal and ethical considerations, available tools, limitations, and best practices for reading, analyzing, and reconstructing Lua programs. It targets developers, reverse engineers, security researchers, and educators seeking a practical, structured guide.
If automatic decompilation fails, use luac -l file.luac to get a disassembly (human-readable opcodes) and reconstruct logic manually. It’s tedious but possible for short scripts.
I can provide specific command strings, tools, or custom de-obfuscation strategies tailored to your exact file. Share public link decompile luac
java -jar unluac.jar myfile.luac > output.lua
| Tool | Lua versions | Best for | |---------------------|-------------------|----------------------------------------| | | 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) | This monograph explains Lua bytecode (
To improve:
The decompiler's compatibility layer must adjust for each version's unique instruction set and data structures to generate valid Lua source code for that version. This is why using a version-agnostic tool like unluac is valuable; it abstracts away many of these low-level differences. It’s tedious but possible for short scripts
function add(a, b) return a + b end print(add(5, 3))
A classic choice for older versions of Lua (specifically 5.1). While it hasn't seen as many updates recently as unluac , it is still a staple for many reverse engineers working on legacy games.
xxd script.luac | head -n 1
: This is the core intelligence of the decompiler. It analyzes the CFG to recognize patterns that correspond to high-level programming constructs. For example, it identifies patterns for if-then-else chains, while and repeat loops, and for loops. It uses algorithms to rebuild variable relationships and match the flattened jump structure back into nested, structured code.