If this blog helped you in any way, please donate a dollar here

Friday, September 24, 2010

Obfuscated Code Contest

Obfuscation is an art. It refers to making your code hard to read... hard to understand using advanced concepts. So, let me present a code that prints my name, but in an obfuscated manner! This was done by me a couple of years ago, but was faulty. I corrected it and here it is:

float m[] = {2.94576846098867283087373218349056E+32, 3.761396E+24, 9.316795E-39 };
main(){printf(m);}

Magic eh? Nope... just an understanding of data types.

The concept here is pretty simple. Data representation is exploited. Don't think IEEE754 here, since this can be made with a simpler technique. So.. let me ask my readers... what technique can be used to generate the number?

I am giving away a prize for the person who answers this first and correctly. Best of Luck!

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Here is a code which generates this kind of program.....All u need to do is change d string hardcoded :)




    #include<stdio.h>
    typedef float type;

    /*as this trick works for other data type also...u can use nything...just change printf parameter acordingly :)*/

    int main()
    {
    char s[]="Mrinalkanti Ghosh";
    type * p=(type *)s;
    int i;
    int c=sizeof(s)/((float)sizeof(type))+.5;
    /*to avoid integer division*/
    printf("float m[] = {");
    for(i=0;i<c;i++)
    printf("%1.32E,",p[i]);
    printf("\b};\nmain(){printf(m);}");
    return 0;
    }

    ReplyDelete
  3. @Mrinal: Hats off to you man!

    You are the winner. :)

    @readers... Intro for Mrinal: He is in IIT-Kanpur and refused a job in TCS to pursue his higher studies...

    ReplyDelete
  4. Not really....i got job in Infosys :)

    ReplyDelete
  5. So, what did the winner get ?? a date with you ??

    ReplyDelete