Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.11 KB | None | 0 0
  1. void antiVM()
  2. {
  3.     HKEY HK = 0;
  4.     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\ACPI\\DSDT\\VBOX__", 0, KEY_READ, &HK) == ERROR_SUCCESS)
  5.     {
  6.         ExitProcess(0);
  7.     }
  8.  
  9.     HANDLE hF1 = CreateFile(L"\\\\.\\VBoxMiniRdrDN", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, 0);
  10.     if (hF1 != INVALID_HANDLE_VALUE)
  11.     {
  12.         ExitProcess(0);
  13.     }
  14.  
  15.  
  16.     HMODULE hM1 = LoadLibrary(L"VBoxHook.dll");
  17.     if (hM1)
  18.     {
  19.         ExitProcess(0);
  20.     }
  21.  
  22.     HK = 0;
  23.     if ((ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Oracle\\VirtualBox Guest Additions", 0, KEY_READ, &HK)) && HK)
  24.     {
  25.         RegCloseKey(HK);
  26.         ExitProcess(0);
  27.     }
  28.  
  29.     HK = 0;
  30.     if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System", 0, KEY_READ, &HK) == ERROR_SUCCESS)
  31.     {
  32.         unsigned long type = 0;
  33.         unsigned long size = 0x100;
  34.         char* systembiosversion = (char*)LocalAlloc(LMEM_ZEROINIT, size + 10);
  35.         if (ERROR_SUCCESS == RegQueryValueEx(HK, L"SystemBiosVersion", 0, &type, (unsigned char*)systembiosversion, &size))
  36.         {
  37.             ToLower((unsigned char*)systembiosversion);
  38.             if (type == REG_SZ || type == REG_MULTI_SZ)
  39.             {
  40.                 if (strstr(systembiosversion, "vbox"))
  41.                 {
  42.                     ExitProcess(0);
  43.                 }
  44.             }
  45.         }
  46.         LocalFree(systembiosversion);
  47.  
  48.         type = 0;
  49.         size = 0x200;
  50.         char* videobiosversion = (char*)LocalAlloc(LMEM_ZEROINIT, size + 10);
  51.         if (ERROR_SUCCESS == RegQueryValueEx(HK, L"VideoBiosVersion", 0, &type, (unsigned char*)videobiosversion, &size))
  52.         {
  53.             if (type == REG_MULTI_SZ)
  54.             {
  55.                 char* video = videobiosversion;
  56.                 while (*(unsigned char*)video)
  57.                 {
  58.                     ToLower((unsigned char*)video);
  59.                     if (strstr(video, "oracle") || strstr(video, "virtualbox"))
  60.                     {
  61.                         ExitProcess(0);
  62.                     }
  63.                     video = &video[strlen(video) + 1];
  64.                 }
  65.             }
  66.         }
  67.         LocalFree(videobiosversion);
  68.         RegCloseKey(HK);
  69.     }
  70.  
  71.     HANDLE hxx = CreateFile(L"\\\\.\\pipe\\VBoxTrayIPC", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
  72.     if (hxx != INVALID_HANDLE_VALUE)
  73.     {
  74.         CloseHandle(hxx);
  75.         ExitProcess(0);
  76.     }
  77.    
  78.     HWND hY1 = FindWindow(L"VBoxTrayToolWndClass", 0);
  79.     HWND hY2 = FindWindow(0, L"VBoxTrayToolWnd");
  80.     if (hY1 || hY2)
  81.     {
  82.         ExitProcess(0);
  83.     }
  84.  
  85.     unsigned long x = 0;
  86.     __asm
  87.     {
  88.         push offset Handler
  89.         push dword ptr fs : [0x0]
  90.         mov dword ptr fs : [0x0], esp
  91.  
  92.         pushad
  93.         xor eax, eax
  94.         xor ecx, ecx
  95.         xor edx, edx
  96.         xor ebx, ebx
  97.         pushfd
  98.         pop esi
  99.         or esi, 0x100; Trap flag
  100.         push esi
  101.         popfd
  102.         CPUID
  103.         pushfd
  104.         pop eax
  105.         mov x, eax
  106.         popad
  107.         pop dword ptr fs : [0x0]
  108.         pop eax
  109.     }
  110.     if (x & 0x100)
  111.     {
  112.         ExitProcess(0);
  113.     }
  114.  
  115.     bool xy = 0;
  116.     __asm
  117.     {
  118.         pushad
  119.         pushfd
  120.         pop eax
  121.         or eax, 0x00200000
  122.         push eax
  123.         popfd
  124.         pushfd
  125.         pop eax
  126.         and eax, 0x00200000
  127.         jz CPUID_NOT_SUPPORTED; Are you still alive ?
  128.         xor eax, eax
  129.         xor edx, edx
  130.         xor ecx, ecx
  131.         xor ebx, ebx
  132.         inc eax; processor info and feature bits
  133.         cpuid
  134.         test ecx, 0x80000000; Hypervisor present
  135.         jnz Hypervisor
  136.         mov x, 0
  137.         jmp bye
  138.         Hypervisor :
  139.         mov x, 1
  140.             jmp bye
  141.             CPUID_NOT_SUPPORTED :
  142.         mov x, 2
  143.             bye :
  144.             popad
  145.     }
  146.     if (xy == 1)
  147.     {
  148.         ExitProcess(0);
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement