跳到正文

个人记录

神秘代码

MGStudent约 35 分钟
原文
文章信息与版本

文章信息

发布
2026年2月11日
收录
2026年7月4日
更新
2026年11月8日
篇幅
约 35 分钟

版本

  1. v1当前

正常版

C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;


#ifndef VK_LWIN
#define VK_LWIN 0x5B          
#endif
#ifndef VK_RWIN
#define VK_RWIN 0x5C          
#endif
#ifndef VK_MENU
#define VK_MENU 0x12        
#endif
#ifndef VK_F4
#define VK_F4 0x73         
#endif
#ifndef VK_DELETE
#define VK_DELETE 0x2E      
#endif
#ifndef VK_TAB
#define VK_TAB 0x09          
#endif
#ifndef VK_ESCAPE
#define VK_ESCAPE 0x1B      
#endif
#ifndef VK_SPACE
#define VK_SPACE 0x20         
#endif
#ifndef VK_C
#define VK_C 0x43          
#endif
#ifndef VK_V
#define VK_V 0x56           
#endif
#ifndef VK_X
#define VK_X 0x58        
#endif
#ifndef VK_A
#define VK_A 0x41         
#endif
#ifndef VK_Z
#define VK_Z 0x5A        
#endif
#ifndef VK_CONTROL
#define VK_CONTROL 0x11     
#endif
#ifndef VK_SHIFT
#define VK_SHIFT 0x10     
#endif

LONG old_WinStyle = 0;
LONG old_ExStyle = 0;
HWND console_hwnd = NULL;
HANDLE hConsoleOut = NULL;
HANDLE hConsoleIn = NULL;
DWORD old_InMode = 0;
WNDPROC old_WndProc = NULL;
string inputBuffer = "";
const string exitCode = "ssd122";
HHOOK keyboardHook = NULL;


LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){
    if(nCode >= 0){
        KBDLLHOOKSTRUCT* pKeyBoard = (KBDLLHOOKSTRUCT*)lParam;
        DWORD vkCode = pKeyBoard->vkCode;
        

        if(vkCode == VK_LWIN || vkCode == VK_RWIN){
            return 1;
        }
        
        bool isAltDown = (GetAsyncKeyState(VK_MENU) & 0x8000) != 0;
        bool isCtrlDown = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
        bool isShiftDown = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0;
        

        if((isAltDown && vkCode == VK_F4) || 
           (isCtrlDown && isAltDown && vkCode == VK_DELETE) || 
           (isCtrlDown && isShiftDown && vkCode == VK_ESCAPE) || 
           (isAltDown && vkCode == VK_TAB) ||     
           (isCtrlDown && vkCode == VK_ESCAPE) ||  
           (isAltDown && vkCode == VK_SPACE) ||   
           (isCtrlDown && vkCode == VK_C) ||       
           (isCtrlDown && vkCode == VK_V) ||     
           (isCtrlDown && vkCode == VK_X) ||      
           (isCtrlDown && vkCode == VK_A) ||     
           (isCtrlDown && vkCode == VK_Z)){     
            return 1;
        }
    }
    return CallNextHookEx(keyboardHook, nCode, wParam, lParam);
}


void setKeyboardHook(){
    keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
}


void unSetKeyboardHook(){
    if(keyboardHook) UnhookWindowsHookEx(keyboardHook);
}

LRESULT CALLBACK CustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
    if((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN || msg == WM_SYSCOMMAND)){
        if(wParam == VK_F11 || wParam == SC_KEYMENU){
            return 0;
        }
    }
    return CallWindowProc(old_WndProc, hwnd, msg, wParam, lParam);
}

void exit_fullscreen(){
    if(!console_hwnd || !hConsoleOut || !old_WndProc) return;

    unSetKeyboardHook();
    SetWindowLong(console_hwnd, -4, (LONG)(UINT_PTR)old_WndProc);
    SetWindowLong(console_hwnd,GWL_STYLE,old_WinStyle);
    SetWindowLong(console_hwnd,GWL_EXSTYLE,old_ExStyle);
    
    CONSOLE_CURSOR_INFO cci;
    cci.dwSize = 100;
    cci.bVisible = TRUE;
    SetConsoleCursorInfo(hConsoleOut, &cci);
    
    if(hConsoleIn) SetConsoleMode(hConsoleIn, old_InMode);
    
    SetWindowPos(console_hwnd, HWND_TOP, 0, 0, 800, 600, SWP_FRAMECHANGED);
}

void full_screen(){   
    console_hwnd = GetConsoleWindow();
    if(!console_hwnd) return;
 
    setKeyboardHook();

    old_WndProc = (WNDPROC)(UINT_PTR)GetWindowLong(console_hwnd, -4);
    SetWindowLong(console_hwnd, -4, (LONG)(UINT_PTR)CustomWndProc);

    old_WinStyle = GetWindowLong(console_hwnd,GWL_STYLE);
    old_ExStyle = GetWindowLong(console_hwnd,GWL_EXSTYLE);

    CONSOLE_FONT_INFOEX cfi;
    cfi.cbSize = sizeof(CONSOLE_FONT_INFOEX);
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetCurrentConsoleFontEx(hConsoleOut, FALSE, &cfi);

    hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
    GetConsoleMode(hConsoleIn, &old_InMode);
    SetConsoleMode(hConsoleIn, ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE);

    int cx = GetSystemMetrics(SM_CXSCREEN) / cfi.dwFontSize.X;
    int cy = GetSystemMetrics(SM_CYSCREEN) / cfi.dwFontSize.Y;

    LONG l_WinStyle = GetWindowLong(console_hwnd,GWL_STYLE);  
    SetWindowLong(console_hwnd,GWL_STYLE,(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);

    if(hConsoleOut != INVALID_HANDLE_VALUE){
        SMALL_RECT winRect = {0, 0, cx - 1, cy - 1};
        SetConsoleWindowInfo(hConsoleOut, TRUE, &winRect);
        COORD bufferSize = {cx, cy};
        SetConsoleScreenBufferSize(hConsoleOut, bufferSize);
        
        CONSOLE_CURSOR_INFO cci;
        cci.dwSize = 1;
        cci.bVisible = FALSE;
        SetConsoleCursorInfo(hConsoleOut, &cci);
    }

    LONG l_ExStyle = GetWindowLong(console_hwnd, GWL_EXSTYLE);
    l_ExStyle &= ~0x00000010;
    l_ExStyle &= ~0x00000020;
    SetWindowLong(console_hwnd, GWL_EXSTYLE, l_ExStyle);

    SetWindowPos(console_hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
}

bool checkExitInput(){
    INPUT_RECORD inputRecord;
    DWORD readCount;
    if(!PeekConsoleInput(hConsoleIn, &inputRecord, 1, &readCount) || readCount == 0) return false;
    
    ReadConsoleInput(hConsoleIn, &inputRecord, 1, &readCount);
    if(inputRecord.EventType == KEY_EVENT && inputRecord.Event.KeyEvent.bKeyDown){
        char ch = inputRecord.Event.KeyEvent.uChar.AsciiChar;
        if(ch >= 32 && ch <= 126){
            inputBuffer += ch;
            if(inputBuffer.length() > exitCode.length()){
                inputBuffer = inputBuffer.substr(inputBuffer.length() - exitCode.length());
            }
            if(inputBuffer == exitCode){
                return true;
            }
        }
    }
    return false;
}

int sum=0;
void cel(){
	if(rand()%2==0)sum+=rand()%3-1;
	if(sum==0)sum=1;
	if(sum<0)sum=0;
	if(sum>8)sum--;
	for(int i=1;i<=sum;i++)cout<<"  ";
}

void tel(int x){
	int k=rand()%7+1;
	k++;
	for(int i=1;i<=k;i++){
		if(i==1)cout<<char(rand()%26+'A');
		else cout<<char(rand()%26+'a');
	}
	if(rand()%4!=3){
		cout<<"\\";
		tel(x+1);
	}
	if(x==1){
		int f=rand()%4;
		if(f==0)cout<<".txt";
		if(f==1)cout<<".cmd";
		if(f==2)cout<<".exe";
		if(f==3)cout<<".bat";
	}
}

void showErrorPopup() {
    int result = MessageBoxA(
        NULL,
        "Your system is now mine!",
        "Silver Wolf",
        MB_OK | MB_ICONWARNING
    );
}

int main(){
	system("color 0A");
	srand(time(0));
	cout<<"Silver Wolf System Takeover Program [versions 10.0.19045.3448]\n";
	cout<<"(c) Silver Wolf Corporation All rights reserved.\n\n";
	cout<<"C:\\Users\\stu>";
//	string s;
//	cin>>s;
	
//	system("rundll32.exe user32.dll,LockWorkStation"); 
	
	
	MSG msg;
	cout<<"Silver Wolf is seizing your control:\n";
	_sleep(2000);
	cout<<"Completed.\n";
	_sleep(1000);
	showErrorPopup();
	full_screen();
	while(1){
		PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
		TranslateMessage(&msg);
		DispatchMessage(&msg);
		if(checkExitInput()){
			exit_fullscreen();
			break;
		}
		cel();
		cout<<"C:\\";
		tel(1);
		cout<<'\n';
	}

	unSetKeyboardHook();
	return 0;
}

需要图片及特殊头文件版:

C++
#include<bits/stdc++.h>
#include<windows.h>

#include<graphics.h>
#include<conio.h>
using namespace std;

#define OCR_NORMAL 3
#ifndef VK_LWIN
#define VK_LWIN 0x5B          
#endif
#ifndef VK_RWIN
#define VK_RWIN 0x5C          
#endif
#ifndef VK_MENU
#define VK_MENU 0x12        
#endif
#ifndef VK_F4
#define VK_F4 0x73         
#endif
#ifndef VK_DELETE
#define VK_DELETE 0x2E      
#endif
#ifndef VK_TAB
#define VK_TAB 0x09          
#endif
#ifndef VK_ESCAPE
#define VK_ESCAPE 0x1B      
#endif
#ifndef VK_SPACE
#define VK_SPACE 0x20         
#endif
#ifndef VK_C
#define VK_C 0x43          
#endif
#ifndef VK_V
#define VK_V 0x56           
#endif
#ifndef VK_X
#define VK_X 0x58        
#endif
#ifndef VK_A
#define VK_A 0x41         
#endif
#ifndef VK_Z
#define VK_Z 0x5A        
#endif
#ifndef VK_CONTROL
#define VK_CONTROL 0x11     
#endif
#ifndef VK_SHIFT
#define VK_SHIFT 0x10     
#endif
#ifndef VK_G
#define VK_G 0x47          
#endif
#ifndef VK_L
#define VK_L 0x4C          
#endif

LONG old_WinStyle = 0;
LONG old_ExStyle = 0;
HWND console_hwnd = NULL;
HANDLE hConsoleOut = NULL;
HANDLE hConsoleIn = NULL;
DWORD old_InMode = 0;
WNDPROC old_WndProc = NULL;
string inputBuffer = "";
const string exitCode = "wzc122",exitcode="silver";
HHOOK keyboardHook = NULL;


void showImagePopup() {
    HANDLE hTempIn = GetStdHandle(STD_INPUT_HANDLE);
    DWORD tempMode = 0;
    GetConsoleMode(hTempIn, &tempMode);
	
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
    
    initgraph(screenWidth, screenHeight);
    
    HWND hwndGraph = GetHWnd();
    SetWindowLong(hwndGraph, GWL_STYLE, GetWindowLong(hwndGraph, GWL_STYLE) 
                  & ~WS_CAPTION
                  & ~WS_THICKFRAME
                  & ~WS_BORDER
                  & ~WS_SYSMENU);
    SetWindowPos(hwndGraph, HWND_TOPMOST, 0, 0, screenWidth, screenHeight, 
                 SWP_FRAMECHANGED | SWP_NOZORDER);
    
    setbkcolor(WHITE);
    cleardevice();
    
    const int imgWidth = 600;
    const int imgHeight = 600;
    IMAGE img;
    loadimage(&img, "C:\\Users\\stu\\Documents\\ssd\\wolf.jpg", imgWidth, imgHeight);
    
    int imgX = (screenWidth - imgWidth) / 2;
    int imgY = (screenHeight - imgHeight) / 2;
    
    putimage(imgX, imgY, &img);
    

    string inputStr = "";
    while (true) {
        SetWindowPos(hwndGraph, HWND_TOPMOST, 0, 0, screenWidth, screenHeight, SWP_NOMOVE | SWP_NOSIZE);
        if (_kbhit()) { 
            char ch = _getch(); 
            if (ch >= 'a' && ch <= 'z') { 
                inputStr += ch;
              
                if (inputStr.length() > exitcode.size()) {
                    inputStr = inputStr.substr(inputStr.length() - exitcode.size());
                }
                
                if (inputStr == exitcode) {
                    break;
                }
            }
        }
        Sleep(10); 
    }
    
    closegraph();

    SetConsoleMode(hTempIn, tempMode);
    SetForegroundWindow(GetConsoleWindow());
    SetFocus(GetConsoleWindow());
    Sleep(500);
}

void HideCursorInApp() {
	while (ShowCursor(FALSE) >= 0);
}

void ShowCursorInApp() {
	while (ShowCursor(TRUE) < 0);
}
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){
    if(nCode >= 0){
        KBDLLHOOKSTRUCT* pKeyBoard = (KBDLLHOOKSTRUCT*)lParam;
        DWORD vkCode = pKeyBoard->vkCode;
        

        if(vkCode == VK_LWIN || vkCode == VK_RWIN ||
           (vkCode == VK_G && ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000)) ||
           (vkCode == VK_L && ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000))){
            return 1;
        }
        
        bool isAltDown = (GetAsyncKeyState(VK_MENU) & 0x8000) != 0;
        bool isCtrlDown = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
        bool isShiftDown = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0;
        

        if((isAltDown && vkCode == VK_F4) || 
           (isCtrlDown && isAltDown && vkCode == VK_DELETE) || 
           (isCtrlDown && isShiftDown && vkCode == VK_ESCAPE) || 
           (isAltDown && vkCode == VK_TAB) ||     
           (isCtrlDown && vkCode == VK_ESCAPE) ||  
           (isAltDown && vkCode == VK_SPACE) ||   
           (isCtrlDown && vkCode == VK_C) ||       
           (isCtrlDown && vkCode == VK_V) ||     
           (isCtrlDown && vkCode == VK_X) ||      
           (isCtrlDown && vkCode == VK_A) ||     
           (isCtrlDown && vkCode == VK_Z)){     
            return 1;
        }
    }
    return CallNextHookEx(keyboardHook, nCode, wParam, lParam);
}


