![]() | Obfuscation |
Too obvious | |
|
When writing programs in C, many are struck by the all too obvious
intentions of their programs. As an example, take the classic ``hello world''
program:
One may wonder how the striking clarity of this program is best avoided. |
A first try | |
Two things spring to mind:
Let us use the string "&$#%@!)*~'!dowl\n Hre", consisting of the characters after encoding (a number of randomly picked, unique characters), followed by the original characters. Of course, the letters from the original "Hello world!" are thoroughly shuffled. This brings us at our first attempt
Notes
|
Going further | |
Clearly, this is not yet up to standards,
but it is getting somewhere. Some of the things about the program so far
that still nag me are that
|
Hello obfuscated world! | ||
|
And finally, using some more C tricks, we get an obfuscated ``hello world''
program:
Which is more like it :-) Some of the `tricks':
A little bit more can be done about this program like removing white space, changing the layout so the f&'s don't stick out so clearly, and removing the f&4. Like so
|
To hell with the standard? | |
True hackers don't care about standards. The code above is (strictly, as
far as I can tell) ANSI/ISO C compliant, but can be tricked even more if we
To avoid dependence on the value main() gets as first argument from the environment (all we know is that it is positive), we shall use negative function codes (the f's above). We can now put everything in one function:
Since this version is non-standard, there is a slight chance that it won't run as expected on your system. |
Would you like more stuff like this? |
Well, you are lucky then! I can offer you a few programs rightaway:
You will notice that there are many more obfuscation techniques than I discussed here. Those are really just beginners work. Often people will do something about the visual appearance of their programs, use the preprocessor to make things even less intelligible, or even use system-specific tricks to prevent other people from understanding what their programs do. I am particularly fond of my contribution in smile.c: using my own name in the decode string. You will have to understand the program in order to change it to your own name and still keep the program working! But if you want more of the real stuff out there, check out the archives of the International Obfuscated C Code Contest (or IOCCC for short) whose winning entries are accessible at
|
Ha! You want to try your luck? |
| Receive everlasting fame, enter the annals of the IOCCC, never get an employer, show off as a Great Hacker... Is that the Ultimate Goal for you? Then here's where you should go! |
This page was written by Arjan Kenter.