The International Obfuscated C Code Contest
A 27th IOCCC Winner
Ilya Kurdyukov
https://github.com/ilyakurdyukov
Twitter: @ilyakurdyukov
The code for this entry can be found in prog.c
make
./prog
# Obfuscated IOCCC
echo IOCCC | ./prog
./prog < prog.x86.asm
./prog < prog.x86_64.asm
This hash of a C code makes a hash out of input. Do you understand how? You should get a-round-to-it figuring it out!
Just a tiny MD5 checksum utility. Prints hash string of data from stdin.
Work same as (openssl md5 | cut -d' ' -f2)
command.
-Wall -Wextra -pedantic
The main difficulty of making MD5 code smaller is a 64x4 bytes long table with constants. Which will take more than 512 bytes in text hex encoding. This table is a results of a sine function, so can be generated dynamically, but merging floating-point arithmetics with precise integer calculations is not a great idea, because can make portability issues.
Attempts to satisfy CLANG -Weverything
will ruin comma magic, that is so great for obfuscation, so I don’t want to care about that.
Probably, should work correctly on any machines, but I have nothing exotic (like BE or not 32/64) to try it.
Added a macro hack to make stdin work in binary mode under Windows (tested under mingw64), otherwise the hashes can be incorrect.
prog.extra.c
the same with the sine function (so smaller), and in different shapes.
prog.x86_64.asm
contains same program, but written on assembly for x86_64 Linux, for the sake of less executable size. Which is 500 bytes long (where 120 is for ELF headers) after compilation. Algorithm details is slightly differ (like constants packing), just to make smaller binary code. It’s interesting to compare density of binary code and obfuscated C.
prog.x86.asm
and for x86, although the headers are smaller, but the binary code is larger due to fewer registers and lack of 64-bit multiply.
© Copyright 1984-2020,
Leo Broukhis, Simon Cooper, Landon Curt Noll
- All rights reserved |