Re: Writing spaghetti code for obfuscation/encryption
- From: "randyhyde@xxxxxxxxxxxxx" <spamtrap@xxxxxxxxxx>
- Date: Wed, 31 Aug 2005 00:19:24 +0000 (UTC)
spamtrap@xxxxxxxxxx wrote:
> Hi all,
>
> I'm considering writing some convoluted and confusing code in order to
> hide the access/decryption of some important data in an app. I don't
> really want to be dependent on any particular OS at the moment.
>
> The problem is how to generate this code without becoming confused
> myself, and how to make sure it is orthogonal, or always produces the
> same result with the same input.
>
> I would like for it to be similar to the copy protection schemes of
> old, that make tracing difficult and unpredictable.
>
> Can anyone offer any suggestions on how this might be done, besides
> undocumented opcodes and simple encryption?
>
> Thanks!
Self-modifying code!
Seriously. If the code is constantly changing at run-time, it's a devil
to trace through it. At the very least, consider packing your code
using an LZW-type algorithm and unpacking each module before running
it. Not only will this make it hard to decipher, but it will save
space, too.
Of course, there is also the trick of burying instruction opcodes
inside other instructions. This one is especially difficult to
disassemble.
And, of course, be sure to bury lots of read-only data in the code
stream and access it via the return address pushed on the stack, e.g.,
call print
byte "Hello world", 13, 10, 0
This confuses the heck out of disassemblers and throws up a roadblock
to people who are reverse engineering your code.
Finally, consider writing an interpreter and switching in and out of
that interpreter during the execution of your code:
call interpreter
byte <<stream of bytecodes in the interpretive language>>
<more x86 instructions>
call interpreter
byte <<another stream of bytecodes in the interpretive language>>
<more x86 instructions>
etc.
If you've got a decent assembler, you can create an "assembly language"
for your interpreter using macros, so it's not hard to write
intepretive code this way. Of course, you *do* have to write the
interpreter. But simple ones (enough to obfuscate your machine code)
will only be a couple of kilobytes long.
Cheers,
Randy Hyde
.
- Follow-Ups:
- Re: Writing spaghetti code for obfuscation/encryption
- From: Jim Leonard
- Re: Writing spaghetti code for obfuscation/encryption
- From: f0dder
- Re: Writing spaghetti code for obfuscation/encryption
- References:
- Writing spaghetti code for obfuscation/encryption
- From: spamtrap
- Writing spaghetti code for obfuscation/encryption
- Prev by Date: Re: Simple program cwitching thru all video-modes craps-out ...
- Next by Date: Re: Writing spaghetti code for obfuscation/encryption
- Previous by thread: Re: Writing spaghetti code for obfuscation/encryption
- Next by thread: Re: Writing spaghetti code for obfuscation/encryption
- Index(es):
Relevant Pages
|
|