void setKeyboardHook(){
    keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
}


void unSetKeyboardHook(){
    if(keyboardHook) UnhookWindowsHookEx(keyboardHook);
}

LRESULT CALLBACK CustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
    if((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN || msg == WM_SYSCOMMAND)){
        if(wParam == VK_F11 || wParam == SC_KEYMENU){
            return 0;
        }
    }
    return CallWindowProc(old_WndProc, hwnd, msg, wParam, lParam);
}

void exit_fullscreen(){
    if(!console_hwnd || !hConsoleOut || !old_WndProc) return;

    unSetKeyboardHook();
    SetWindowLong(console_hwnd, -4, (LONG)(UINT_PTR)old_WndProc);
    SetWindowLong(console_hwnd,GWL_STYLE,old_WinStyle);
    SetWindowLong(console_hwnd,GWL_EXSTYLE,old_ExStyle);
    
    CONSOLE_CURSOR_INFO cci;
    cci.dwSize = 100;
    cci.bVisible = TRUE;
    SetConsoleCursorInfo(hConsoleOut, &cci);
    
    if(hConsoleIn) SetConsoleMode(hConsoleIn, old_InMode);
    
    SetWindowPos(console_hwnd, HWND_TOP, 0, 0, 800, 600, SWP_FRAMECHANGED);
}

