Advertisement
Madmouse

QEMU stosb windows example :D

Apr 12th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 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 <iostream>
  9. #include <windows.h>
  10.  
  11. unsigned qemu(void)
  12. {
  13. __asm{
  14.         mov eax, 0x90       // move a nop into eax for copying
  15.         mov ecx, 9      // move 9 into ecx for the number of bytes the byte code is from the offset to the jmp
  16. off:    mov edi, offset off // mov the address of the start of this instruction into edi for rep
  17.         rep stosb       // finally, repeat that byte over the memory region
  18.         jmp _qemu       // this should be overwritten, if it isnt, some naughty child is running an old version of qemu lol, and they are in the matrix
  19.         jecxz noqemu        // if ecx is 0, we are not in the matrix by definition lol, if it is not 0, then
  20. _qemu:              // this is the matrix
  21.         mov eax, 1      // follow cdecl calling convention and return 1 in eax
  22.         ret
  23. noqemu:             // this is not the matrix
  24.     xor eax, eax};      // return 0 according to cdecl calling convention
  25. }
  26.  
  27. int seh_filter(unsigned code, struct _EXCEPTION_POINTERS* ep)
  28. {
  29.     return EXCEPTION_EXECUTE_HANDLER;
  30. }
  31.  
  32. int _tmain(int a, _TCHAR* argv[])
  33. {
  34.     DWORD funSize, oldProtect;
  35.     VirtualProtect(qemu, 0x14, PAGE_EXECUTE_READWRITE, &oldProtect);
  36.     __try
  37.     {
  38.         if(qemu()) goto matrix;
  39.     }
  40.     __except(seh_filter(GetExceptionCode(), GetExceptionInformation()))
  41.     {
  42.         goto matrix;
  43.     }
  44.     std::cout << "Isn't real life boring?"<<std::endl;
  45.     exit(0);
  46. matrix:
  47.     std::cout << "The Matrix haz you Neo..."<<std::endl;
  48.     exit(1);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement