LuaJIT Raw-Bytecode Decompiler (LJD)
===
The original name was _ljwthgnd_, as in _LuaJIT 'What The Hell is Going On'
Decompiler_; named under the LuaJIT C sources variable-naming convention.
__WARNING!__ This code is not finished or tested! There is not even
the slightest warranty that the resulting code is even close to the original.
Use the decompiled code at your own risk.
__SECOND WARNING!__ This is all a huge prototype. The "release" version
should be written in Lua itself, because it's cool to
decompile the decompiler — a great test too!
Requirements:
---
Python __3.7+__ from Python.org
How To Use:
---
Typical usage (no version configuration list, all files in a directory):
```
python3 ./main.py --recursive ./<input directory> --dir_out ./<output directory> --catch_asserts
```
Note About Bytecode Versions:
---
Different versions of LuaJIT produce different versions of the bytecode. Currently revision
`1` (corresponding to LuaJIT 2.0.x) and revision `2` (corresponding to LuaJIT 2.1.x) are supported.
These are the only two versions officially used in LuaJIT. From time to time I've seen files
with a revision code of `3` pop up. This appears to be from RaptorJIT, but more investigation
in that area is needed.
In previous versions of the decompiler, you had to manually specify the version of the files
you are decompiling. This is now done automatically, although there may be bugs when using
the `-r` option with files coming from multiple versions of LuaJIT.
Arguments:
---
"-f", "--file" : Single file input target. Not to be used with "-r"
"-o", "--output" : Single file output destination. Not to be used with "-r"
"-r", "--recursive" : Directory in which to recurse and process all files. Not to be used with "-f"
"-d", "--dir_out" : Directory to output processed files during recursion. Not to be used with "-f"
"-c", "--catch_asserts" : Prevent most integrity asserts from canceling decompilation
"-l", "--enable_logging" : Output a log of exceptions and information during decompilation
IRC:
---
```#ljd at freenode```
TODO:
---
There is a lot of work to do. In order of priority:
0. Logical subexpressions in while statements:
This is done! As far as I'm aware, this is the only available LuaJIT decompiler
that can decompile stuff like the following:
```lua
while x < (xi and 2 or 3) do
print ("Hello crazy world!")
end
```
If you're having many failures while decompiling files via other forks of LJD, this
is quite likely going to solve 90% of your problems.
1. AST Mutations:
1. Use the line information (or common sense if there is no line
information) to squash similar expressions into single expressions.
2. Formatting improvements (partially-implemented):
1. Use the line information (or common sense) to preserve empty lines
and break long statements like in the original code.
This is mostly done, but only in the "common sense" part.
3. Features not supported:
1. GOTO statement (from Lua 5.2). All the required functionality is
now in place, but that's a rather low-priority task right now.
2. Local sub-blocks:
```lua
do
...
end
```
These subblocks are not directly reflected in the bytecode.
The only way to guess their presence is to watch local variable scopes.
Simple enough in case of non-stripped bytecode, but a bit
harder otherwise.
Licence:
---
The original LJD (and Aussiemon's modifications) are distributed under the MIT licence, and a
copy of this is included as `LICENSE-upstream`. However, all changes made by myself
(Campbell "ZNixian" Suter) are licenced under the GNU General Public Licence, version 3 or any later
version of your choice (a copy of which is available in the `LICENSE` file supplied with the source code).
I've chosen this license due to certain dynamics of the videogame modding scene for which these changes
were made. If you have a use for this outside of games, and need a less restrictive licence, please let me know
and I'll most likely be fine to relicence the project either to MIT or (preferrably) LGPL.
Also note that while this licence did not appear as my first modification to this project, I did not
distribute the source before making this change, and never offered those changes under the original licence
(even if the licence file supplied in those revisions was the original one).
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本工具是用python编写,需要python3以上版本环境支持 下载后解压出来后可以直接运行下面命令: python ./main.py C:/DeskTop/test.luac.32 即可得到你想要反编译的lua源码,最终输出到终端stdout中,如你想要输出到一个文件中,你可以通过重定向管道输出到对应的文件中 python ./main.py C:/DeskTop/test.luac.32 > test.lua 本工具亲测可以解析通过luajit编译的lua文件,并反编译生成原始lua文件。
资源推荐
资源详情
资源评论
收起资源包目录
luajit反编译获取lua源文件工具 (103个子文件)
.gitignore 370B
ifs.lua 12KB
test_ifs_2.1b3_5.1.lua 12KB
test_primitive_2.1b3_5.1.lua 11KB
primitive.lua 9KB
test_expression_2.1b3_5.1.lua 9KB
operations.lua 8KB
test_loop_2.1b3_5.1.lua 8KB
test_operations_2.1b3_5.1.lua 6KB
loop.lua 6KB
expression.lua 6KB
breaks.lua 3KB
test_breaks_2.1b3_5.1.lua 2KB
illegal_type_eliminations.lua 461B
massive_nils.lua 452B
massive_std.lua 316B
slot_block_gathering.lua 239B
slot_local_declarations.lua 212B
simple.lua 71B
loops.lua 33B
README.md 4KB
unwarper.py 82KB
builder.py 46KB
slotworks.py 34KB
writer.py 32KB
instructions.py 20KB
main.py 20KB
nodes.py 19KB
instructions.py 11KB
validator.py 11KB
mutator.py 10KB
locals.py 9KB
luajit_opcode.py 6KB
luajit_opcode.py 5KB
traverse.py 4KB
printast.py 4KB
constants.py 4KB
helpers.py 4KB
prototype.py 4KB
binstream.py 4KB
testunit.py 3KB
debuginfo.py 2KB
code.py 2KB
header.py 2KB
parser.py 2KB
prototype.py 2KB
indentedstream.py 2KB
test.py 2KB
debuginfo.py 1KB
constants.py 1KB
writer.py 1KB
testlist.py 730B
prototype.py 711B
utils.py 629B
constants.py 457B
log.py 383B
config.py 198B
helpers.py 180B
__init__.py 164B
__init__.py 74B
__init__.py 74B
__init__.py 74B
__init__.py 74B
__init__.py 74B
__init__.py 74B
__init__.py 0B
unwarper.cpython-38.opt-1.pyc 34KB
builder.cpython-38.opt-1.pyc 23KB
nodes.cpython-38.opt-1.pyc 22KB
writer.cpython-38.opt-1.pyc 21KB
slotworks.cpython-38.opt-1.pyc 19KB
instructions.cpython-38.opt-1.pyc 13KB
traverse.cpython-38.opt-1.pyc 10KB
locals.cpython-38.opt-1.pyc 9KB
validator.cpython-38.opt-1.pyc 8KB
mutator.cpython-38.opt-1.pyc 7KB
instructions.cpython-38.opt-1.pyc 6KB
printast.cpython-38.opt-1.pyc 4KB
binstream.cpython-38.opt-1.pyc 4KB
helpers.cpython-38.opt-1.pyc 3KB
constants.cpython-38.opt-1.pyc 3KB
prototype.cpython-38.opt-1.pyc 3KB
luajit_opcode.cpython-38.opt-1.pyc 2KB
header.cpython-38.opt-1.pyc 2KB
indentedstream.cpython-38.opt-1.pyc 2KB
debuginfo.cpython-38.opt-1.pyc 2KB
parser.cpython-38.opt-1.pyc 2KB
prototype.cpython-38.opt-1.pyc 2KB
code.cpython-38.opt-1.pyc 2KB
debuginfo.cpython-38.opt-1.pyc 2KB
writer.cpython-38.opt-1.pyc 1KB
constants.cpython-38.opt-1.pyc 1KB
prototype.cpython-38.opt-1.pyc 1KB
constants.cpython-38.opt-1.pyc 824B
log.cpython-38.opt-1.pyc 616B
helpers.cpython-38.opt-1.pyc 452B
__init__.cpython-38.opt-1.pyc 175B
__init__.cpython-38.opt-1.pyc 167B
__init__.cpython-38.opt-1.pyc 166B
__init__.cpython-38.opt-1.pyc 165B
共 103 条
- 1
- 2
资源评论
- weixin_461526802023-10-01资源是宝藏资源,实用也是真的实用,感谢大佬分享~
- weixin_435984362024-03-22感谢资源主的分享,很值得参考学习,资源价值较高,支持!
- kilopower2024-02-01资源很赞,希望多一些这类资源。
- itLin_share2023-11-13资源很好用,有较大的参考价值,资源不错,支持一下。
前网易架构师-高司机
- 粉丝: 8053
- 资源: 200
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功