Can anyone figure out this C Code?

Discussion in 'Programming' started by purifier, Apr 14, 2006.

Thread Status:
Not open for further replies.
  1. purifier

    purifier New Member

    Joined:
    Mar 31, 2005
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    Does anybody have any idea how this works???

    #include<stdio.h>
    main()
    {
    int a,b,c;
    int count = 1;
    for (b=c=10;a=
    "- LLLLLL?, LMKC,XYZHELLO FOLKS,\
    TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
    UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
    NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
    HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
    T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
    Hq!WFs XDt!" [b+++21]; )

    for(; a-- > 64 ; )
    putchar ( ++c=='Z' ? c = c/ 9:33^b&1);

    }

    It somehow manages to print map of India

    i feel a prog has be used to generate this code ...can nybody tell does such program exists for converting a simple logic into a cryptic form
     
  2. QwertyManiac

    QwertyManiac Commander in Chief

    Joined:
    Jul 17, 2005
    Messages:
    6,656
    Likes Received:
    10
    Trophy Points:
    0
    I saw this here I guess... Pointers I think...
     
  3. OP
    OP
    purifier

    purifier New Member

    Joined:
    Mar 31, 2005
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    Oh...yeah after posting...i'm searching too.. but not able to see a complete valid explanation anywhere...well pointers could be the thing...but i wonder how everything works out...
     
  4. nikhil ramteke

    nikhil ramteke s,b+..u cn..

    Joined:
    Dec 21, 2006
    Messages:
    76
    Likes Received:
    1
    Trophy Points:
    0
    u may get answer 4m www.programmersheaven.com .....i dnt know certainly u wil b getting it or not but try.....i wil also look 4 it.....
     
  5. tuxfan

    tuxfan New Member

    Joined:
    Feb 4, 2004
    Messages:
    2,653
    Likes Received:
    9
    Trophy Points:
    0
    Location:
    Mumbai
    This is not pointers.

    But a is declared as an int. So it can store 2 bytes of data. Instead of that, it is stuffed with so many characters.

    Additionally, the second part in the for() loop is the condition. So there should "a==..." instead of that there is a single =. So it is an assignement and not a condition.

    b and c are declared immediately after a. So most likely they will occupy next 4 bytes after a. But a is stuffed with these characters. First 2 characters are accessible with a, next two with b and next 2 with c. Even count will have characters from the same string.

    This is cryptic programming. My (rusted) knowledge of C isn't so good that I would understand this. But these are just a few observations. I have heard that there used to be competitions held for cryptic C programming. C is endless. :)
     
  6. jal_desai

    jal_desai New Member

    Joined:
    May 19, 2006
    Messages:
    426
    Likes Received:
    1
    Trophy Points:
    0
    ya such programs can create graphical outputs... but i think u may need to include graphics.h header file
     
  7. sachin_kothari

    sachin_kothari New Member

    Joined:
    Dec 13, 2004
    Messages:
    568
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pune
    This code is an obfuscated code.
    They are generally unreadable but executable.
    Wiki details out Obfuscated Code.
    There are software available that can obfuscate any c code. Just google it and you will find lots of obfuscator tools for C, Java, etc.
     
  8. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    Thanks for the info :) .I had never come through such a program :D
     
  9. adi007

    adi007 New Member

    Joined:
    Sep 10, 2007
    Messages:
    713
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    hassan
    me too :D:D
     
  10. aditya.shevade

    aditya.shevade Console Junkie

    Joined:
    Jun 29, 2006
    Messages:
    990
    Likes Received:
    3
    Trophy Points:
    0
    Location:
    USA
    Search for obfuscated c code in google. Even looking at the winning programs gives you a headache.
     
  11. fun2sh

    fun2sh Pawned!... Beyond GODLIKE

    Joined:
    May 2, 2006
    Messages:
    1,062
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    World Of Warcraft -DOTA
    how do get such ideas :shock: :shock: :shock: :shock: :shock: :shock:

    cant any1 explain that india map program. also first for[\B] loop in that prog contains only two expression instead of for(exp1;exp2;exp3)
     
  12. QwertyManiac

    QwertyManiac Commander in Chief

    Joined:
    Jul 17, 2005
    Messages:
    6,656
    Likes Received:
    10
    Trophy Points:
    0
    ^^
    For can be used without initialization and counter expressions :?

    for( ; condition ; ) is valid as you can place the initialization outside and counter inside the loop if you have to. Removing the condition makes it infinite loop until break.
     
  13. sachin_kothari

    sachin_kothari New Member

    Joined:
    Dec 13, 2004
    Messages:
    568
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pune
    @fun2sh
    The code is obfuscated so that it remains unexplainable.
    Its like you can look at the code, but cant make out the flow of the code.
     
  14. fun2sh

    fun2sh Pawned!... Beyond GODLIKE

    Joined:
    May 2, 2006
    Messages:
    1,062
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    World Of Warcraft -DOTA
    yeah i know that.we can even use like for(;;) but first for[\B] loop contains only one ;[\b] there.
     
  15. deepak.krishnan

    deepak.krishnan New Member

    Joined:
    Jan 11, 2005
    Messages:
    423
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Palakkad/Bangalore
    OMG how can one think of such a code??? :))
     
  16. ayush_chh

    ayush_chh Member

    Joined:
    Nov 25, 2005
    Messages:
    525
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bangalore
    man u did a great job...never knew this........:):)

    @purifirer

    where did u get tis from man????
     
    Last edited: Oct 27, 2007
  17. sachin_kothari

    sachin_kothari New Member

    Joined:
    Dec 13, 2004
    Messages:
    568
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pune
    ^^ Check this link for more obfuscated codes.
    This link is of International Obfuscated C code contest.
    Enjoy :)

    You cannot write such codes directly.
    There are obfuscated code generators which take your normal programs as input and produce obfuscated code.
     
    Last edited: Oct 27, 2007
  18. Pathik

    Pathik Google Bot

    Joined:
    Aug 28, 2005
    Messages:
    9,747
    Likes Received:
    20
    Trophy Points:
    0
    Yup... and i think coes are also obfuscated to make it difficult to reverse engineer it..
     
  19. sachin_kothari

    sachin_kothari New Member

    Joined:
    Dec 13, 2004
    Messages:
    568
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pune
    These codes can be reversed engineered only if the technique used by the obfuscator is known.

    There are some well know obfuscation techniques like
    > Layout obfuscations - modify the layout structure of the program by two basic methods: renaming identifiers and removing debugging information. They make the program code less informative to a reverse engineer. Most layout obfuscations cannot be undone because they use one-way functions such as changing identifiers by random symbols and removing comments, unused methods, and debugging information. Though layout obfuscations cannot prevent reverse engineers to understand the program by observing the obfuscated code, they at least consume the cost of reverse engineering. Layout obfuscations are the most well studied and widely used in code obfuscation. Almost all Java obfuscators contain this technique.

    |> Control obfuscations - change the control flow of the program. The trick is simple: For a routine A() obfuscator creates an additional routine A_bug and an "if" selector, if (PREDICATE) then A_bug(); else A();. The PREDICATE is designed on-the-fly in that way so it is always false (but it's made so it's hard to conclude that fact), and the A() routine is always selected instead of a buggy copy A_bug().

    |> Data obfuscations - break the data structures used in the program and encrypt literals. This method includes modifying inheritance relations, restructuring arrays, etc. Data obfuscations thoroughly change the data structure of a program. They make the obfuscated codes so complicated that it is impossible to recreate the original source code.

    Source
     
Thread Status:
Not open for further replies.

Share This Page