This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RunasSudo-AWOLindefinitely's profile picture

Securing your code through compilation

Started by RunasSudo-AWOLindefinitely, 31 December 2012 - 05:18 PM
RunasSudo-AWOLindefinitely #1
Posted 31 December 2012 - 06:18 PM
If you're like the guy who made iHomeOS, and you don't want people to steal your code "WITHOUT MY PERMISSION", then this (might) be for you1:
  1. Get a copy of the Lua binaries from http://www.lua.org/download.html
  2. If you're running Windows, I'd recommend these binaries.
  3. Extract the files somewhere convenient.
  4. Put your super-amazing-and-really-secret source code into the folder.
  5. Open up a command prompt in the directory with the exe files.
  6. On Windows, hold down shift and right click in any empty space in the folder and select "Open command window here"
  7. If your "luac__.exe" file is "luac52.exe" and your code is called "helloworld.lua", then run
    luac52.exe -o helloworld.bin helloworld.lua
  8. Magic! If you open up helloworld.bin on one of your computers, it runs fine, but if you open it up in notepad (or something), it's incomprehensible.
  9. Now noone2 can steal your code!
1Something else that might be for you is to reconsider going closed-source.
2Okay, it's not actually irreversible. If someone was determined, they could reverse the compilation and steal your code anyway, but at least it stops some people!
Lyqyd #2
Posted 31 December 2012 - 08:47 PM
Sooo, basically just string.dump(loadfile("filename"))?
AfterLifeLochie #3
Posted 31 December 2012 - 08:47 PM
I have on many occasions in IRC, and in this post, discussed why "compiling" Lua code and distributing compiled versions is not the most efficient - please take the points into consideration.
RunasSudo-AWOLindefinitely #4
Posted 31 December 2012 - 08:55 PM
Sooo, basically just string.dump(loadfile("filename"))?
I have on many occasions in IRC, and in this post, discussed why "compiling" Lua code and distributing compiled versions is not the most efficient - please take the points into consideration.
Well, as you said yourself:
to prevent the users who do not understand the Lua Runtime and it's byte-instructions from reversing said programs
I don't understand LUA's byte instructions, therefore it might not be as easy as Control-C, Control-V to steal someones code, but anyway.
Feel free to lock this thread if you don't think it's up to scratch.
6677 #5
Posted 01 January 2013 - 02:11 AM
well it isnt the most secure method granted but its a significant improvement over just chucking .lua files around.

Even C and C++ can be reverse engineered into at least an ASM source, working with that is rather difficult though. Decompiled lua bytecode happens to be pretty complete in comparison.
ScruffyRules #6
Posted 01 January 2013 - 03:05 AM
i'd just make everything a local
6677 #7
Posted 01 January 2013 - 03:21 AM
thats completely unrelated to what was being discussed
PixelToast #8
Posted 01 January 2013 - 04:05 AM
lol ihome
i have a copy of it
though it would be illegal to distribute it :P/>

obufuscation + compiling is the best way to go if you dont want people to see the code
but i hate things that arent open source :s
lieudusty #9
Posted 01 January 2013 - 07:55 AM
lol ihome
i have a copy of it
though it would be illegal to distribute it :P/>

obufuscation + compiling is the best way to go if you dont want people to see the code
but i hate things that arent open source :s
Can you be a pirate and torrent iHome? xD
dissy #10
Posted 01 January 2013 - 12:05 PM
obufuscation + compiling is the best way to go if you dont want people to see the code

I wouldn't say the best way. At most it's a distance second way.
All the "kracks" available for compiled software, released from the 70s up to this very day, should be proof enough of that.

The only way to not have your code out in the public, is to not distribute your code to the public.

but i hate things that arent open source :s

Agreed. And for anyone who is thinking of going that route, something to ponder over:
How far would you be in your projects if everyone on these forums and elsewhere else felt the same? These people openly and freely help with coding errors, provide code to accomplish something tricky, and in general got you to the point you are today…
Taking the stance of claiming all the code you created is somehow "yours", when most if not all of it was given to you freely in examples, tutorials, and by other people. These are the very people you are attempting to hold code back from, and not reciprocate in kind like they did for you.

Please keep this in mind and consider also sharing back to others what you have learned and made instead of locking it behind precompiled binaries.

Thank you
/soapbox