版本比较
防JC神器,再也不怕机惨了
正文
增加 108 行删除 108 行
23 行未改动2425262728282930313132333435353637383940404142434445454647484950505152535354555657585859606162626364656566676869707172727374757576777878798081828283848586868788899091929293949596979798991001011011021031041051061061071081091101111111121131141151161161171181191201201211221231231241251261261271281291301301311321331341351351361371381391401401411421431441451461471471481491501511521531531541551561571581581591601611621631641651661671671681691701711721731741741751761771781791801811821831831841851861871881891901911921921931941951961961971981992002002012022032032042052062062072082092102112112122132142142152162172182192202212212222232242252 行未改动2282292302312322322332342352362372382392402402412422432442452462462472482492502512522532532542552562572572582592592602612622632632642652662672672682692702712722722732742752762762772782792802812812822832842852862862872882892902912912922932942952 行未改动2982993003013023023033043053063073083093103103113123133143153153163173183193193203213223233243253263273283293293303313323333343353363373383393393403413423438 行未改动3523533543553563563573583593603603613623633633643653663673683683693703713722 行未改动3753763773783793793803813823833843843853863873883893903903913923933943953963963973983994004014014024034044054064064074084094104114114124134144154164164174184194204214214224234244254264274284294294304314324324334344354364374374384394404414424424434444454464474474484494504514524534544544554564574584594594604614624634644654664674674684694704714724734744754764764774784794804 行未改动4854864874884894894904914924934944954954964974984995 行未改动5055065075085095095105115115125135145157 行未改动52352452552652752752852952953053153253353453553653753853954054154254354454554654753753853954054154254354454554654754854955055155155255355455555655755855955956056156156256356356456556556656756856917 行未改动5875885895905915915925935945945955965975985996006016016026036046056066066076086096108 行未改动23 行未改动private: HHOOK hKeyboardHook; bool monitoring; std::thread monitorThread;
public: CompleteCADDisabler() : hKeyboardHook(NULL), monitoring(false) {}
// 主方法:立即禁用Ctrl+Alt+Delete(不用重启) BOOL DisableCADImmediate() { std::cout << "正在立即禁用 Ctrl+Alt+Delete..." << std::endl;
// 1. 设置注册表 if (SetRegistrySettings()) { std::cout << "? 注册表设置完成" << std::endl; }
// 2. 安装键盘钩子(实时拦截) if (InstallKeyboardHook()) { std::cout << "? 键盘钩子已安装" << std::endl; }
// 3. 启动进程监控 if (StartProcessMonitoring()) { std::cout << "? 进程监控已启动" << std::endl; }
// 4. 刷新系统策略 RefreshSystemPolicy();
std::cout << "\n?? Ctrl+Alt+Delete 已完全禁用,立即生效!" << std::endl; std::cout << "现在可以测试按 Ctrl+Alt+Delete 组合键" << std::endl; return TRUE; }
// 停止所有保护 BOOL StopAllProtection() { std::cout << "正在停止所有保护..." << std::endl;
// 1. 恢复注册表 RestoreRegistry();
// 2. 移除键盘钩子 if (hKeyboardHook) { UnhookWindowsHookEx(hKeyboardHook); hKeyboardHook = NULL; std::cout << "? 键盘钩子已移除" << std::endl; }
// 3. 停止进程监控 StopProcessMonitoring();
// 4. 刷新策略 RefreshSystemPolicy();
std::cout << "? 所有保护已停止,功能已恢复" << std::endl; return TRUE; }
~CompleteCADDisabler() { StopAllProtection(); }
private: // 设置注册表 BOOL SetRegistrySettings() { HKEY hKey; DWORD value = 1;
// 系统策略 - 禁用CAD if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueEx(hKey, "DisableCAD", 0, REG_DWORD, (BYTE*)&value, sizeof(value)); RegCloseKey(hKey); }
// 用户策略 - 禁用任务管理器和锁定 if (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, (BYTE*)&value, sizeof(value)); RegSetValueEx(hKey, "DisableLockWorkstation", 0, REG_DWORD, (BYTE*)&value, sizeof(value)); RegCloseKey(hKey); }
// Winlogon设置 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {
RegSetValueEx(hKey, "DisableCAD", 0, REG_DWORD, (BYTE*)&value, sizeof(value)); RegCloseKey(hKey); }
return TRUE; }
// 安装键盘钩子(实时拦截按键) BOOL InstallKeyboardHook() { hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, GetModuleHandle(NULL), 0); return (hKeyboardHook != NULL); }
// 键盘钩子处理函数 static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN)) { KBDLLHOOKSTRUCT* kbd = (KBDLLHOOKSTRUCT*)lParam;
// 拦截 Ctrl+Alt+Delete if (kbd->vkCode == VK_DELETE) { BOOL ctrlPressed = (GetAsyncKeyState(VK_CONTROL) & 0x8000); BOOL altPressed = (GetAsyncKeyState(VK_MENU) & 0x8000);
if (ctrlPressed && altPressed) { std::cout << "[拦截] Ctrl+Alt+Delete 被阻止!" << std::endl; MessageBeep(MB_ICONEXCLAMATION); // 提示音 return 1; // 拦截按键 } }
// 拦截 Win+L(锁定计算机) if (kbd->vkCode == 'L' && (GetAsyncKeyState(VK_LWIN) & 0x8000)) { std::cout << "[拦截] Win+L 被阻止!" << std::endl; return 1; // 拦截按键 }
// 拦截 Ctrl+Shift+Esc(任务管理器) if (kbd->vkCode == VK_ESCAPE) { BOOL ctrlPressed = (GetAsyncKeyState(VK_CONTROL) & 0x8000); BOOL shiftPressed = (GetAsyncKeyState(VK_SHIFT) & 0x8000);
if (ctrlPressed && shiftPressed) { std::cout << "[拦截] Ctrl+Shift+Esc 被阻止!" << std::endl; return 1; // 拦截按键 } } } return CallNextHookEx(NULL, nCode, wParam, lParam); }
// 启动进程监控 BOOL StartProcessMonitoring() { monitoring = true; monitorThread = std::thread(&CompleteCADDisabler::MonitorLoop, this); return TRUE; }
// 停止进程监控 BOOL StopProcessMonitoring() { monitoring = false; if (monitorThread.joinable()) { monitorThread.join(); } return TRUE; }
// 进程监控循环 void MonitorLoop() { while (monitoring) { KillSecurityProcesses(); CloseSecurityWindows(); std::this_thread::sleep_for(std::chrono::milliseconds(300)); // 快速响应 } }
// 修复的进程名比较函数 bool CompareProcessName(const char* processName, const char* targetName) { if (processName == NULL || targetName == NULL) return false;
// 转换为小写比较 std::string procStr(processName); std::string targetStr(targetName);
for (char& c : procStr) c = tolower(c); for (char& c : targetStr) c = tolower(c);
return procStr == targetStr; }
// 关闭安全相关进程 void KillSecurityProcesses() { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return;
PROCESSENTRY32 pe; pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &pe)) { do { // 使用修复的比较函数 if (CompareProcessName(pe.szExeFile, "taskmgr.exe") || // 任务管理器 CompareProcessName(pe.szExeFile, "logonui.exe") || // 登录界面 CompareProcessName(pe.szExeFile, "sethc.exe")) { // 粘滞键
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if (hProcess) { TerminateProcess(hProcess, 0); CloseHandle(hProcess);2 行未改动 } while (Process32Next(hSnapshot, &pe)); } CloseHandle(hSnapshot); }
// 关闭安全相关窗口 void CloseSecurityWindows() { // 关闭任务管理器窗口 HWND hTaskMgr = FindWindow("TaskManagerWindow", NULL); if (hTaskMgr && IsWindowVisible(hTaskMgr)) { PostMessage(hTaskMgr, WM_CLOSE, 0, 0); }
// 关闭Windows安全窗口(Ctrl+Alt+Delete界面) HWND hSAS = FindWindow("SAS window class", NULL); if (hSAS && IsWindowVisible(hSAS)) { PostMessage(hSAS, WM_CLOSE, 0, 0); }
// 关闭登录界面 HWND hLogonUI = FindWindow("LogonUI", NULL); if (hLogonUI && IsWindowVisible(hLogonUI)) { PostMessage(hLogonUI, WM_CLOSE, 0, 0); } }
// 刷新系统策略 void RefreshSystemPolicy() { // 发送设置变更消息 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Policy", SMTO_BLOCK, 1000, NULL);
// 更新系统参数 SystemParametersInfo(SPI_SETWORKAREA, 0, NULL, SPIF_SENDCHANGE); }
// 恢复注册表设置 void RestoreRegistry() { HKEY hKey;
// 恢复系统策略 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {
RegDeleteValue(hKey, "DisableCAD"); RegCloseKey(hKey); }
// 恢复用户策略 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); }
// 恢复Winlogon设置 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) {
RegDeleteValue(hKey, "DisableCAD"); RegCloseKey(hKey); } }2 行未改动class MouseDisabler {private: HHOOK mouseHook; static MouseDisabler* instance;
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { // Block all mouse events return 1; } return CallNextHookEx(NULL, nCode, wParam, lParam); }
public: MouseDisabler() : mouseHook(NULL) { instance = this; }
~MouseDisabler() { enableMouse(); }
bool disableMouse() { // Set Windows hook to intercept mouse events mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, GetModuleHandle(NULL), 0); if (mouseHook) { return true; } else { return false; } }
bool enableMouse() { if (mouseHook) { if (UnhookWindowsHookEx(mouseHook)) { mouseHook = NULL; return true; } } return false; }
bool isMouseDisabled() const { return mouseHook != NULL; }};8 行未改动 std::vector<int> blockedKeys; std::map<int, bool> keyStates; bool isBlockingEnabled; static ShortcutBlocker* instance;
static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { KBDLLHOOKSTRUCT* pKeyBoard = (KBDLLHOOKSTRUCT*)lParam;
if (instance && instance->isBlockingEnabled) { int vkCode = pKeyBoard->vkCode;
// Check single keys for (int blockedKey : instance->blockedKeys) { if (vkCode == blockedKey) { if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
// Display key names switch(vkCode) { case VK_LWIN: break; case VK_RWIN: break;2 行未改动 case VK_APPS: break; default: break; } std::cout << std::endl;
return 1; // Block the key } } }
// Check combination keys bool ctrlPressed = GetAsyncKeyState(VK_CONTROL) & 0x8000; bool altPressed = GetAsyncKeyState(VK_MENU) & 0x8000; bool shiftPressed = GetAsyncKeyState(VK_SHIFT) & 0x8000; bool winPressed = GetAsyncKeyState(VK_LWIN) & 0x8000 || GetAsyncKeyState(VK_RWIN) & 0x8000;
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) { // Block Alt+Tab if (altPressed && vkCode == VK_TAB) { return 1; }
// Block Win+Tab if (winPressed && vkCode == VK_TAB) { return 1; }
// Block Win+D (Show Desktop) if (winPressed && vkCode == 'D') { return 1; }
// Block Win+E (File Explorer) if (winPressed && vkCode == 'E') { return 1; }
// Block Win+L (Lock Computer) if (winPressed && vkCode == 'L') { return 1; }
// Block Ctrl+Esc (Start Menu) if (ctrlPressed && vkCode == VK_ESCAPE) { return 1; }
// Block Alt+F4 if (altPressed && vkCode == VK_F4) { return 1; } } } }
return CallNextHookEx(nullptr, nCode, wParam, lParam); }
public: ShortcutBlocker() : keyboardHook(nullptr), isBlockingEnabled(false) { instance = this; }
~ShortcutBlocker() { stopBlocking(); instance = nullptr; }
bool startBlocking() { if (keyboardHook) { return true; }
// Install low-level keyboard hook keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, GetModuleHandle(NULL), 0); if (!keyboardHook) { DWORD error = GetLastError(); return false; }
isBlockingEnabled = true; showBlockedKeys(); return true; }
void stopBlocking() { if (keyboardHook) { UnhookWindowsHookEx(keyboardHook); keyboardHook = nullptr; isBlockingEnabled = false; } }
void addBlockedKey(int virtualKeyCode) { // Check if already exists for (int key : blockedKeys) { if (key == virtualKeyCode) { return; } } blockedKeys.push_back(virtualKeyCode);
// Display key names switch(virtualKeyCode) { case VK_LWIN: break; case VK_RWIN: break;4 行未改动 default: break; } std::cout << std::endl; }
void addBlockedKeys(const std::vector<int>& keys) { for (int key : keys) { addBlockedKey(key); } }
void showBlockedKeys() const { if (!blockedKeys.empty()){ for (int key : blockedKeys) { switch(key) {5 行未改动 } } std::cout << std::endl; }
}
bool isBlocking() const { return isBlockingEnabled; }};7 行未改动ShortcutBlocker* ShortcutBlocker::instance = nullptr;
int main() { MouseDisabler disabler;
ShortcutBlocker blocker;
// Add keys to block std::vector<int> systemKeys = { VK_LWIN, // Left Win Key VK_RWIN, // Right Win Key VK_ESCAPE, // Escape Key VK_TAB, // Tab Key VK_APPS, // Menu Key VK_F1, VK_F2, VK_F3, VK_F5, VK_F6, VK_F7, VK_F9, VK_F11, VK_F12, VK_LCONTROL, VK_RCONTROL, VK_F1, VK_F2, VK_F3, VK_F5, VK_F6, VK_F7, VK_F9, VK_F11, VK_F12, VK_LCONTROL, VK_RCONTROL, VK_UP, VK_DOWN };
while (1){ for (int i = '0'; i <= '9'; i++) if (GetAsyncKeyState(i)) password += i, cout << char(i), Sleep(300); if (GetAsyncKeyState(VK_F5)) break; } system("cls");
HideConsoleWindow();
blocker.addBlockedKeys(systemKeys);
CompleteCADDisabler disabler2;
// Start blocking string input = ""; while (1){ if (GetAsyncKeyState(VK_F8) & 0x8000) {17 行未改动 } TranslateMessage(&msg); DispatchMessage(&msg); }
// Small delay to avoid high CPU usage std::this_thread::sleep_for(std::chrono::milliseconds(10));
} blocker.stopBlocking(); disabler.enableMouse(); disabler2.StopAllProtection(); } }
if (GetAsyncKeyState(VK_F4) & 0x8000) { break; } }
return 0;}
8 行未改动