|
-
Oct 17th, 2002, 12:43 AM
#1
Thread Starter
Hyperactive Member
Contest :-)
Ok Guys a friend of mine wrote this code and i wanna see if we have some good C++ programmers in this forum :-)
Anyone that can figure out how this code works and post a good explanation WINS
Code:
#include <stdio.h>
#define _____ char
#define ____ int
#define _ main
_____ ______[]="]a`z)`z)Clp. z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})
;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm
f%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";_(____ __, _____ ** _______){__>0?_(0,(_____**)______) (_____*)_______)[-__] == '\0'?putchar(10) utchar(((_____*)_______)[-__]^9)?_(--__,_______):_(__,++_______);}
-
Oct 17th, 2002, 04:42 AM
#2
Monday Morning Lunatic
It doesn't even compile like that so I'm doing the expansions by hand %-)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 04:44 AM
#3
Monday Morning Lunatic
Ooh, recursive main(), these are always fun...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 04:52 AM
#4
Monday Morning Lunatic
Code:
#include <stdio.h>
char str[] = "]a`z)`z)Clp. z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})\n ;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm\nf%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";
main (int argc, char ** argv) {
char* p = str;
while(*p) {
putchar(*p ^ 9);
++p;
}
}
Recursion removed 
What I did was look for where it was going, and with the calling of main with argc increased each time, looks like it's using main to loop through a string. That done, it XORs the character with 9 and prints it. I also had to replace the actual newlines in the string with '\n' characters.
This gives the message:
Code:
This is Jey')s Obfuscated Hello World example! It is copyright )2001 by Jeyasankar Kottalam.
Without further ado, here's the message: HELLO, WORLD!
Not bad considering the code you gave doesn't compile
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 04:55 AM
#5
Monday Morning Lunatic
Hmm, just noticed those spurious brackets...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 04:57 AM
#6
Monday Morning Lunatic
Code:
#include <stdio.h>
const char str[] = "]a`z)`z)Clp.z)Fko|zjh}lm)Aleef)^f{em)lqhdyel()@})`z)jfyp{`na})\n;998)kp)Clphzhgbh{)Bf}}hehd'\3\3^`}af|})o|{}al{)hm\nf%)al{l.z)}al)dlzzhnl3)ALEEF%)^F[EM((";
int main (int argc, const char **argv) {
const char* p = str;
while(*p) {
putchar(*p ^ 9);
++p;
}
putchar('\n');
}
Done.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 08:54 AM
#7
Woah, why write such a thing?
I guessed at how to solve this, but I'm sure I'd have been too lazy...
Good job, parksie.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2002, 08:55 AM
#8
btw it is less a matter of being a good C++ programmer, but more of knowing such obscure things like trigraph sequences.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2002, 09:07 AM
#9
I have extended the thing a little bit.
But I mostly copied the original, so it still won't compile.
Code:
??=include <stdio.h>
??=define _____ char
??=define ____ int
??=define _ main
_____ ______??(??)="??)a`z)`z)Clp. z)Fko??!zjh??>lm)Aleef)??'f??<em)lqhdyel()@??>)`z)jfyp??<`na??>)
;998)kp)Clphzhgbh??<)Bf??>??>hehd'??/3??/3??'`}af??!??>)o??!??<??>al??<)hm
f%)al??<l.z)??>al)dlzzhnl3)ALEEF%)??'F??(EM((";____ _(____ __, _____ ** _______)??<__>0?_(0,(_____**)______) (_____*)_______)??(-__??) == '??/0'?putchar(10) utchar(((_____*)_______)??(-__??)??'9)?_(--__,_______):_(__,++_______);??>
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2002, 10:11 AM
#10
Monday Morning Lunatic
The "utchar" is also a typo.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 10:46 AM
#11
Frenzied Member
Originally posted by CornedBee
Woah, why write such a thing?
I guessed at how to solve this, but I'm sure I'd have been too lazy...
Good job, parksie.
Agree =). But obfuscating hello world isnt a big deal... Obfuscate Halflife =P.
Z.
-
Oct 17th, 2002, 12:18 PM
#12
Thread Starter
Hyperactive Member
-
Oct 17th, 2002, 01:48 PM
#13
Monday Morning Lunatic
I'm suspicious though. How did your friend write it? You haven't been allowed to get away with code like that without specifically compiling it as "old" C...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2002, 02:27 PM
#14
Thread Starter
Hyperactive Member
I dont know ill refer him to this forum and have him post an answer
-
Oct 18th, 2002, 04:55 PM
#15
I wrote this code once. It's legal C++.
Don't cheat by running it!
Code:
??=define e(r)e??=#??=??=??=??=#??=r
??=define b(e)""??=#??=e??=#""
??=define t(i)()r(??<)#??=??/
e(t)#??=urn(i??=#??=??=??/
b(y)??=??=i#??="")+((3??'(0??=#x2??!1))??!
??=define r(i)i#??=#??=??=??=r
??=include<iostream>
??=define i(i)in??=#t ma??=??=in()??<??/
st??=??=d::cou??=??=t<#??=r(<i;)??=#e(t)#??=ur#??=n 0??'0
??=define d(t) i(b(h)??=#"i"??=#b(??/?)??/
<??=#<std::??=??=e(ndl<)??=??=<'b'<#??=<e(r)())
r(cha)*r(e) t(b(e)"??/41")2);??>d(??!/\??\
??=ine i(i)in??=#t ma??=??=in)??!0;??>
When I first wrote it, it output Dutch, it took me 30 minutes just to convert it to English.
Note to self: Never write code like that again!
Last edited by twanvl; Oct 18th, 2002 at 05:05 PM.
-
Oct 18th, 2002, 05:05 PM
#16
Monday Morning Lunatic
Most of it's just trigraphs.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 18th, 2002, 05:12 PM
#17
You're right, I wrote this code when I learned about trigraphs (found a link in MSDN library) Without the trigraphs it's just a bunch of macros
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|