Obfuscated C programs (stolen from Bernhard Münzer)

Here are some C programs I found on the net.
Try to guess what they do before you compile and run them :-)


Here is my current signature file:

int m,u,e=0;float l,_,I;main(){for(;e<1863;putchar((++e>923&&952>
e?60-m:u)["\n)ed.fsg@eum(rezneuM drahnreB"]))for(u=_=l=0;(m=e%81)
<80&&I*l+_*_<6&&20>++u;_=2*l*_+e/81*.09-1,l=I)I=l*l-_*_-2+m/27.;}

This is how it looked a year ago

(and it looks more like the Mandelbrot program I found on the net - unfortunately I don't have the original any more)
main(){char*c=" _.+=#\n)rezneuM drahnreB(ed.fsg@eum";int x,t,y;float a,
b,d;for(y=0;y<25;y++){for(x=0;x<80;x++){t=b=d=0;do{a=b*b-d*d-2.1+.035*x
;d=2*b*d+.088*y-1.1;b=a;t++;}while(t<32&&b*b+d*d<4);putchar(c[x>79?6:y>
23&&x<28?34-x:t>31?0:t>>4?5:t>>3?4:t>>2?3:t>>1?2:1]);}}} /*mue@gsf.de*/

Enter an integer after calling this program:

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]     
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}

Here's another version if the above does not work:

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]
|6<rand()<<27||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}

Merry Christmas !

#include <stdio.h>
#define O (b=b?b-1:(p++,5),*p&1<<b)
#define o O?O
char*p,j=2,b,c;e(n){for(p="|'8I0>+@{=#_P0-]PV.]F>TM!YK'?? |T\"Z8}aE<&D-!:-T'\"\
O<~cG5$,<2'#;/UI.0{d^HV6817-2F95-T7X|c^/1XB]*)3WHG0/0}dN>G RMZB.12.P] ~hM^J\\[\
<R^ (7;)R9A78{gU!:N)E5OPUR><29A6|e&9V;E[Q:,S1.P] }eES.$Z):B.*O+$G_ ~fWU8)75?I#\
75?WHN0{jE=]<V*1]JI#5VK)R9A6~J5X9X#69/+VX4 =S%!X-[)OE #1XRZ\"?~%^-#Dz&M\\RST|%\
G66*~&^HV0> {%^-8_P}%N>FO(}'M^JQ=z&U!:O(J{%&9G4|%ERO(~(WU8)G4{'E=]^G4",b=n;*p++
<122||--b;);c=*p;while(--c>31&&c!=79)putchar(44+(o?o?o?-34:68:O?60:74:O?64:o?o?
2:54:O?23:63:77:O?55:o?76:15:35:-12:o?61:O?56:65:O?66:53:o?o?O?75:58:0:70:57:o?
71:o?73:1:67:O?72:59));c>32?e(n-1):0;}main(){while(++j<15)e(1),e(13+j),e(15),e(
j-(j<4));}

#include <stdio.h>
main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_
,main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&
t==2?_<13?main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,"@\
n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n\
{n+,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+\
#n';d}rw' i;# ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[\
{nl]'/w#q#n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r\
'}{nlwb!/*de}'c ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'\
rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/"):t<-50?_==*a?
putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1):0<t\
?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,"!ek;dc i@bK'(q)-\
[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

Here you have to enter an odd number on the command line:

/*-----Jos------*/ main(o,O0)char**O0;{int OO,O;O=--o?atoi(O0[!0]):!
/* cc .sig      */ 0;for(o=((OO=O*O)-O+!0+!0)>>!0;OO;o+=((--OO%O)?-!
/* a.out oddnum */ 0:((((o-!0)%O)?O:0)+!0))-(((o-!0)%O)?O:0)){printf
/*--jos@and.nl--*/ ("\n%*d "+!!(OO%O),!0<<!0<<!0,o+=(o<!0)?O*O:0);}}

Pi in the sky:

int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;for(;d=0,g=c*2;c
-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);}

And another one:

int putchar(int);int main(int a,char*b[]){static double c,d,e,f,g;r\
eturn a?a<0?g=c*c+d*d,f=.5*(c+g/c),main(0,0),c=.5*(c+f),d*=.5,main(a
+1,b):b[a]?(a=c)>c&&a--,c-=a,c*=10,putchar(a+'0'),*b[1]?putchar(*b[1
]++):(d*=.1),d+1!=1?main(1,b):putchar('\n'),0:(c=d=.5,b[1]=".",main(
-32,b),c=2/c,d=.01,main(1,b)):b||(e=f,f=.5*(f+g/f),f<e&&main(0,0));}

No need to compile this anyway :-)

char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}

You need UNIX for this one:

long h[4];t(){h[3]-=h[3]/3000;setitimer(0,h,0);}int c,d,l,v[]={(int)t,0,2},w,s,I,K
=0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9,-1,1,
12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,10,-12,
1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12,
12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i]
){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf(
"\033[%dm  "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+
n[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char*
*V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i<
25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v,
0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+
12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){
for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c
=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G
(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock(
8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=
0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen(
"stty -cbreak echo stop \023;cat - HI|sort -rn|head -20>/tmp/$$;mv /tmp/$$ HI\
;cat HI","w");fprintf(d,"%4d on level %1d by %s\n",w,l,getlogin());pclose(d);}

Now this source is fun to read

char*lie;

	double time, me= !0XFACE,

	not; int rested,   get, out;

	main(ly, die) char ly, **die ;{

	    signed char lotte,


dear; (char)lotte--;

	for(get= !me;; not){

	1 -  out & out ;lie;{

	char lotte, my= dear,

	**let= !!me *!not+ ++die;

	    (char*)(lie=


"The gloves are OFF this time, I detest you, snot\n\0sed GEEK!");

	do {not= *lie++ & 0xF00L* !me;

	#define love (char*)lie -

	love 1 *!(not= atoi(let

	[get -me?

	    (char)lotte-


(char)lotte: my- *love -

	'I'  -  *love -  'U' -

	'I'  -  (long)  - 4 - 'U' ])- !!

	(time  =out=  'a'));} while( my - dear

	&& 'I'-1l  -get-  'a'); break;}}

	    (char)*lie++;


(char)*lie++, (char)*lie++; hell:0, (char)*lie;

	get *out* (short)ly   -0-'R'-  get- 'a'^rested;

	do {auto*eroticism,

	that; puts(*( out

	    - 'c'

-('P'-'S') +die+ -2 ));}while(!"you're at it");


for (*((char*)&lotte)^=

	(char)lotte; (love ly) [(char)++lotte+

	!!0xBABE];){ if ('I' -lie[ 2 +(char)lotte]){ 'I'-1l ***die; }

	else{ if ('I' * get *out* ('I'-1l **die[ 2 ])) *((char*)&lotte) -=

	'4' - ('I'-1l); not; for(get=!


get; !out; (char)*lie  &  0xD0- !not) return!!

	(char)lotte;}


(char)lotte;

	do{ not* putchar(lie [out

	*!not* !!me +(char)lotte]);

	not; for(;!'a';);}while(

	    love (char*)lie);{


register this; switch( (char)lie

	[(char)lotte] -1 *!out) {

	char*les, get= 0xFF, my;
 case' ':

	*((char*)&lotte) += 15; !not +(char)*lie*'s';

	this +1+ not; default: 0xF +(char*)lie;}}}

	get - !out;

	if (not--)

	goto hell;

	    exit( (char)lotte);}

And here's something to keep your PostScript printer busy

153 540 translate .12 setlinewidth/d{def}def/i 50 d/x .1 d/y .1 d/m{mul}d/a{add}
d/e{exch}d/s{sub}d 1 1 60000{pop .4 6 1 x x m y y m a a div s 57.2958 m dup/u e
sin d/v e cos d 1 .9 x v m y u m s m a/y .9 x u m y v m a m d/x e d i 0 eq{x 175
m y 175 m moveto 0 1 rlineto stroke}{i/i e 1 s d}ifelse}for showpage %%End

Bernhard Münzer September 12, 1994


Visited Many, many times since 30.August 1999.
, last updated: 19.Jul.2002