Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tutorials for Code Obfuscation in C [closed]

Tags:

c

obfuscation

I am fascinated by the way people obfuscate their code (mostly, C) (examples here : http://ioccc.org/) and would like to learn the various techniques for the same. I have been told of a book, "Obfuscated C and other Mysteries", but I am not able to get that book. Are there any tutorials or books that give hints on this topic? Thank you.

like image 971
Chandra Avatar asked Jun 13 '13 06:06

Chandra


2 Answers

The best you can do is read the comments of the author of the programs on IOCCC. They describe how they manage to obfuscate their code. Here are a few pointers:

Short and meaningless identifiers

Because a=aaa*aa; will always be more obfuscated than result = value * factor;

In order to have short identifiers, obfuscators tend to even #define many things.

Reversed array indexing

You just have to remember that var[3] and 3[var] are equivalent.

Digraphs and trigraphs

if(a< <:b+aa??))??<f();%>

should be less readable than:

if (a < (b+aa)) { f(); }

Look-alike characters

Sometimes, it's hard to tell appart l, 1 and I or o, 0 and O. For example, if you write 10l, I bet everyone will read 101 instead.

Coding style guidelines

Generally speaking, just try to find good coding guidelines and to try to violate them all. Those documents that you could find anywhere on the web could help you more than most things and would allow you not to buy anything.

Here are some links:

  • How to write unmaintainable code.
like image 157
Morwenn Avatar answered Sep 23 '22 03:09

Morwenn


Morwenn's answer nicely covers obfuscation of syntax. But there is another level, and that is semantic obfuscation. Consider that the oft-mentioned Turing Machine has the same computational power as any other programming language (ignoring considerations of input and output). In fact all of the various models of computation have sibling models with equivalent power.

For example, a string char s[N] can be considered a mapping from indices to characters, so any string can be represented instead by a function which always delivers the appropriate character when called with a specified index char f(int i). Now read this. Crazy, right?

like image 35
luser droog Avatar answered Sep 22 '22 03:09

luser droog