Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Making C compiler generate obfuscated code
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Torben Ęgidius Mogensen  
View profile  
 More options Dec 15 2010, 5:23 am
Newsgroups: comp.compilers
From: torb...@diku.dk (Torben Ęgidius Mogensen)
Date: Wed, 15 Dec 2010 11:23:49 +0100
Local: Wed, Dec 15 2010 5:23 am
Subject: Re: Making C compiler generate obfuscated code

Joshua Cranmer <Pidgeo...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.