如何使 Lua 脚本不可反编译?
我有许多编译的 Lua 脚本(用于多人模式 Multi Theft Auto),原因有很多,包括防盗。实际上,这只是一种防盗措施,因为 Luadec (http://luadec51.luaforge.net/) 可以轻松反编译脚本。有人对如何使我的脚本不可反编译有任何建议吗?
I have many Lua scripts (for the multiplayer mod Multi Theft Auto) that are compiled, for many reasons, including theft prevention. In reality, this is only a theft deterrent, as Luadec (http://luadec51.luaforge.net/) can easily de-compile the scripts. Does anyone have have any tips on how I can make my scripts un-decompilable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
加密;这确实是唯一可行的方法。当然,由于您的程序必须解密它们,因此它们可以直接从内存中获取解密的数据。
所以不,你无能为力。 任何方法在某种程度上都“只是一种防盗手段”。即使编译为实际的程序集也只是一种威慑,因为它可以被反编译成与原始源代码不完全不同的东西。
问题很简单,就是你想给用户带来多少麻烦。加密可能会给您带来最大的收益。这将迫使他们必须遍历可执行文件来找出如何将数据从内存中提取出来。大多数临时用户都不想这样做。
Encryption; that's really the only way it's going to work. Of course, since your program would have to decrypt them, they could just snatch the decrypted data right out of memory.
So no, there's nothing you can do. Any method is going to be "only a theft deterrent" to some degree. Even compiling to actual assembly is just a deterrent, as this can be decompiled into something not entirely unlike the original source code.
The question is simply how much trouble you want to give the user. Encryption probably gives you the most bang for your buck. This will force them to have to walk through the executable to figure out how to yank the data out of memory. Most casual users won't want to do that.
如果你想变得非常认真,你可以改变 lua 虚拟机生成和使用的操作码,那么它就不能被现成的软件反编译。虽然这可能会给你带来更多的问题——你必须支持你自己的 lua 版本,而且你可能无法使用像 luajit 这样的东西。
为了反编译,他们必须找出你想出并翻译的操作码的映射。这可能不会太难,但我可能不会。
[更新]
查看源代码可能相当简单,有两个文件 lopcode.c 和 lopcode.h 也许如果您只需更改其中操作码的顺序即可完成。如果您最终这样做并且它有效或无效,请发帖。
If you wanted to get really serious you could change the opcodes generated and used by the lua vm, then it couldn't be decompiled by off the shelf software. Though this might cause you more problems than it's worth - you'd have to support your own version of lua, and you probably couldn't use things like luajit.
To decompile they'd have to figure out the mapping of opcodes you'd come up with and translate. It probably wouldn't be too hard to do, but I probably wouldn't.
[Update]
Looking at the source it may be fairly easy, there are two files lopcode.c and lopcode.h maybe if you just change the order of the opcodes in these you'll be done. Please post if you end up doing this and it works or not.
Multi Theft Auto 现在支持脚本加密。您可以在 http://luac.mtasa.com/ 在线编译它们或下载独立编译器。
Multi Theft Auto now supports encryption of scripts. You can compile them online at http://luac.mtasa.com/ or download standalone compiler.
我认为这是不可能的。这种野兽的本质(在非常小的虚拟机上运行的非常小的语言)基本上禁止它。
您所能期望的最好的结果就是反编译的代码对于人类来说尽可能难以理解。
I don't think it's possible. The very nature of the beast (a very minimal language working on a very small VM) basically forbids it.
The best you can hope for is for the decompiled code to be as difficult to understand as possible, for a human.