Parses Lua 5.1 bytecode
Go to file
CPunch 005567fee1 Added loadBlock for abstraction purposes
This was for a personal project where the bytecode was XOR'd with a key. Each call
to lundump.c:LoadBlock() xor'd the data against a static key. This lets me easily
reimplement that behavior.
2021-04-08 23:16:14 -05:00
README.md better examples 2019-08-15 12:03:53 -05:00
luac.py Added loadBlock for abstraction purposes 2021-04-08 23:16:14 -05:00

README.md

LuaPytecode

Parses Lua 5.1 bytecode

Example

import luac

lc = luac.LuaCompiler()
chunk = lc.compileC("test.lua")

print("\n===== [[Disassembly]] =====\n")

lc.print_dissassembly()

or just parse lua bytecode

import luac

bytecode = "27\\76\\117\\97\\81\\0\\1\\4\\8\\4\\8\\0\\21\\0\\0\\0\\0\\0\\0\\0\\112\\114\\105\\110\\116\\40\\39\\104\\101\\108\\108\\111\\32\\119\\111\\114\\108\\100\\39\\41\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\2\\2\\4\\0\\0\\0\\5\\0\\0\\0\\65\\64\\0\\0\\28\\64\\0\\1\\30\\0\\128\\0\\2\\0\\0\\0\\4\\6\\0\\0\\0\\0\\0\\0\\0\\112\\114\\105\\110\\116\\0\\4\\12\\0\\0\\0\\0\\0\\0\\0\\104\\101\\108\\108\\111\\32\\119\\111\\114\\108\\100\\0\\0\\0\\0\\0\\4\\0\\0\\0\\1\\0\\0\\0\\1\\0\\0\\0\\1\\0\\0\\0\\1\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0".split('\\')
bytecode = list(map(int, bytecode))
lc = luac.LuaCompiler()
chunk = lc.decode_bytecode(bytecode)

lc.print_dissassembly()