r/obfuscatedcode • • Apr 19 '13

(C) My first piece of obfuscated code

#include <stdio.h>
void main(void){int _,q=-('?'&1),u,z=-q
<<5,vb='%'&(z>>2),s=z&2,i=1+q;char*__=(
(u= q),"int32** icnf[n]:ic()INT:==()IN"
"T sub//_{ *strDVD i++,k++ --d;___:#ke"
"zz=D MadCatz AARDM4N:*#2468#");char _x
[z >> 1];_+=q;while(i<z>>1){_x[i++]=0;}
while(q++,u++,__[q]!=0){if(z==__[q]||__
[q]==2*0x1d)u=vb-1,s++;_x[s]+=((__[q]&1
)<<(6-u));}puts(_x);/*6809/19.Apr.13*/}

Can you guess what it does? Kudos to anyone who can figure out the decryption method, it shouldn't be too hard.

6 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/Farlo1 Jul 28 '13

I have literally no knowledge on obfuscating code, how are you able to form "Hello World" from seemingly random strings?

1

u/Elite6809 Jul 28 '13 edited Jul 28 '13

Basically, say if the binary for an ascii letter eg. H is 1001000, then you choose 7 letters (one per bit). Each letter's last ascii bit makes up each consecutive bit of the letter you want.

That's not the best explanation, so let me explain it. Remember the binary value 1001000, let's look at the first string:

int32**

Let's break each letter of that down into the binary:

i: 01101001
n: 01101110
t: 01110100
3: 00110011
2: 00110010
*: 00101010
*: 00101010

Recognise any binary patterns in those last digits? It makes up the letter 'H' in binary. I could have chosen any other letters - even 3223222 for the last example, but choosing other letters made it more confusing. Security by obscurity isn't always great but it was appropriate then. If you want any further explanation feel free to ask.