/ ************************************************** ***************** * * This program is a self-replication program, which will use the programs of many different names, * this copy program is the same Both self-replication is similar to the virus, but it is not a virus, because * has no destructive, there is no destructive code in the program. * * Program in TurboC2.0 through * * programming: Zheng Shaohui 2004.3.1 * ************************************ ******************************************************************** / # include
#define ok 1 # Define error 0typedEf Int Bool;
Void getprefixname (int idx, char * name) {/ * generates a file name prefix according to the data IDX, only 4 bytes, * * Use it as the first 4 characters of the file name of an executable file, * * and save * / Int Temp; int CNT = 0; while (CNT <4) {Name [CNT ] = IDX% 26 97; IDX / = 26;} / * while * / name [4] = '/ 0 ';} / * getname * /
Void getFullName (Char * prefix, int idx, char * fullname) {/ * generates a full name of an executable file, which consists of prefix * PREFIX and a digital IDX, saved in fullname * / int CNT = 4, TEMP; STRCPY (Fullname, Prefix); while (idx> 0) {fullname [CNT ] = IDX% 10 48; IDX / = 10;} fullname [cnt] = '/ 0'; strcat (fullname, " ");} / * getFullname * /
Bool Writefile (char * filename, unsigned char * buffer, long size) {/ * puts the content in the buffer in the file name filename * / file * fp; long count = 0; fp = fopen (filename, "wb "); If (fp == null) return error; while (count Bool readfile (char * filename, unsigned char * buffer, long * size) {/ * places the content in the file named filename in buffer * / file * fp; long count = 0; fp = fopen (filename, "rb"); if (fp == null) return error; CPrintf ("Wait a Moment Please, this Program Is Reading Soure File ..."); while (! feof (fp)) {/ * When the file is not over * / Buffer [count ] = fgetc (fp);} / * while * / * size = count; fclose (fp); return ok;} / * readfile * / void showinfo (void) {textbackground (lightblue); CLRSCR (); WINDOW (15, 1, 65, 7); TextBackground (cyan); Clrscr (); Window (17, 2, 63, 6); Textbackground (Black); TextColor (RED); CLRSCR (); CPRINTF " Void Main (int Argc, char * argv []) { Char prefixname [5]; char filename [50]; char buffer [30000]; int count = 0, prefix; long fsize; file * fp; (void) argc; showinfo (); SRAND (Time (NULL)); prefix = rand (); getPrefiXName (prefix, prefixName); if (ReadFile (Argv [0], Buffer, & fsize == error) {CPRINTF "Sorry, Can't Read file% s.", Argv [0]); exit (0);} While (count <10000) {/ * exits * / getfullname (prefixName, count, filename) after 100,000 files; / * Get a file name as the name * / if (Writefile (FileName, Buffer, Fsize) == Error) / * If write file error * / printf ("/ n / rcan't create file% s.", filename); CPrintf ("% s,", filename);}}