Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP Newsgroups: comp.sources.misc Subject: Submission for comp-sources-misc Message-ID: <681@aurora.UUCP> Date: Thu, 21-May-87 05:00:59 EDT Article-I.D.: aurora.681 Posted: Thu May 21 05:00:59 1987 Date-Received: Mon, 25-May-87 06:36:55 EDT References: <8705141214.AA19848@mstar.UUCP> Sender: allbery@ncoast.UUCP Organization: NASA Ames Research Center, Mt. View, Ca. Lines: 144 Approved: allbery@ncoast.UUCP # "Watergate is a gnat compared to the Bell System." -- from the suicide note of T. O. Gravitz, exec VP, pre-divestiture Southern Bell Mr. Fox's gem is herewith complete. Notes: (a) If this were a submission to JACM, it would be entitled "Functional Obfuscation in a Self-Decompressing Shell Archive." (b) On the part of the receiver, assumes access to nothing except 'cc', a simple 'sh', and 'cat'. Some non-Unix systems might even qualify. (c) Assumes the sender has a favorite 'shar' -- some pass binary, some do directories. Whatever. Also 'compress' and 'btoa' (better'n "uudecode") from mod.sources, volume 2. (d) Aside from some superfluous demonstration test files, the sharchive below contains 'shark', which is the main constructo-thing itself. If the name is already taken, call it 'sharp', or 'shard'. (e) Making it do "cc -O" may be counterproductive. (f) What we have here is not minimal. -- James A. Woods (ames!jaw) ------------------------------- cut here -------------------------------- #!/bin/sh echo "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica" > /dev/null echo compiling decoders ... cat > atob.c <<'ZZ' #include #define R register #define t85(x) ((((((x<<2)+x)<<2)+x)<<2)+x) FILE *tf;long CX,Cs,CR,w,B; F(){fprintf(stderr,"bad format or Cs to atob\n"); exit(1);} d(c)R c;{if(c=='z'){if(B){F();}else{b(0);b(0);b(0);b(0);}}else if (c>='!'&&(c<'!'+85)){if(!B){w=c-'!';++B;}else if(B<4){w=t85(w);w+=c-'!';++B;} else{w=t85(w)+c-'!';b((int)((w>>24)&255));b((int)((w>>16)&255));b((int) ((w>>8)&255));b((int)(w&255));w=B=0;}}else F();} b(c)R c;{CX^=c;Cs+=c;Cs+=1; if(CR&0x80000000){CR<<=1;CR+=1;}else{CR<<=1;}CR+=c;putc(c,tf);} main(gc,v)char **v;{R c;R long i;char tn[99],Q[99];long n1,n2,oX,os,oR; if(gc!=1){fprintf(stderr,"bad args to %s\n",v[0]);exit(2);}sprintf(tn, "/usr/tmp/atob.%x",getpid());tf=fopen(tn,"w+");if(tf==NULL)F();unlink(tn); for(;;){if(fgets(Q,99,stdin)==NULL)F();if(!strcmp(Q,"xbtoa Begin\n"))break;} while((c=getchar())!=EOF){if(c=='\n')continue;else if(c=='x')break;else d(c);} if(scanf("btoa End N %ld %lx E %lx S %lx R %lx\n",&n1,&n2,&oX,&os,&oR)!=5) {F();}if(n1!=n2||oX!=CX||os!=Cs||oR!=CR){F();} else{fseek(tf,0L,0);for(i=n1;--i>=0;)putchar(getc(tf));exit(0);}} ZZ cc -o atob atob.c cat > zcat.c <<'ZZ' #include #define d define #d G getchar() #d I if #d H(n) ((C*)h)[n] #d C char #d U unsigned long #d u unsigned short #d R register C* #d B(n) (1<<(n)) #d V(a,b) (a&(B(b)-1)) #d E {fprintf(stderr,"Bad COMPRESS file format\n");exit(1);} int i,q,b,n,k=16,e=128,j=0,O=0,S=0;u t[69001];long o,v,c,m,M=B(16),f=0;U h[ 69001];C D[16];long g(){R p=D;I(j>0||O>=S||f>m){I(f>m)m= ++n==k?M:B(n)-1;I(j>0) m=B(n=9)-1,j=0;S=fread(D,1,n,stdin);I(S<=0)return-1;O=0;S=(S<<3)-n+1;}q=O;b=n;p +=q>>3;q&=7;c=V(*p++>>q,8-q);q=8-q;b-=q;I(b>=8)c|=(*p++&255)< 16)E;z();exit(0);}z(){long w;R s;m=B(n=9)-1;for(w=255;w>=0;w--)t[w]=0,H(w)=(C)w ;f=e?257:256;i=o=g();I(o==-1)return;putchar((C)i);s=(C*)&H(B(16));while((w=g()) >-1){I(w==256&&e){for(w=255;w>=0;w--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