Related articles |
---|
Making C compiler generate obfuscated code dennis.yurichev@gmail.com (Dennis Yurichev) (2010-12-07) |
Re: Making C compiler generate obfuscated code paul.biggar@gmail.com (Paul Biggar) (2010-12-09) |
Re: Making C compiler generate obfuscated code Pidgeot18@gmail.com (Joshua Cranmer) (2010-12-09) |
Re: Making C compiler generate obfuscated code torbenm@diku.dk (2010-12-15) |
Re: Making C compiler generate obfuscated code gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-12-16) |
Re: Making C compiler generate obfuscated code Pidgeot18@gmail.com (Joshua Cranmer) (2010-12-16) |
Re: Making C compiler generate obfuscated code Pidgeot18@gmail.com (Joshua Cranmer) (2010-12-16) |
Re: Making C compiler generate obfuscated code martin@gkc.org.uk (Martin Ward) (2010-12-17) |
Re: Making C compiler generate obfuscated code gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-12-18) |
Re: Making C compiler generate obfuscated code rpw3@rpw3.org (2010-12-18) |
[11 later articles] |
From: | torbenm@diku.dk (Torben Ęgidius Mogensen) |
Newsgroups: | comp.compilers |
Date: | Wed, 15 Dec 2010 11:23:49 +0100 |
Organization: | SunSITE.dk - Supporting Open source |
References: | 10-12-017 10-12-019 |
Keywords: | C, code |
Posted-Date: | 15 Dec 2010 23:53:54 EST |
Joshua Cranmer <Pidgeot18@gmail.com> writes:
> If I wanted to deobfuscate this code, all I have to do is first run it
> through an optimizer, and one simple enough to be written as a course
> project at that. If you really want to obfuscate the code, it's better
> to modify the control flow graph as opposed to inserting random
> do-nothing code.
Indeed. I wsa not impressed by the approach: It made the code a lot
larger and a lot slower and the obfuscation was easy to remove.
Ideally, obfuscated code should only be marginally larger and slower
than "normal" code, but extremely difficult to reverse-engineer.
Some of the least readable code I have seen has been code where every
trick in the book was used to make it as short as possible, so using
extreme optimisaton tricks is probably a much better obfuscator than
inserting random code -- even random control-structure code.
Some common optimisations do, indeed, make the code less readable:
Strength reduction, loop scheduling, array blocking, common
subexpression elimination and so on. So using these aggressively
would work well. But there will be code where such optimsations do
not apply. Here, you could use some of the following tricks:
- Split a variable x into two variables p and q, such that x=p+q.
Modifications to x are made into modifications of p _or_ q. Uses of
x (except those for self-modification such as x=x+1) are replaced by
uses of p+q. This will make the code somewhat larger and slower, but
not by much. Common subexpression elimination can remove some of the
p+q additions without increasing readability.
- Replace two otherwise unrelated variables x and y by p and q such
that p=x+y and q=x-y (so x==(p+q)/2 and y==(p-q)/2).
- A variable x holding small non-negative integers is replaced by a
variable p = 2^x. Additions and subtractions of constants to x are
made into shifts. Using x is more tricky, though, unlesss there is a
"count leading zeroes" instruction.
Torben
Return to the
comp.compilers page.
Search the
comp.compilers archives again.