Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created February 24, 2014 20:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RobinDavid/9196548 to your computer and use it in GitHub Desktop.
Save RobinDavid/9196548 to your computer and use it in GitHub Desktop.
Know if we are on a virtual machine thank's to the processor cache trick
#include <stdio.h>
int main () {
unsigned char m[2+4], rpill[] = "\x0f\x01\x0d\x00\x00\x00\x00\xc3";
*((unsigned*) & rpill[3]) = (unsigned)m;
((void(*)()) & rpill)();
printf ("idt base: %#x\n", *((unsigned*) & m[2]));
if (m[5]>0xd0) {
printf ("Inside Matrix!\n", m[5]);
return 1;
}
else {
printf ("Not in Matrix.\n");
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment