Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 8th, 2005, 1:27 PM   #1
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Nice and obfuscated

Well since Scorpions4ever had come with a modified version of one posted at ioccc.org I thought it would be nice to try and deobfuscate one which still works on my (V)C-compiler, which is configured at warning level 3. (So no errors at this level allowed)


Obfuscated:
#define P(X)j=write(1,X,1)
#define C 39
int M[5000]={2},*u=M,N[5000],R=22,a[4],l[]={0,-1,C-1,-1},m[]={1,-C,-1,C},*b=N,
*d=N,c,e,f,g,i,j,k,s;main(){for(M[i=C*R-1]=24;f|d>=b;){c=M[g=i];i=e;for(s=f=0;
s<4;s++)if((k=m[s]+g)>=0&&k<C*R&&l[s]!=k%C&&(!M[k]||!j&&c>=16!=M[k]>=16))a[f++
]=s;if(f){f=M[e=m[s=a[rand()/(1+2147483647/f)]]+g];j=j<f?f:j;f+=c&-16*!j;M[g]=
c|1<<s;M[*d++=e]=f|1<<(s+2)%4;}else e=d>b++?b[-1]:e;}P(" ");for(s=C;--s;P("_")
)P(" ");for(;P("\n"),R--;P("|"))for(e=C;e--;P("_ "+(*u++/8)%2))P("| "+(*u/4)%2
);}


Deobfuscated
#define P(X)j=write(1,X,1)
#define C 39

int M[5000] = {2};
int *u = M,N[5000];
int R = 22;
int a[4];
int l[] = {0,-1,C-1,-1};
int m[] = {1,-C,-1,C};
int *b = N;
int *d=N;
int c,e,f,g,i,j,k,s;

main()
{
	for( M[i=C*R-1] = 24; f|d >= b;)
	{
		c=M[g=i];
		i=e;
		for( s=f=0; s<4; s++ )
			if( (k=m[s]+g)>=0 && k<C*R&&l[s]!=k%C && (!M[k] || !j && c >= 16 != M[k] >= 16))
			a[f++] = s;
		if(f)
		{
			f=M[e=m[s=a[rand()/(1+2147483647/f)]]+g];
			j = j < f ? f : j;
			f += c&-16*!j;
			M[g] = c|1<<s;
			M[*d++=e]=f|1<<(s+2)%4;
		}
		else
		e = d > b++ ? b[-1]: e;
	}
	P(" ");
	for(s=C; --s; P("_"))
		P(" ");
	for(; P("\n"),R--; P("|"))
		for(e = C; e--; P("_ "+(*u++/8)%2))
			P("| " + (*u/4)%2);
}
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Jun 8th, 2005, 1:46 PM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Oo oo I got another one deobfuscated:


Obfuscated:
#include "stdio.h"
#define xyxx char
#define xyyxx putchar
#define xyyyxx while
#define xxyyyx int
#define xxxyyx main
#define xyxyxy if
#define xyyxyy '\n'
xyxx *xyx [] = {
"]I^x[i]k\\I^o[IZ~\\IZ~[I^|[I^l[I^j[I^}[I^n[i]m\\I]h",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~[IZ|_IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm_IZh",
"]IZx\\IZx[I^k[I\\o]IZ~\\IZ~\\I]|[IZl_I^j]IZ}]I^n[IZm\\IZm_IZh",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~_IZ|[IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm]IZh",
"]I^x[i]k\\IZo_I^~[I^|[I^l[IZj\\IZj]IZ}]I^n[i]m^IZh",'\0'};/*xyyxyxyxxxyxxxyy*/
xyxx *xyyx; xxyyyx xyyyx,xyyyyx,xyyyyyx=0x59,xyyyyyyx=0x29,/*yxxyxyyyxxyyyxyy*/
xxyx=0x68;xxxyyx(){xyyyyx=0;xyyyxx(xyx[xyyyyx]){xyyx=xyx[xyyyyx++];/*xyyyxxyx*/
xyyyxx(*xyyx){xyyyx= *xyyx++-xyyyyyx;xyyyxx(xyyyx--)xyyxx(*xyyx-xyyyyyyx);/*x*/
xyxyxy(*xyyx==xxyx)xyyxx(xyyxyy);*xyyx++;}}}/*xyxyxyyyyxxyxxxyyyxyyyxyxxyyy*/


Deobfuscated:
#include <stdio.h>

char *crypt [] =
{
"]I^x[i]k\\I^o[IZ~\\IZ~[I^|[I^l[I^j[I^}[I^n[i]m\\I]h",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~[IZ|_IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm_IZh",
"]IZx\\IZx[I^k[I\\o]IZ~\\IZ~\\I]|[IZl_I^j]IZ}]I^n[IZm\\IZm_IZh",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~_IZ|[IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm]IZh",
"]I^x[i]k\\IZo_I^~[I^|[I^l[IZj\\IZj]IZ}]I^n[i]m^IZh",'\0'
};
char *array;
int one, two, three=0x59, four=0x29, five=0x68;
main()
{
	two = 0;
	while(crypt[two])
	{
		array=crypt[two++];
		while(*array)
		{
			one = *array++ - three;
			while(one--)
				putchar(*array-four);
			if(*array==five)
				putchar('\n');
			*array++;
		}
	}
}
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates

Last edited by nnxion; Jun 8th, 2005 at 1:49 PM.
nnxion is offline   Reply With Quote
Old Jun 8th, 2005, 3:19 PM   #3
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Go for my sig It's not that bad. It's in C++ btw.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Jun 8th, 2005, 4:01 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Is there a program that replaces #defined things with their pre-processed equivalents?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 8th, 2005, 4:29 PM   #5
Gilward Kukel
Newbie
 
Join Date: Jun 2005
Location: Vienna, Austria
Posts: 15
Rep Power: 0 Gilward Kukel is on a distinguished road
Quote:
Originally Posted by Ooble
Is there a program that replaces #defined things with their pre-processed equivalents?
the C compiler with the E option.
for instance (on Linux):
gcc -E program.c >output.c
Gilward Kukel is offline   Reply With Quote
Old Jun 8th, 2005, 5:59 PM   #6
Scorpions4ever
Programmer
 
Join Date: Jun 2005
Posts: 86
Rep Power: 4 Scorpions4ever is on a distinguished road
Quote:
Originally Posted by Ooble
Is there a program that replaces #defined things with their pre-processed equivalents?
man cpp
Scorpions4ever is offline   Reply With Quote
Old Jun 8th, 2005, 6:57 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Danke.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 8th, 2005, 7:02 PM   #8
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
rofl... the C Preprocesser (cpp)
Same thing the compiler uses to do it!
uman is offline   Reply With Quote
Old Jun 9th, 2005, 3:35 AM   #9
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Don't leave the include files though when using the -E option, it will get you a lot of things you don't want.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Jun 9th, 2005, 4:46 AM   #10
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
*gives uni lecturer obfuscated c code*

*uni lecturer fails code due to not understanding it*

*i cry*
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC