Advertisement
Madmouse

shitty VM detector, works on Qemu and Bochs

Apr 14th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1. // ------------------------------------------------------------------------------
  2. // THE BEER-WARE LICENSE (Revision 43):
  3. // <aaronryool@gmail.com> wrote this file. As long as you retain this notice you
  4. // can do whatever you want with this stuff. If we meet some day, and you think
  5. // this stuff is worth it, you can buy me a beer in return
  6. // ------------------------------------------------------------------------------
  7.  
  8. #include <unistd.h>
  9. #include <stdlib.h>
  10. #include <signal.h>
  11. #include <sys/mman.h>
  12.  
  13. int main(unsigned a);
  14.  
  15. __sighandler_t handler(int sig)     // our signal handler function
  16. {
  17.     switch(sig)
  18.     {
  19.         case SIGSEGV:       // when segfaults happen
  20.             main(0xC0DE);   // assume they have to be because of the bug and tell us we are in the matrix
  21.         break;
  22.     }
  23. }
  24.  
  25. int main(unsigned a)
  26. {
  27.     if(a==0xC0DE) goto irl;     // if this shit is from a segfault, we are in real life :(
  28.     signal(SIGSEGV, &handler);  // register the segfault signal to be caught by our handler
  29.    
  30. asm(
  31.         ".intel_syntax noprefix\n"
  32.         "xor ecx, ecx\n"    // we arent actually copying anything, so the counter is zero
  33.         ".byte 0xf3, 0xf3, 0xf3, 0xf3, 0xf3\n"  // redundant rep prefixes
  34.         ".byte 0xf3, 0xf3, 0xf3, 0xf3, 0xf3\n"  // ...
  35.         ".byte 0xf3, 0xf3, 0xf3, 0xf3, 0xf3\n"  // ...
  36.         ".byte  0xa4\n" // movsb
  37. );
  38.     puts("The Matrix haz you Neo...");  // this is where you would put ninja moves, jack in or jack off, your choice ;)
  39.     exit(1);
  40. irl:
  41.     puts("Isn't real life boring?");    // if we get here, this is boring reality :( no cool ninja moves today bro lol
  42.     exit(0);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement