Tutorials for Code Obfuscation in C

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.

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?

Tags:

C

Obfuscation