Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Unnecessary Obfuscation  (Read 1069 times)

Mephisto

  • Bay Watcher
    • View Profile
Unnecessary Obfuscation
« on: September 13, 2009, 11:16:51 pm »

Can I post something in CP if I'm not the one that created it? Too bad, I'm going to anyway.

I saw this bewildering collection of hashes, parentheses, and gibberish. Foolishly, not considering the security risk of running code when I have no idea what it does, I copy it into Leafpad, modify it as per the OP in the link, and save it as a .c file. I compile and run and am surprised at how much info is packed in that short snippet. The code is completely harmless.

Unlike the linked post, the source file is two lines rather than one. Line 1 is the #include and line 2 is the rest of the stuff. Copy everything to <somefile>.c.
Code: [Select]
gcc <somefile>.c -o <somefile>Then run it. The author is correct when he said he should have waited until Christmas.

Just so this isn't utterly useless, does anyone else have any examples of such practices?
Logged

Puzzlemaker

  • Bay Watcher
    • View Profile
Re: Unnecessary Obfuscation
« Reply #1 on: September 14, 2009, 10:32:41 am »

Wow.

That's impressive.

And what does it do?
Logged
The mark of the immature man is that he wants to die nobly for a cause, while the mark of the mature man is that he wants to live humbly for one.

Mephisto

  • Bay Watcher
    • View Profile
Re: Unnecessary Obfuscation
« Reply #2 on: September 14, 2009, 10:40:26 am »

It's quite boring. All it does is print out the full "Twelve Days of Christmas" song.
Logged

Puzzlemaker

  • Bay Watcher
    • View Profile
Re: Unnecessary Obfuscation
« Reply #3 on: September 14, 2009, 10:49:06 am »

H... How?

I don't... see... twelve days of Christmas...   ???
Logged
The mark of the immature man is that he wants to die nobly for a cause, while the mark of the mature man is that he wants to live humbly for one.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Unnecessary Obfuscation
« Reply #4 on: September 14, 2009, 01:26:40 pm »

H... How?

I don't... see... twelve days of Christmas...   ???

I wouldn't know how to begin de-ciphering it, but in quick look over I saw what appears to be a call to main(), that and the fact that main()'s first line is a return statement tells me that there's some recursion going on there.
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Puzzlemaker

  • Bay Watcher
    • View Profile
Re: Unnecessary Obfuscation
« Reply #5 on: September 14, 2009, 02:12:18 pm »

Is... Is that a variable called _?

And you're right, it is recursive.  Interesting...

It also uses copious amounts of that freaking shorthand if statements.  You know, the Blah?Blah:Blah things. 

I don't get what all the #'s are though... that part is really confusing me.  If anyone could shed light on that, that would be great.

I also can't figure out where the actually printing to the screen is... maybe that putchar?  Hmm...
Logged
The mark of the immature man is that he wants to die nobly for a cause, while the mark of the mature man is that he wants to live humbly for one.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Unnecessary Obfuscation
« Reply #6 on: September 15, 2009, 09:46:06 am »

Is... Is that a variable called _?

From what I've seen, that's fairly common in these sort of things.

And I love ?: constructs, but I do try to avoud them when I can. They do make code a bit harder to read.
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Derakon

  • Bay Watcher
    • View Profile
Re: Unnecessary Obfuscation
« Reply #7 on: September 15, 2009, 10:44:11 am »

If you want to see more code like this, check out the International Obfuscated C Contest. Specifically, this page has previous winners.
Logged
Jetblade - an open-source Metroid/Castlevania game with procedurally-generated levels