home *** CD-ROM | disk | FTP | other *** search
-
- Newsgroups: alt.hackers
- From: nobody@nowhere.nohow.com (nobody)
- Subject: Re: Ugly C translator
- Organization: Anonymous Posters `R` Us.
- Xdisclaimer: No attempt has been made to authenticate the user.
- Lines: 76
-
-
- In article <1994Sep5.164621@georges.montefiore.ulg.ac.be>
- boigelot@georges.montefiore.ulg.ac.be (Bernard Boigelot) writes:
- >Has anyone ever heard about a program that could translate ordinary C into
- >'unreadable C' (while preserving the semantics of the program undergoing the
- >translation) ?. By 'unreadable C', I mean a style of encoding that would make
- >it very difficult to grasp the logical structure and the algorithms of the
- >program. I'm in urgent need of such a tool.
-
- ObHack: This post. Err... I mean this poster. I was bored one day and
- wrote this little post forger in perl. I also wrote the forged post
- canceler on the offchance you need to forge a cancel for your own
- or someone eles's article.
-
- Here is something I picked up off the net a while ago.
-
- From: denny@cd.com (Dennis Cronin)
- Subject: OOP (Obfuscated Obfuscating Program)
- Message-ID: <CE67v5.H2J@cd.com>
- Summary: Program removes comments and white space from C code
- Keywords: obfuscated
- Organization: Central Data Corp.
- Date: Thu, 30 Sep 1993 14:21:04 GMT
- Lines: 55
-
- Here's a program that removes comments and most white space from C code
- while still leaving it compilable. Commented source available for free
- via email.
- */
-
- #include <stdio.h>
- typedef void (*fptr)(); typedef void (*actn)(); struct
- fsmcell { actn action; unsigned char nextstate; }; void main(); void fsm();
- void prefsm(); int premap(); int map(); void null(); void outc(); void W();
- void Wc(); void SL(); void SLc(); void err(); void pchar(); void NL(); void
- NLc(); void BSLc(); void WSL(); void WSLc(); void NLSL(); void NLSLc(); static
- struct fsmcell prestab[6][4] = { outc,1, null,0, outc,3, outc,1, null,4,
- null,2, outc,1, outc,1, Wc,1, null,2, NLc,3, Wc,1, null,5, outc,0, outc,3,
- outc,3, BSLc,1, null,1, BSLc,1, BSLc,1, BSLc,3, null,3, BSLc,3, BSLc,3 };
- static struct fsmcell stab[16][8] = { null,2, outc,0, null,1, null,9, outc,5,
- outc,7, outc,0, outc,0, null,10, Wc,0, null,1, null,9, Wc,5, Wc,7, Wc,0, Wc,0
- , err,0, null,3, SL,1, SL,9, err,0, err,0, err,0, SLc,0 , null,3, null,4,
- null,3, null,3, null,3, null,3, null,3, null,3, null,0, null,4, null,3,
- null,3, null,3, null,3, null,3, null,3, outc,5, outc,5, outc,5, err,0, outc,0,
- outc,5, outc,6, outc,5, outc,5, outc,5, outc,5, err,5, outc,5, outc,5, outc,5,
- outc,5, outc,7, outc,7, outc,7, err,0, err,0, outc,0, outc,8, outc,7, outc,7,
- outc,7, outc,7, err,7, outc,7, outc,7, outc,7, outc,7, null,13, NLc,0, null,9,
- null,9, NLc,5, NLc,7, NLc,0, NLc,0, err,0, null,11, WSL,1, WSL,9, err,0,
- err,0, err,0, WSLc,0, null,11, null,12, null,11, null,11, null,11, null,11,
- null,11, null,11, null,1, null,12, null,11, null,11, null,11, null,11,
- null,11, null,11, err,0, null,14, NLSL,1, NLSL,9, err,0, err,0, err,0,
- NLSLc,0, null,14, null,15, null,14, null,14, null,14, null,14, null,14,
- null,14, null,9, null,15, null,14, null,14, null,14, null,14, null,14, null,14
- }; void main() { int c; while(c = getchar(), c != EOF) prefsm(c); } void
- prefsm(c) int c; { static unsigned char state = 0; struct fsmcell *cp; int
- input; input = premap(c); cp = &prestab[state][input]; (*cp->action)(c,fsm);
- state = cp->nextstate; } int premap(c) int c; { switch(c) { case '\\':
- return(0); case '\n': return(1); case '#': return(2); default: return(3); } }
- void fsm(c) int c; { static unsigned char state = 0; struct fsmcell *cp; int
- input; input = map(c); cp = &stab[state][input]; (*cp->action)(c,pchar); state
- = cp->nextstate; } int map(c) int c; { switch(c) { case '/': return(0); case
- '*': return(1); case ' ': case '\t': return(2); case '\n': return(3); case
- '\"': return(4); case '\'': return(5); case '\\': return(6); default:
- return(7); } } void null(c,vec) int c; fptr vec; { } void outc(c,vec) int c;
- fptr vec; { (*vec)(c); } void W(c,vec) int c; fptr vec; { (*vec)(' '); } void
- Wc(c,vec) int c; fptr vec; { (*vec)(' '); (*vec)(c); } void SL(c,vec) int c;
- fptr vec; { (*vec)('/'); } void SLc(c,vec) int c; fptr vec; { (*vec)('/');
- (*vec)(c); } void err(c,vec) int c; fptr vec; { printf("\nError\n"); exit(1);
- } void pchar(c) int c; { putchar(c); } void NL(c,vec) int c; fptr vec; {
- (*vec)('\n'); } void NLc(c,vec) int c; fptr vec; { (*vec)('\n'); (*vec)(c); }
- void BSLc(c,vec) int c; fptr vec; { (*vec)('\\'); (*vec)(c); } void WSL(c,vec)
- int c; fptr vec; { (*vec)(' '); (*vec)('/'); } void WSLc(c,vec) int c; fptr
- vec; { (*vec)(' '); (*vec)('/'); (*vec)(c); } void NLSL(c,vec) int c; fptr
- vec; { (*vec)('\n'); (*vec)('/'); } void NLSLc(c,vec) int c; fptr vec; {
- (*vec)('\n'); (*vec)('/'); (*vec)(c); }
-
-
- ----
-
- ANSI & more Acorn friendly source in !OC.c.oc - still obfuscated though...
-