Obfuscation Strategies

Tricks and techniques for deliberately obfuscated code, particularly ObfuscatedCee. The kind of stuff you'd never use in your own code, but would apply liberally for the InternationalObfuscatedCeeCodeContest.

Please contribute ideas!


There is a category of tricks that take advantage of CeePreprocessorStatements to disguise the intentions of individual symbols. These are often effective, but keep in mind that the first stage in the scoring at the contest is to run everything through the preprocessor.

If you do this, your code could look like this:

 #define O0OO0OO00OO00OO0 int
 #define O0OO0O0OOOO00O00 ;
 O0OO0OO00OO00OO0
 O0O00O0OO0OOOO00
 O0OO0O0OOOO00O00

I would suggest actually editing your code as normal code, and having a script apply this transformation.


Some C functions return values that most programmers ignore. For example, [fs]?printf return the number of characters that were written. Use this fact.

  int l10 = printf("%d", n); /* Poor man's common log. */

Use recursion. Recursive calls to main are always popular.

Use the techniques Roedy Green describes in HowToWriteUnmaintainableCode.

Write code that reads its source file.

Use non-portable constructs:

  int n = 8;
  int nn = ++n * n++; /*  72, 80, 81, 90 are all possible values. */

Abuse the comma and ternary operators.

Use trigraphs. Use digraphs!

Keep in mind that the contest judges "tend to dislike programs that... obfuscate by excessive use of ANSI tri-graphs." (http://www1.us.ioccc.org/guidelines.txt)


EditText of this page (last edited April 12, 2004) or FindPage with title or text search