Sunday, March 20, 2011

Making an executable difficult to hack

Apparently it's relatively trivial to take any exe file, use disassembler and a binary editor, and modify it.  This is how cracked versions of code get published via torrent websites.

So either the exe has to be tiny, and the user always has to download it from a server to run it - but I think even that can be cracked relatively easily.  If you use an exe checksum, then the code that forms a response that uses the checksum could be modded to respond with the correct checksum - but at least that executable would have to cracked for every new version, and if the server is capable of generating a new executable every day - then it's too much trouble to have it cracked.  Creating a script that modifies the exe checksum every day seems like it would be easy to do.  But it also raises the server bandwidth.

Another approach is to have self-modifying code that consists of assembly language embedded in a table and written to an area of memory to be executed.  Fine so they modify the table.  Now if it resides in 10,000 different tables (maybe use a perl/etc script to generate the tables) to obfuscate the assembly code, it requires much more work to crack.  This begins to get into the realm of "if you code this - you're crazy" and "if you crack this - you've really earned some sort of easter egg that asks you and anyone running the cracked version to at least donate to charity".

I might wind up with the common model - all code is crackable, but most of the population is honest, and half the people running cracked code only want to know precisely what it is they would be paying for if they bought the product.  And it probably helps ALOT to maintain an attitude of humility.  Am I going to go broke if some people hack my code?  What the whole problem means at the most fundamental level - work for me, and the cracker - work that could have been used more productively, and increased burden on honest users, is something to continually keep in mind.

If you have ideas, or find interesting threads on the subject - maybe something to look at.