Sunday, December 18, 2011

Code Obfuscation (Example 1)

Following through the series of posts about code obfuscation and unmaintainable code, I want to show here a C code snippet:


#define x(y,z) z , y
#define y(z,x) x z
#define a(b,c) c##b
#define x167 }
#define x879 x167;
#define x798 '\0'x879
#define x98 {
#define _ a(ain,m)
#define __ ()
#define b(c,d) a(c,d)
#define w a(ar,ch)
w ____[] = x98 x(0154, x(0145, 0110)), 108, 111, 30+02, 87, 0x6f, 0162, 0x6c, 0x64, x798
w ___[] = x98 '%', 's', x(x798, '\n')
_ __ x98 y((___, ____),a(ntf,pri)); x167


This is indeed a full working program, and the techniques used here to screw the code are simple enough. What's the actual purpose of this program?

Compile & running it (or gcc -E) are good means to see in its internals.

No further explanation is being given here, as I consider this to be easy enough!

5 comments:

  1. Tu, che posti cose del genere, sei matto XD ...io che impiego le mie pause a riconstruire questa roba ben sapendo dove andava a parare, sto ancora peggio XD ...

    ReplyDelete
  2. ciao mondo ...
    banale :P ! Criptalo un altro po' la prossima volta XD ...

    ReplyDelete
  3. Liuk, ste cose sono da ingegneri del software! Basta!! :-D

    ReplyDelete
  4. Ingegneri del software?! Ma cosa! Bravi comunque, sono fiero di voi! :P

    ReplyDelete