Decompile Luac Instant

The linear list of instructions is divided into basic blocks (straight-line code ending in a branch). A CFG maps how blocks connect via jumps, calls, and returns.

| Tool | Supported Lua Versions | Strengths | Weaknesses | |------|------------------------|-----------|-------------| | unluac (Java) | 5.1 – 5.4 | Most accurate, actively maintained, handles upvalues, varargs. | No GUI, requires JVM. | | LuaDec (C++/Lua) | 5.1 – 5.3 | Fast, integrates with Lua environment. | Less accurate for complex closures. | | LuaDec51 (Python) | 5.1 only | Simple, good for legacy. | Outdated, no 5.2+ support. | | Frida-lua-decompiler | 5.2+ | In-memory runtime decompilation. | Complex, requires Frida hooks. | | LuaJIT-decompiler | LuaJIT bytecode | Specialized for LuaJIT (used in games like GMod). | Does not support standard Lua bytecode. |

Example using unluac:

# Decompile a Lua 5.3 bytecode file
java -jar unluac.jar my_script.luac > recovered.lua

Scenario: A game modder named Alex lost the source of a Lua AI script for a strategy game. Only ai.luac remains (Lua 5.2 with debug stripped).

Steps:


A modern LUAC decompiler follows three stages:

Let’s decompile a sample script.luac (Lua 5.1) using unluac. decompile luac

Several tools are available for decompiling Lua bytecode:

Decompiling Lua bytecode can be challenging due to: The linear list of instructions is divided into