IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2020/yang - Best abuse of CPP

PIN-protected program generator

Author:

To build:

    make

To use:

    ./prog [PIN] < input.txt > output.c

Try:

    ./try.sh

The author provided the file cppp.cc which can preprocess the generated output to make them more acceptable to typical compilers. To build:

    make cppp

See the author’s remarks for more details.

Judges’ remarks:

You might think of this entry as code obfuscater with a code. If you use the wrong code, you’re gonna have a bad time. What is compiling this entry about? Having a good .. time!

This winning entry also comes with a JavaScript time-lapse obfuscation that shows how this entry was written.

Author’s remarks:

Synopsis

    echo "Hello world" | ./prog 12345 > encoded.c

    gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded

Details

Mile is a C code generator. Run without arguments for the help message below:

    usage: [PIN] < input.txt > output.c

    where [PIN] is an integer in the range of 1..65535

When run with an encoding PIN (first command line argument), Mile will read bytes from stdin and generate C code on stdout. Example:

    echo "Hello, world!" | ./prog 56789 > encoded.c

This generated code will reproduce the same input bytes on stdout when executed, if it was compiled with the same encoding PIN.

    gcc -DPIN=56789 encoded.c -o decoded

The generated code reconstructs all data at compile time by seeding a random number generator with the given PIN to reproduce the input bytes, and simply does one fwrite(3) call at run time to print those bytes. Not specifying a PIN is a compile time error. Specify the wrong PIN and output code will still compile, but will likely produce garbage instead of the input bytes. If the original input was empty then any PIN works, but you might get a compile time warning complaining about empty arrays.

Because all data is reconstructed at compile time, expect the compile time to be excruciatingly long if you try to encode too much data. Code generated by encoding a haiku will probably compile in seconds, a limerick may require tens of seconds, a sonnet will take minutes. Give Mile an epic poem and you can probably write a faster preprocessor before GCC is done (Clang probably already failed long before then).

I see that there is a lack of preprocessor abuse in recent years, probably because programming in preprocessor is too tedious. Mile is meant to help with that by producing C code filled with at least 98% preprocessor lines for any input. Now you too can enjoy long compile times with minimal effort.

Features

Compatibility

Mile has been verified to work in these environments (also, compiles without warnings on all of these):

Output of Mile is a bit more taxing, and only works with a subset of the above:

For people eager to encode large files, an extra utility has been packaged with this entry to preprocess the generated output to make them more acceptable to typical compilers. View the cppp.cc source and then compile it with a c++ compiler of your choice.

Inventory for 2020/yang

Primary files

Secondary files


Jump to: top