Skip to content

Instantly share code, notes, and snippets.

@timb-machine
Created September 4, 2017 14:40
Show Gist options
  • Save timb-machine/21db3cfd326dbd0fcf83da97ced62dce to your computer and use it in GitHub Desktop.
Save timb-machine/21db3cfd326dbd0fcf83da97ced62dce to your computer and use it in GitHub Desktop.
Patching a VMDK file
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdio.h>
int main(int argc, char **argv) {
int filehandle;
char *mmapbuffer;
filehandle = open("sarpedon-000002.vmdk", O_RDWR);
mmapbuffer = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, f, 0);
/* cbf94b5f */
*(mmapbuffer + 0x248) = 'c';
*(mmapbuffer + 0x249) = 'b';
*(mmapbuffer + 0x24a) = 'f';
*(mmapbuffer + 0x24b) = '9';
*(mmapbuffer + 0x24c) = '4';
*(mmapbuffer + 0x24d) = 'b';
*(mmapbuffer + 0x24e) = '5';
*(mmapbuffer + 0x24f) = 'f';
msync(mmapbuffer, 4096, MS_SYNC);
munmap(mmapbuffer, 4096);
close(filehandle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment