Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
It's funny.  Laugh. Programming Technology

18th International Obfuscated C Code Contest Opens 187

chongo writes "The 18th International Obfuscated C Code Contest, the Internet's longest running contest, is now open. The goals, rules, and guidelines are available. Use the online submission tool to submit your obfuscated C code by 22-May-2005 23:59:59 UTC."
This discussion has been archived. No new comments can be posted.

18th International Obfuscated C Code Contest Opens

Comments Filter:
  • by Entropy248 ( 588290 ) on Wednesday March 23, 2005 @02:24AM (#12021094) Journal
    Here [ioccc.org] are some past winners with "Spoilers" for what they do. It's already pretty slow though and I'm first post.
    • The most brilliant one in my opinion is Jason from 2001. In the author's words it's 'downright chatty for only having two string literals ("%d \n" and "Y\n : ! ,.?>")'

      The thing is I know theoretically how the program does it, but I just don't know how he wrote it!
      • My personal favorite is the following:


        It's a command line based ascii to morse converter...
        I especially like the fact it's a bunch of DAH DAHDIT!
        • After running arg.c (just a file with the original source code in it) through the preprocessor and some indentation:

          # 1 "arg.c"
          # 1 ""
          # 1 ""
          # 1 "arg.c"
          # 9 "arg.c"
          char _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7 c 8a90l?e'b.s;i,d:";
          main ( )
          {
          char * _DIT,* DAH_,* DIT_,* _DIT_,* malloc (),* gets ( );

          for ( _DIT=malloc ( 81 ),DIT_=_DIT++;_DIT== gets ( _DIT );__DIT('\n') )
          for ( DAH_=_DIT; *DAH_; __DIT ( *_DIT_?_DAH ( * DIT_ ):'?'),__DIT(' '),DAH_ ++ )
          for (* DIT_=2,_DIT_=_DAH_
          • Oh yeah I used the preprocessor to cheat through the redefinition of the reserved keywords and other operators basically just the #define DIT ( #define DAH ) #define __DAH ++ #define DITDAH * #define DAHDIT for #define DIT_DAH malloc #define DAH_DIT gets #define _DAHDIT char stuff. After that it's pretty much just reading normal-ish code... enjoy
    • Now waiting for YOUR favourites from the entries.
      Mine:
      -calculating surface of circle by counting the characters of ascii-arted one,
      -the letter from Char(lie) to Char(lotte).
  • by mirko ( 198274 ) on Wednesday March 23, 2005 @02:25AM (#12021105) Journal
    The highlight of the annual Computer Bowl occurred when Bill Gates, who was a judge, posed the following question to the contestants:


    ``What contest, held via Usenet, is dedicated to examples of weird, obscure, bizarre, and really bad programming?''

    After a moment of silence, Jean-Louis Gassee (ex-honcho at Apple) hit his buzzer and answered ``Windows.''

    Mr. Bill's expression was, in the words of one who was there, ``classic.''
  • by AhaIndia ( 725879 ) on Wednesday March 23, 2005 @02:26AM (#12021110) Journal
    The legacy code I have to work on must be submitted. No body knows how it works and there is no documentation.
  • Hmm.. (Score:5, Funny)

    by bl4nk ( 607569 ) on Wednesday March 23, 2005 @02:32AM (#12021140)
    DOS C:\DOS C:\DOS\RUN RUN DOS RUN.. Wait... that's C isn't it? God damn it. I'll never win at this rate...
  • Mirrors (Score:5, Informative)

    by ugo ( 305502 ) on Wednesday March 23, 2005 @02:34AM (#12021150) Homepage
    www.tw.ioccc.org - Hsin-Chu, Taiwan
    www.au.ioccc.org - Sydney, Australia
    www.de.ioccc.org - Frankfurt/Main, Germany
    www.es.ioccc.org - Madrid, Spain
    www.gr.ioccc.org - Athens, Greece
    www0.us.ioccc.org - Sunnyvale California, US
    www1.us.ioccc.org - Saint Paul, Minnesota US
    • Imawhore (Score:5, Informative)

      by Kethinov ( 636034 ) on Wednesday March 23, 2005 @02:53AM (#12021215) Homepage Journal
      Google cache of the main page: http://64.233.167.104/search?q=cache:QecdG73oJ2cJ: www.ioccc.org/main.html+The+International+Obfuscat ed+C+Code+Contest&hl=en&client=firefox-a [64.233.167.104]

      Full text of rules.txt

      18th International Obfuscated C Code Contest Rules

      Copyright (C) 2005 Leonid A. Broukhis, Simon Cooper, Landon Curt Noll and
      Peter Seebach.

      All Rights Reserved. Permission for personal, education or non-profit use is
      granted provided this this copyright and notice are included in its entirety
      and remains unaltered. All other uses must receive prior permission in
      writing from the contest judges.

      Obfuscate: tr.v. -cated, -cating, -cates. 1. a. To render obscure.
      b. To darken. 2. To confuse: his emotions obfuscated his
      judgment. [LLat. obfuscare, to darken : ob(intensive) +
      Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
      obfuscatory adj.

      GOALS OF THE CONTEST:

      * To write the most Obscure/Obfuscated C program under the rules below.
      * To show the importance of programming style, in an ironic way.
      * To stress C compilers with unusual code.
      * To illustrate some of the subtleties of the C language.
      * To provide a safe forum for poor C code. :-)

      The 18th IOCCC contest window is:

      | 21-Mar-2005 00:00 UTC to 22-May-2005 23:59:59 UTC

      RULES:

      To help us with the volume of entries, we ask that you follow these rules:

      1) Your entry must be a complete program.

      2) The size of your program source must be <= 4096 bytes in length.
      The number of characters excluding whitespace (tab, space,
      newline, formfeed, return), and excluding any ; { or } immediately
      followed by whitespace or end of file, must be <= 2048.

      3) Submissions should be performed using the instructions outlined at,

      | http://www.ioccc.org/2005/submit

      4) If your entry is selected as a winner, it will be modified as follows:

      Your 'build' instructions will be incorporated into a
      makefile. If your build instructions *is* a makefile then
      it should be portable and usable from within a master
      makefile.

      Your program source will be renamed using an identifier of
      our choice (usually your family name or anonymous) followed
      by an optional digit, followed by '.c'

      Your entry will be compiled into a file with the above name
      minus the '.c'.

      If your entry requires that a build file exist, state so in
      your entry's remark section. The makefile will be arranged to
      execute a build shell script containing the 'build'
      information. The name of this build shell script will be your
      entry's title, possibly followed by a digit, followed by '.sh'.

      If needed, your entry's remarks should indicate how your entry
      must be changed in order to deal with the new filenames.

      5) The build file, the source and the resulting executable should be
      treated as read-only files. If your entry needs to modify these files,
      it should make and modify a copy of the appropriate file. If this
      occurs, state so in your entry's remarks.

      6) Your program source must be able to be compiled cleanly by an ANSI C
      compiler, or if there are any compile errors, they must be documented
      in the "remarks" section of your submission.

      7) The program must be of original work. All submitted programs are
      are thereby put in the public domain. All explic

  • I wonder... (Score:3, Interesting)

    by slobber ( 685169 ) on Wednesday March 23, 2005 @02:39AM (#12021164)
    is there a similar contest for Perl? I imagine much crazier submissions with Perl than what can be done with C (no offense to C programmers ;))
  • by aendeuryu ( 844048 ) on Wednesday March 23, 2005 @02:43AM (#12021178)
    Once upon a midnight dreary, gcc compiled, growing weak and weary,
    code obfuscated like ne'er seen before.
    I could hear a faint grinding,
    As the preprocessor went on finding,
    it was a noise I could plainly say I abhor.
    T'was an executable destined to dump quite a core.

    It was a nice sunny day, I remember, in May,
    and there lay pizza boxes scattered all o'er the floor.
    But because of this Gentoo, I felt I was being sent to
    the depths of hell for damnation evermore.
    All for a program that would dump its core.

    In time, day diminished, and gcc was finished,
    and the program was a size worthy of lore,
    because of the a.out, my hard drive near ran out,
    as the program took up gigabytes galore,
    and when I ran it, quoth the output, "I've just dumped a core."
    • Once upon a midnight dreary,
      while I websurfed, weak and weary,
      Over many a strange and spurious
      website of hot chicks galore,

      While I clicked my fav'rite bookmark,
      suddenly there came a warning,
      And my heart was filled with mourning,
      mourning for my dear amour.
      'Tis not possible, I muttered,
      give me back my cheap hardcore! --

      Quoth the server, "404".
  • Will anyone be able to top the venerable 12 days?
    • I think Fabrice Bellard's original implementation of TCC is more interesting that the 12 days. The entry contained a compiler for a subset of C that was enough to compile the compiler itself (among other things). Since then, TCC has been un-obfuscated and enhanced. While it does not produce highly optimised code, it does produce correct code very quickly, and so is quite useful in rapid test/development cycles.
  • Maze of Code (Score:5, Interesting)

    by Anonymous Coward on Wednesday March 23, 2005 @02:47AM (#12021196)
    Compile with -fwritable-strings, run, type in a number like 20, find your way out...

    char*M,A,Z,E=40,J[40],T[40];main(C){for( *J=A=scanf(M="%d",&C);
    -- E; J[ E] =T
    [E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|"
    ) , A = 39 ,C --
    ) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C
    & A == T[ A]
    |6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z ]=A,"_.":" |"];}
  • by PornMaster ( 749461 ) on Wednesday March 23, 2005 @02:49AM (#12021205) Homepage
    If you haven't been there yet, you should check out TheDailyWTF [thedailywtf.com]... it's not obfuscated code, but rather unmaintainable code people submit to show what they've been left to deal with at work. Quite interesting, and sometimes as difficult to understand as intentionally obfuscated code.
    • by Repton ( 60818 ) on Wednesday March 23, 2005 @04:53AM (#12021585) Homepage

      This truly brings tears to my eyes...

      public boolean compareObjects(Object obj1 , Object obj2) {
      if (obj1.equals(obj2) == true)
      return true;
      else
      return false;
      }

      Oh why aren't we teaching more people to code like this?

      • This truly brings tears to my eyes...

        Tears...chest pains...same thing.
      • Y'know, I think I've seen that same function in some code at my office.... Just change the names a bit....
      • In my experience, code like that often comes about as a programmer is experimenting with a different algorithms (sometimes to fix bugs) and simply forgot to finish refactoring that slice.

        For instance, I once used a byte array of one 1 element as a buffer! The reason was that my previous design overused Java IO streams. The next version (which is much simpler) just modified the bytes directly from a single stream. However, with my brain in "byte" mode I tried to use bytes where I should have used an int.

        • I prefer the latter form:

          int buffer;
          while((buffer = in.read()) != -1) { //...

          It reads the easiest, to me. "While the read operation doesn't return -1"

          Since most read operations return the number of characters/bytes read though, I'd probably write it as:

          while ((buffer = in.read()) > 0)

          to give a clearer indication of expecting more than 0 characters/bytes. Maybe I'm just overly used to reading while(read(buf,1024) > 0) statements.
          • while ((buffer = in.read()) > 0)

            That wouldn't work, since the null character is still a legit byte. Did you mean:

            while ((buffer = in.read()) >= 0)

            That's why I usually deal with buffer classes and streams for both reading and writing rather than looking at the bytes by hand. :) However, in this case they were overkill for my method.

            • Actually, null characters are used to terminate strings, so if there's one byte left to be read and it's a null character, the read routine would just return a string with length of zero. If it's the EOF character, it would return -1.

              I actually had a problem with the null character recently where somehow one of them ended up in an XML document and my parser was just choking all over it and I couldn't figure out why until I pulled the source into a hex editor the examine all the character codes specifically
              • Actually, null characters are used to terminate strings, so if there's one byte left to be read and it's a null character, the read routine would just return a string with length of zero. If it's the EOF character, it would return -1.

                That's true in C, but not in Java. Try this code fragment:

                byte[] bytes = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
                String string = new String(bytes, "UTF-16LE");
                System.out.println(string.length());
                System.out.println("'" + string.codePointAt(1) + "'");

                The first println w

        • while(in.available()) {

          Correction! Actually, the faulty line was:

          while(in.available() > 0) {

          That's what I get for typing from memory...

      • by sconeu ( 64226 ) on Wednesday March 23, 2005 @12:03PM (#12025279) Homepage Journal
        Reminds me of some code... it was in a military system...


        while (strncmp(p," ", 1) == 0)
        ++p;


        To find the first non-space character in a string.
      • Can somebody enlighten a newbie what is wrong with parent's code? Is the following snippet better:
        public boolean compareObjects(Object obj1,Object obj2) {
        return obj1.equals(obj2);
        }
  • by sshtome ( 771249 ) on Wednesday March 23, 2005 @02:53AM (#12021216)
    "With a little practice, language can become a complete impediment to understanding"
  • by fm6 ( 162816 ) on Wednesday March 23, 2005 @02:55AM (#12021228) Homepage Journal
    ...is from all the brains that exploded as they tried to grasp that code.

    But what's the point? Why expend all that effort on obfuscating code when there are languages with obfuscation already built in [archive.org]?

  • Ode to C. (Score:5, Funny)

    by Anonymous Coward on Wednesday March 23, 2005 @02:57AM (#12021233)
    May your signals all trap
    May your references be bounded
    All memory aligned
    Floats to ints rounded

    Remember ...

    Non-zero is true
    ++ adds one
    Arrays start with zero
    And NULL is for none

    For octal, use zero
    0x means hex
    = will set
    == means test

    use -> for a pointer
    a dot if its not
    ? : is confusing
    use them a lot

    a.out is your program
    there's no U in foobar
    And char (*(*x())[])() is a function returning a pointer to an array of pointers to functions returning char.

    • You lost me at "?: is confusing"... how is a simple ternary logic operator confusing?!
      • > a simple ternary logic operator confusing?

        For the same reason you can't use words like "abstruse" in any modern text. People just don't want to learn their language before insisting on using it.
        • You're just trying to be abstruse. ;-)
          • > You're just trying to be abstruse

            No, I'm trying convey my perspicuous indignation at the tenacity of human ignorance. The ignominy of its apostles inspires enmity and distaste in any reasonable man. Alas, the conundrum of their persistence is unexplainable.
  • by Anonymous Coward on Wednesday March 23, 2005 @03:05AM (#12021254)
    It does say something about the joy and beauty of C that such a contest is even possible. It says something about "learning from their mistakes" that you couldn't even have a contest like this in Java. You just can't write a valid Java file that is obfuscated to such an extent. A large part of it is that Java has no pointers and everything has to exist within a class.

    Wasn't there some kind of obfuscated vote counting software contest announced before the recent US election? I would like to see some of the entrants into that.

  • by Crspe ( 307319 ) on Wednesday March 23, 2005 @03:50AM (#12021390)
    This I love - One guy went and had the first ever entry in the ioccc (from 1984) tattooed on his forearm ...
    http://tattoo.thomasscovell.com/index.html [thomasscovell.com]

    This I also love - the first ever entry was a hello world program!

    That entry was the longest one ever made into a tattoo, however there are hundreds of people around the world who have unknowingly had this entry tattoed on their forearm:
    http://www.de.ioccc.org/years.html#1994_smr [ioccc.org]

    This is really a great competition - lots of fun, lots to learn. Try understanding how some of the entries work, its really a challenge sometimes, and you can learn plenty about C and the preprocessor.
    • That entry was the longest one ever made into a tattoo, however there are hundreds of people around the world who have unknowingly had this entry tattoed on their forearm:
      http://www.de.ioccc.org/years.html#1994_smr [ioccc.org]

      wow. I didn't realize that I had that tattoo!

      ...took me a few minutes to figure out why the source wasn't loading. Then I realized that damn Microsoft C loaded it more than 1000 times in the same window!

  • by halleluja ( 715870 ) on Wednesday March 23, 2005 @04:11AM (#12021460)
    telnet.c
  • by Crspe ( 307319 ) on Wednesday March 23, 2005 @04:14AM (#12021467)
    The goals of the competiton are ...
    • To show the importance of programming style, in an ironic way.
    • To stress C compilers with unusual code.
    • To illustrate some of the subtleties of the C language.
    • To provide a safe forum for poor C code. :-)

    They certainly achieve their goal of showing how bad caode can be and also of providing a safe forum for amazing C code.
    I have also learnt much better how to program in C, even for unobfuscated code. There is nothing like going through some of these entries to understand much better how the preprocessor works, and how compilers react to differrent constructs.
    So, the only goal left is that of stressing the C compilers ... does anyone have some good examples of bugs found *and later fixed* in c compilers due to this competition? There are certainly enough evidence of the compilers being crashed, but I wonder if anything positive has come out of it.
  • Last Year's Winners (Score:2, Interesting)

    by ajs318 ( 655362 )
    I actually quite liked Hibachi [snert.org]. And not just for the animated logo! You can even run multiple instances on separate ports, and use NAT and port forwarding to get a poor man's virtual server setup.

    I'd recommend you stick to v1.0 {which is actually PD}, for licencing reasons. The v2.8 licence is unnecessarily restrictive.
  • by 10101001011 ( 744876 ) on Wednesday March 23, 2005 @04:58AM (#12021601) Homepage
    We ought to submit the code for WIndows?
  • Ive seen obfuscated DVD decryption code..

    But what happens if someone submits obfuscated SCO code? Heck, what happens if someone submits code that used to be proprietary? Noone really checks, and say the code gets printed on T-shirts and the like, and is discovered by the owners, wonder what the consequences will be.

    I'll just send my sendmail.cf
  • Many people can write code, fewer people can write good code.

    The many who do not write good code also produce obfuscated code without even trying. This is particularly true with large projects, done by groups, over time, and with limited oversight.

    Another interesting contest would be to see how fast different people could figure out such code.
  • I've been wanting to get a cool tatoo [thomasscovell.com] for a while now...
  • Looks like line noise.
  • ...or did any other web developers get their wires crossed when they read "18th International" and thought this had something to do with "I18N"?
  • You want obfuscated? (Score:4, Informative)

    by prakslash ( 681585 ) on Wednesday March 23, 2005 @09:47AM (#12023216)

    Try this:

    Whitespace [dur.ac.uk]

    It is so obfuscated, you cannot even see it!

    • by m50d ( 797211 )
      It's pretty simple really though, you just have to convert it and then you've got your basic language, as long as you can handle stack-based programming it's a breeze. Ook is more to my liking.

"The great question... which I have not been able to answer... is, `What does woman want?'" -- Sigmund Freud

Working...