void full_screen(){   
    console_hwnd = GetConsoleWindow();
    if(!console_hwnd) return;
 
    setKeyboardHook();

    old_WndProc = (WNDPROC)(UINT_PTR)GetWindowLong(console_hwnd, -4);
    SetWindowLong(console_hwnd, -4, (LONG)(UINT_PTR)CustomWndProc);

    old_WinStyle = GetWindowLong(console_hwnd,GWL_STYLE);
    old_ExStyle = GetWindowLong(console_hwnd,GWL_EXSTYLE);

    CONSOLE_FONT_INFOEX cfi;
    cfi.cbSize = sizeof(CONSOLE_FONT_INFOEX);
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetCurrentConsoleFontEx(hConsoleOut, FALSE, &cfi);

    hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
    GetConsoleMode(hConsoleIn, &old_InMode);
    SetConsoleMode(hConsoleIn, ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE);

    int cx = GetSystemMetrics(SM_CXSCREEN) / cfi.dwFontSize.X;
    int cy = GetSystemMetrics(SM_CYSCREEN) / cfi.dwFontSize.Y;

    LONG l_WinStyle = GetWindowLong(console_hwnd,GWL_STYLE);  
    SetWindowLong(console_hwnd,GWL_STYLE,(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);

    if(hConsoleOut != INVALID_HANDLE_VALUE){
        SMALL_RECT winRect = {0, 0, cx - 1, cy - 1};
        SetConsoleWindowInfo(hConsoleOut, TRUE, &winRect);
        COORD bufferSize = {cx, cy};
        SetConsoleScreenBufferSize(hConsoleOut, bufferSize);
        
        CONSOLE_CURSOR_INFO cci;
        cci.dwSize = 1;
        cci.bVisible = FALSE;
        SetConsoleCursorInfo(hConsoleOut, &cci);
    }

    LONG l_ExStyle = GetWindowLong(console_hwnd, GWL_EXSTYLE);
    l_ExStyle &= ~0x00000010;
    l_ExStyle &= ~0x00000020;
    SetWindowLong(console_hwnd, GWL_EXSTYLE, l_ExStyle);

    SetWindowPos(console_hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
}

bool checkExitInput(){
    INPUT_RECORD inputRecord;
    DWORD readCount;
    if(!PeekConsoleInput(hConsoleIn, &inputRecord, 1, &readCount) || readCount == 0) return false;
    
    ReadConsoleInput(hConsoleIn, &inputRecord, 1, &readCount);
    if(inputRecord.EventType == KEY_EVENT && inputRecord.Event.KeyEvent.bKeyDown){
        char ch = inputRecord.Event.KeyEvent.uChar.AsciiChar;
        if(ch >= 32 && ch <= 126){
            inputBuffer += ch;
            if(inputBuffer.length() > exitCode.length()){
                inputBuffer = inputBuffer.substr(inputBuffer.length() - exitCode.length());
            }
            if(inputBuffer == exitCode){
                return true;
            }
        }
    }
    return false;
}

int sum=0;
void cel(){
	if(rand()%2==0)sum+=rand()%3-1;
	if(sum==0)sum=1;
	if(sum<0)sum=0;
	if(sum>8)sum--;
	for(int i=1;i<=sum;i++)cout<<"  ";
}

void tel(int x){
	int k=rand()%7+1;
	k++;
	for(int i=1;i<=k;i++){
		if(i==1)cout<<char(rand()%26+'A');
		else cout<<char(rand()%26+'a');
	}
	if(rand()%4!=3){
		cout<<"\\";
		tel(x+1);
	}
	if(x==1){
		int f=rand()%4;
		if(f==0)cout<<".txt";
		if(f==1)cout<<".cmd";
		if(f==2)cout<<".exe";
		if(f==3)cout<<".bat";
	}
}

void showErrorPopup() {
    int result = MessageBoxA(
        NULL,
        "Your system is now mine!",
        "Silver Wolf",
        MB_OK | MB_ICONWARNING | MB_TOPMOST
    );
}

int main(){

    console_hwnd = GetConsoleWindow();
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
	 
	system("color 0A");
	srand(time(0));

    full_screen();
	cout<<"Silver Wolf System Takeover Program [versions 10.0.19045.3448]\n";
	cout<<"(c) Silver Wolf Corporation All rights reserved.\n\n";
	cout<<"C:\\Users\\stu>";
	
	MSG msg;
	cout<<"Silver Wolf is seizing your control:\n";
	_sleep(2000);
	cout<<"Completed.\n";
	_sleep(1000);
    

	showErrorPopup();
    

    SetWindowPos(console_hwnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_NOMOVE | SWP_NOSIZE);
	
	while(1){
	
		SetWindowPos(console_hwnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_NOMOVE | SWP_NOSIZE);
		PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
		TranslateMessage(&msg);
		DispatchMessage(&msg);
		if(checkExitInput()){
			exit_fullscreen();
			break;
		}
		cel();
		cout<<"C:\\";
		tel(1);
		cout<<'\n';
	}
	
	showImagePopup(); 
	
	system("cls");
	cout<<"Alright, you successfully cracked this program.\n(-_-)";
	unSetKeyboardHook();
	return 0;
}
原文