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?
问题:
回答1:
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.
回答2:
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.
回答3:
Multi Theft Auto now supports encryption of scripts. You can compile them online at http://luac.mtasa.com/ or download standalone compiler.
回答4:
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.