LuaDecompy/README.md

49 lines
987 B
Markdown
Raw Normal View History

2022-08-11 20:54:19 +00:00
# LuaDecompy
2022-08-11 21:00:41 +00:00
An experimental Lua 5.1 dump decompiler (typically dumped using `luac -o <out.luac> <script.lua>`).
2022-08-11 20:54:19 +00:00
## Example usage
```sh
2022-08-11 21:00:41 +00:00
> 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
2022-08-11 20:54:19 +00:00
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]
2022-08-11 21:00:41 +00:00
[ 5] JMP : R[0] R[5]
2022-08-11 20:54:19 +00:00
[ 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]
2022-08-11 21:00:41 +00:00
[ 10] CALL : R[0] R[2] R[1]
[ 11] RETURN : R[0] R[1] R[0]
2022-08-11 20:54:19 +00:00
==== [[example.lua's decompiled source]] ====
pp = "pri" .. "nt"
if 4.0 == 4.0 then
2022-08-11 21:00:41 +00:00
_G[pp]("Hello world")
2022-08-11 20:54:19 +00:00
end
```