PEter-virus/make_write.c

27 lines
530 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
FILE *fd;
char *buf, *secName;
int bufSz;
fd = fopen("a.exe", "rb");
fseek(fd, 0, SEEK_END);
bufSz = ftell(fd);
fseek(fd, 0, SEEK_SET);
buf = malloc(bufSz);
fread(buf, 1, bufSz, fd);
fclose(fd);
int i = 0;
while (secName = sections_by_index_get_name(buf, i)) {
sections_by_name_set_writable(buf, secName);
}
fd = fopen("a.exe", "w+b");
fwrite(buf, 1, bufSz, fd);
return 0;
}