Experimental Lua 5.1 dump decompiler
Go to file
2022-08-11 16:19:21 -05:00
.gitignore Inital commit 2022-08-11 15:38:31 -05:00
LICENSE.md Added LICENSE 2022-08-11 15:55:49 -05:00
lparser.py Inital commit 2022-08-11 15:38:31 -05:00
lundump.py lundump.py: Instruction.__readRK() should be a static method 2022-08-11 16:19:21 -05:00
main.py Inital commit 2022-08-11 15:38:31 -05:00
README.md README: clarification 2022-08-11 16:00:41 -05:00

LuaDecompy

An experimental Lua 5.1 dump decompiler (typically dumped using luac -o <out.luac> <script.lua>).

Example usage

> cat example.lua && luac5.1 -o example.luac example.lua
pp = "pri" .. "nt"

if 2 + 2 == 4 then
    _G[pp]("Hello world")
end

> python main.py example.luac
example.luac

==== [[example.lua's constants]] ====

0: [STRING] pp
1: [STRING] pri
2: [STRING] nt
3: [NUMBER] 4.0
4: [STRING] _G
5: [STRING] Hello world

==== [[example.lua's dissassembly]] ====

[  0]      LOADK : R[0] K[1]
[  1]      LOADK : R[1] K[2]
[  2]     CONCAT : R[0] R[0] R[1]
[  3]  SETGLOBAL : R[0] R[0]
[  4]         EQ : R[0] K[3] K[3]
[  5]        JMP : R[0] R[5]
[  6]  GETGLOBAL : R[0] K[4]
[  7]  GETGLOBAL : R[1] K[0]
[  8]   GETTABLE : R[0] R[0] R[1]
[  9]      LOADK : R[1] K[5]
[ 10]       CALL : R[0] R[2] R[1]
[ 11]     RETURN : R[0] R[1] R[0]

==== [[example.lua's decompiled source]] ====


pp = "pri" .. "nt"
if 4.0 == 4.0 then 
    _G[pp]("Hello world")
end