Sunday, January 19, 2014

Another Obfuscated C code

hey guys ,

Just found another simple C obfuscated code ,and this one was simpler than the others ,but was kinda different ,here it is :

Obfuscated Code

I'll try to just mention the obfuscated points at it ,I won't walk through it step by step ,as it's very simple and easy to trace and understand .

Code After removing spaces

-Line 12 : c=c^10 part is used to switch variable (c) between values 42 and 32
-32 is the decimal ascii for whitespace character .
-42 is the decimal ascii for asterisk character .
-Line 4 : (s) array is used as follows :
  -even indexed numbers are used for displaying asterisks .
  -odd indexed numbers are used for displaying spaces .
  -negative numbers are used to print a new line feed .
  -58 is used to display 10 spaces ,it's just an additional way to obfuscate the   code ,we can replace every 58 element by inserting 10 instead ( doing this ,will force us to remove the s[i]&(9+6) part on line 19 in the inner for loop condition ,so now it should be s[i] only ) .
-Line 20 : function p() is given any value as a parameter ,since it's doing nothing with this parameter ( we can even remove the parameter in function definition ) .
-Line 28 : function f() is useless ,since it's not called anywhere in the code .
-Lines 32,30,15 : some garbage are added just to obfuscate the code .

And here is the last deobfuscated version of the code :

Deobfuscated Code

Enjoy .