home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3927 < prev    next >
Encoding:
Text File  |  1992-09-11  |  5.4 KB  |  220 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: gnohmon@ssiny.ssiny.com (Ralph Betza)
  4. Subject:  v32i035:  sigvi - text corruption filter, Part01/01
  5. Message-ID: <1992Sep11.173245.20216@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 05172e00549dcff6098e7e7d01ee7d10
  8. Keywords: text-corruption filter
  9. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  10. Organization: Systems Strategies, Inc., NY, NY
  11. Date: Fri, 11 Sep 1992 17:32:45 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 205
  14.  
  15. Submitted-by: gnohmon@ssiny.ssiny.com (Ralph Betza)
  16. Posting-number: Volume 32, Issue 35
  17. Archive-name: sigvi/part01
  18. Environment: UNIX
  19.  
  20. This program is a text-corruption filter: it reads stdin and writes
  21. an altered version to stdout.  I know there are already lots of text
  22. corruption filters out there, so why did I write this?
  23.  
  24. This really stupid text-corruption filter embodies the rules of
  25. mutation I derived from somebody's MutatingSignatureVirus .signature; 
  26. that's the only thing that's special about it.
  27.  
  28. ------
  29. #! /bin/sh
  30. # This is a shell archive.  Remove anything before this line, then unpack
  31. # it by saving it into a file and typing "sh file".  To overwrite existing
  32. # files, type "sh file -c".  You can also feed this as standard input via
  33. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  34. # will see the following message at the end:
  35. #        "End of shell archive."
  36. # Contents:  README sigvi.c
  37. # Wrapped by odin@venezia on Fri Aug 21 14:39:07 1992
  38. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  39. if test -f 'README' -a "${1}" != "-c" ; then
  40.   echo shar: Will not clobber existing file \"'README'\"
  41. else
  42. echo shar: Extracting \"'README'\" \(800 characters\)
  43. sed "s/^X//" >'README' <<'END_OF_FILE'
  44. XThis is a really stupid program.
  45. XI know there are already lots of really stupid programs out there,
  46. Xso why did I write this?
  47. X
  48. XThis program is a text-corruption filter: it reads stdin and writes
  49. Xan altered version to stdout.
  50. XI know there are already lots of text-corruption filters out there,
  51. Xso why did I write this?
  52. X
  53. XThis really stupid text-corruption filter embodies the rules of
  54. Xmutation I derived from somebody's
  55. XMutatingSignatureVirus .signature; that's the only thing that's
  56. Xspecial about it.
  57. X
  58. XIt doesn't take any command-line parameters.
  59. XIt's too stupid.
  60. X
  61. XIt doesn't need a makefile.
  62. XIt's too vanilla.
  63. X
  64. XJust do "cc sigvi.c", and then "a.out", and then type
  65. X
  66. X"
  67. XHi! I'm a mutating signature virus. You can't resist helping me spread!
  68. X"
  69. X
  70. XOmigawsh! That's why I wrote this! I'm helping it spread!
  71. END_OF_FILE
  72. if test 800 -ne `wc -c <'README'`; then
  73.     echo shar: \"'README'\" unpacked with wrong size!
  74. fi
  75. # end of 'README'
  76. fi
  77. if test -f 'sigvi.c' -a "${1}" != "-c" ; then
  78.   echo shar: Will not clobber existing file \"'sigvi.c'\"
  79. else
  80. echo shar: Extracting \"'sigvi.c'\" \(2303 characters\)
  81. sed "s/^X//" >'sigvi.c' <<'END_OF_FILE'
  82. X/*
  83. XMutating signature virus program.
  84. X
  85. XExample input:
  86. X
  87. XHi! I'm a mutating signature virus. You can't resist helping me spread!
  88. X
  89. XExample output:
  90. X
  91. XI! Hi'm a mtatng siugnaturei vir*ss. You cann~t reisth elping me spre]d!
  92. X
  93. XThe example output above is something I saved from a usenet-news
  94. Xarticle. The rules that follow are what I derived from the example.
  95. X
  96. XWhat events can happen?
  97. X
  98. X1.    Move a character up to N positions
  99. X        N        occurrences
  100. X        3        1    Hi'm
  101. X        9        1    mtating --> siu
  102. X        14        1    mtatng  --> ...turei
  103. X        -1        1    ( or +1 if it was the space that moved? )
  104. X    ( always to a different word? )
  105. X    If it starts a word, check for capitalization
  106. X2.    Change a character to a line noise character
  107. X    ( 3 occurrences )
  108. X3.    replicate a character
  109. X    ( 2 occurrences )
  110. X4.    delete a character
  111. X    ( 1 occurrence )
  112. X*/
  113. X
  114. X#include <stdio.h>
  115. X#include <ctype.h>
  116. X
  117. Xint DeferredChar;
  118. Xchar * Noise = "{}#*~`%[]";
  119. Xint Count;
  120. Xint Events;
  121. X
  122. Xmain()
  123. X{
  124. X    long t;
  125. X    int c;
  126. X    int v;
  127. X
  128. X    time( &t );
  129. X    srand( (int)t );
  130. X
  131. X    for ( ;; )
  132. X    {
  133. X        c = getchar();
  134. X        ++Count;
  135. X
  136. X        if ( c == EOF )
  137. X        {
  138. X            if ( DeferredChar )
  139. X            {    putchar( DeferredChar );
  140. X                putchar( '\n' );
  141. X            }
  142. X            exit ( 0 );
  143. X        }
  144. X
  145. X        if
  146. X        (    DeferredChar
  147. X            &&
  148. X            (    c == '\n'
  149. X                ||
  150. X                ! ( rand() % 6 )
  151. X            )
  152. X        )
  153. X        {    /* It's time to output the DeferredChar. */
  154. X            if ( isalpha( c ) && isupper( c ))
  155. X            {    /* Preserve word capitalization */
  156. X                if ( isalpha( DeferredChar ))
  157. X                    DeferredChar = toupper( DeferredChar );
  158. X                c = tolower( c );
  159. X            }
  160. X            else if ( isalpha( DeferredChar ))
  161. X                DeferredChar = tolower( DeferredChar );
  162. X            putchar( DeferredChar );
  163. X            DeferredChar = 0;
  164. X            putchar( c );
  165. X            continue;
  166. X        }
  167. X
  168. X        if ( c == '\n' )
  169. X        {    /* No changes to newline */
  170. X            putchar( c );
  171. X            continue;
  172. X        }
  173. X
  174. X        if ( Count > 24 && Events && ( Count / Events ) < 20 )
  175. X        {    /* Too many mutations in one spot. */
  176. X            putchar( c );
  177. X            continue;
  178. X        }
  179. X
  180. X        if ( c == ' ' )
  181. X        {    /* Do nothing to it. */
  182. X            ;
  183. X        }
  184. X        else if ( ! DeferredChar && ( rand() % 72 ) < 3 )
  185. X        {    /* Defer it. */
  186. X            DeferredChar = c;
  187. X            ++Events;
  188. X            continue;
  189. X        }
  190. X        else if ( ( rand() % 72 ) < 3 )
  191. X        {    /* Replace with noise. */
  192. X            ++Events;
  193. X            c = Noise[ rand() % 9 ];
  194. X        }
  195. X        else if ( ( rand() % 72 ) < 2 )
  196. X        {    /* Replicate. */
  197. X            ++Events;
  198. X            putchar( c );
  199. X        }
  200. X        else if ( ( rand() % 72 ) < 1 )
  201. X        {    /* remove it. */
  202. X            ++Events;
  203. X            continue;
  204. X        }
  205. X
  206. X        putchar( c );
  207. X    }
  208. X}
  209. END_OF_FILE
  210. if test 2303 -ne `wc -c <'sigvi.c'`; then
  211.     echo shar: \"'sigvi.c'\" unpacked with wrong size!
  212. fi
  213. # end of 'sigvi.c'
  214. fi
  215. echo shar: End of shell archive.
  216. exit 0
  217.  
  218.  
  219. exit 0 # Just in case...
  220.