Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Can a decompiler turn lua bytecode back into lua script?


Asked by Henley Phillips on Dec 07, 2021 Lua



Decompilers turn Lua bytecode back into Lua script! Unfortunately, most of the data went lost during the compiling process, meaning that decompilers won't be able to give you the original input.
Likewise,
Decompilers do exactly the opposite of what compilers do, Decompilers turn Lua bytecode back into Lua script! Unfortunately, most of the data went lost during the compiling process, meaning that decompilers won't be able to give you the original input.
One may also ask, It looks like LuaDec itself was last updated for Lua 5.0.2. A new version targeting Lua 5.1.x bytecode has been released as LuaDec51. The wiki is always a good place to start looking for resources as mentioned by f3lix.
Also Know,
Lua has heuristics to detect that a "string" it is given is a Lua source string or byte code. So yes, you can load byte code with luaL_loadfilejust like before. The difference is that you can't use luaL_loadstringwith byte code.
Furthermore,
Do note that it is relatively easy to add obfuscation or even encryption to the bytecode loader. Neither would require edits to the Lua core. If the system you are analyzing has taken any of those measures, you might have more work to do.