home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / dde / oc / Posting < prev   
Encoding:
Text File  |  1994-11-10  |  4.7 KB  |  89 lines

  1.  
  2. Newsgroups: alt.hackers
  3. From: nobody@nowhere.nohow.com (nobody)
  4. Subject: Re: Ugly C translator
  5. Organization: Anonymous Posters `R` Us.
  6. Xdisclaimer: No attempt has been made to authenticate the user.
  7. Lines: 76
  8.  
  9.  
  10. In article <1994Sep5.164621@georges.montefiore.ulg.ac.be> 
  11. boigelot@georges.montefiore.ulg.ac.be (Bernard Boigelot) writes:
  12. >Has anyone ever heard about a program that could translate ordinary C into
  13. >'unreadable C' (while preserving the semantics of the program undergoing the
  14. >translation) ?. By 'unreadable C', I mean a style of encoding that would make
  15. >it very difficult to grasp the logical structure and the algorithms of the
  16. >program. I'm in urgent need of such a tool.
  17.  
  18. ObHack: This post. Err... I mean this poster. I was bored one day and
  19. wrote this little post forger in perl. I also wrote the forged post
  20. canceler on the offchance you need to forge a cancel for your own
  21. or someone eles's article. 
  22.  
  23. Here is something I picked up off the net a while ago.
  24.  
  25. From: denny@cd.com (Dennis Cronin)
  26. Subject: OOP (Obfuscated Obfuscating Program)
  27. Message-ID: <CE67v5.H2J@cd.com>
  28. Summary: Program removes comments and white space from C code
  29. Keywords: obfuscated
  30. Organization: Central Data Corp.
  31. Date: Thu, 30 Sep 1993 14:21:04 GMT
  32. Lines: 55
  33.  
  34. Here's a program that removes comments and most white space from C code
  35. while still leaving it compilable.  Commented source available for free
  36. via email.
  37. */
  38.  
  39. #include <stdio.h>
  40. typedef void (*fptr)(); typedef void (*actn)(); struct 
  41. fsmcell { actn action; unsigned char nextstate; }; void main(); void fsm(); 
  42. void prefsm(); int premap(); int map(); void null(); void outc(); void W(); 
  43. void Wc(); void SL(); void SLc(); void err(); void pchar(); void NL(); void 
  44. NLc(); void BSLc(); void WSL(); void WSLc(); void NLSL(); void NLSLc(); static 
  45. struct fsmcell prestab[6][4] = { outc,1, null,0, outc,3, outc,1, null,4, 
  46. null,2, outc,1, outc,1, Wc,1, null,2, NLc,3, Wc,1, null,5, outc,0, outc,3, 
  47. outc,3, BSLc,1, null,1, BSLc,1, BSLc,1, BSLc,3, null,3, BSLc,3, BSLc,3 }; 
  48. static struct fsmcell stab[16][8] = { null,2, outc,0, null,1, null,9, outc,5, 
  49. outc,7, outc,0, outc,0, null,10, Wc,0, null,1, null,9, Wc,5, Wc,7, Wc,0, Wc,0 
  50. , err,0, null,3, SL,1, SL,9, err,0, err,0, err,0, SLc,0 , null,3, null,4, 
  51. null,3, null,3, null,3, null,3, null,3, null,3, null,0, null,4, null,3, 
  52. null,3, null,3, null,3, null,3, null,3, outc,5, outc,5, outc,5, err,0, outc,0, 
  53. outc,5, outc,6, outc,5, outc,5, outc,5, outc,5, err,5, outc,5, outc,5, outc,5, 
  54. outc,5, outc,7, outc,7, outc,7, err,0, err,0, outc,0, outc,8, outc,7, outc,7, 
  55. outc,7, outc,7, err,7, outc,7, outc,7, outc,7, outc,7, null,13, NLc,0, null,9, 
  56. null,9, NLc,5, NLc,7, NLc,0, NLc,0, err,0, null,11, WSL,1, WSL,9, err,0, 
  57. err,0, err,0, WSLc,0, null,11, null,12, null,11, null,11, null,11, null,11, 
  58. null,11, null,11, null,1, null,12, null,11, null,11, null,11, null,11, 
  59. null,11, null,11, err,0, null,14, NLSL,1, NLSL,9, err,0, err,0, err,0, 
  60. NLSLc,0, null,14, null,15, null,14, null,14, null,14, null,14, null,14, 
  61. null,14, null,9, null,15, null,14, null,14, null,14, null,14, null,14, null,14 
  62. }; void main() { int c; while(c = getchar(), c != EOF) prefsm(c); } void 
  63. prefsm(c) int c; { static unsigned char state = 0; struct fsmcell *cp; int 
  64. input; input = premap(c); cp = &prestab[state][input]; (*cp->action)(c,fsm); 
  65. state = cp->nextstate; } int premap(c) int c; { switch(c) { case '\\': 
  66. return(0); case '\n': return(1); case '#': return(2); default: return(3); } } 
  67. void fsm(c) int c; { static unsigned char state = 0; struct fsmcell *cp; int 
  68. input; input = map(c); cp = &stab[state][input]; (*cp->action)(c,pchar); state 
  69. = cp->nextstate; } int map(c) int c; { switch(c) { case '/': return(0); case 
  70. '*': return(1); case ' ': case '\t': return(2); case '\n': return(3); case 
  71. '\"': return(4); case '\'': return(5); case '\\': return(6); default: 
  72. return(7); } } void null(c,vec) int c; fptr vec; { } void outc(c,vec) int c; 
  73. fptr vec; { (*vec)(c); } void W(c,vec) int c; fptr vec; { (*vec)(' '); } void 
  74. Wc(c,vec) int c; fptr vec; { (*vec)(' '); (*vec)(c); } void SL(c,vec) int c; 
  75. fptr vec; { (*vec)('/'); } void SLc(c,vec) int c; fptr vec; { (*vec)('/'); 
  76. (*vec)(c); } void err(c,vec) int c; fptr vec; { printf("\nError\n"); exit(1); 
  77. } void pchar(c) int c; { putchar(c); } void NL(c,vec) int c; fptr vec; { 
  78. (*vec)('\n'); } void NLc(c,vec) int c; fptr vec; { (*vec)('\n'); (*vec)(c); } 
  79. void BSLc(c,vec) int c; fptr vec; { (*vec)('\\'); (*vec)(c); } void WSL(c,vec) 
  80. int c; fptr vec; { (*vec)(' '); (*vec)('/'); } void WSLc(c,vec) int c; fptr 
  81. vec; { (*vec)(' '); (*vec)('/'); (*vec)(c); } void NLSL(c,vec) int c; fptr 
  82. vec; { (*vec)('\n'); (*vec)('/'); } void NLSLc(c,vec) int c; fptr vec; { 
  83. (*vec)('\n'); (*vec)('/'); (*vec)(c); }
  84.  
  85.  
  86. ----
  87.  
  88. ANSI & more Acorn friendly source in !OC.c.oc - still obfuscated though...
  89.