防毒軟體的簡單實現

2021-04-01 05:11:06 字數 4586 閱讀 1178

#define debugmsg

#include

#include

#include

#include

#include

#include "psapi.h"

#pragma ***ment (lib,"psapi.lib")

#define erron getlasterror ()

#define five 50

#define high 255

tchar name[five]=;    //儲存蟲蟲的檔名+路徑

file *gfp=null;          //輸出到檔案

bool scanvxer (lptstr v_filename,long v_fileoffset,int v_length,tchar *v_contents);

//匹配特徵碼函式

bool scanfilevxer (lptstr filename);

//檔案遍歷函式

bool processvxer (void);

//列舉程序函式

bool killproc (dword processid);

//殺程序函式

bool enableprivilege(lptstr privilegename);

//提公升許可權函式

bool regdelvxer (void);

//刪除登錄檔項函式

void usage (lpctstr parameter);

//幫助函式

int main (int argc, tchar *argv)

#ifdef debugmsg

gfp=fopen("vxer.txt","a+");

if (gfp==null)

fprintf(gfp,"%s/n/n","[-------------------------file list-------------------------]");

#endif

if (strlen(argv[1])>10)

if (!(scanfilevxer(argv[1])))

if (!(processvxer()))

if (!(regdelvxer()))

fclose(gfp);

return 0;

}bool scanfilevxer (lptstr filename)

;tchar dirbuffer[high]=;

handle hfind=null;

uint count=0;

long fileoffset=0x1784;  //偏移位址

int filelength=0x77;     //長度

tchar contents=;

//從衝擊波中提取出來的,用做特徵碼

//獲取系統目錄的完整路徑

if (getsystemdirectory(dirbuffer,lpbufferlength)!=0)

else

else

}//進行特徵碼匹配工作

scanvxer(findfiledata.cfilename,fileoffset,filelength,contents);}}

while (findnextfile(hfind,&findfiledata))  //繼續查詢檔案

if (getfullpathname(findfiledata.cfilename,lpbufferlength,lpbuffer,null)!=0)

else

scanvxer(findfiledata.cfilename,fileoffset,filelength,contents);

}fprintf(gfp,"/nfile total:%d/n/n",count);

fprintf(gfp,"%s/n/n","[-------------------------file end---------------------------]/n");

printf("file total:%d/n",count);  //列印出查詢到的檔案各數

if (hfind!=null)

findclose(hfind);               //關閉搜尋控制代碼

return true;

}bool scanvxer (

lptstr v_filename,  //檔名

long v_fileoffset, //偏移位址

int v_length,      //長度

tchar *v_contents)  //具體內容

;int cmpreturn=0;

file *fp=null;

fp=fopen(v_filename,"rb");  //以二進位制唯讀方式開啟

if (fp==null)

fseek(fp,v_fileoffset,seek_set);  //把檔案指標指向特徵碼在檔案的偏移位址處

fread(filecontents,v_length,1,fp);//讀取長度為特徵碼長度的內容

cmpreturn=memcmp(v_contents,filecontents,v_length);

//進行特徵碼匹配。失敗返回false

if (cmpreturn==0)

else

}bool processvxer (void)

;dword cbneeded_1,cbneeded_2;

handle hproc=null;

hmodule hmod[1024]=;

tchar procfile[max_path];

tchar filename[five]=;

uint pcount=0;

int i=0;

enableprivilege(se_debug_name);   //提公升除錯程序許可權

fprintf(gfp,"%s/n/n","[------------------------process list--------------------------]");

strcpy(filename,"c://winnt//system32//");

strcat(filename,name);//把檔名+路徑複製到filename變數中

//列舉程序

if (!(enumprocesses(lpidprocess,sizeof(lpidprocess),&cbneeded_1)))

for (i=0;i<(int)cbneeded_1/4;i++)

deletefile(filename); //程序殺掉後,再將檔案刪除}}

}}

}if (hproc!=null)

closehandle(hproc);                //關閉程序控制代碼

fprintf(gfp,"/nprocess total:%d/n/n",pcount);

fprintf(gfp,"%s/n/n","[------------------------process end----------------------------]");

printf("/nprocess total:%d/n/n",pcount);  //列印程序各數

return true;

}bool killproc (dword processid)

}else

if (hproc!=null)

closehandle(hproc);

return true;

}bool enableprivilege(lptstr privilegename)

//提公升許可權

if(!lookupprivilegevalue(null,privilegename,&tp.privileges[0].luid))

tp.privileges[0].attributes=se_privilege_enabled;

tp.privilegecount=1;

//允許許可權,主要根據tp這個結構

if(!adjusttokenprivileges(htoken,false,&tp,sizeof(tp),0,0))

close:

if (hproc!=null)

closehandle(hproc);

if (htoken!=null)

closehandle(htoken);

return false;

if (hproc!=null)

closehandle(hproc);

if (htoken!=null)

closehandle(htoken);

return true;

}bool regdelvxer (void)

//刪除鍵值windows auto update。

ret=regdeletevalue(hkey,"windows auto update");

if (ret==error_success)

else

regclosekey(hkey);  //關閉開啟的登錄檔項

return true;

}void usage (lpctstr parameter)

防毒軟體的簡單實現

define debugmsg include include include include include include psapi.h pragma ment lib,psapi.lib define erron getlasterror define five 50 define high...

防毒軟體引擎

轉貼 防毒軟體的引擎 鄭重宣告 本貼原作者為走走看看 很多人認為諾頓企業版和個人板採用的引擎完全一致這種理解不很正確。實際上企業版在個人板的技術上還是有改進的。zdnet上刊登過一篇文章指出 企業版和個人版引擎的核心規則完全一樣,但在前端檔案匯入部分企業版是優於個人版的,企業版使用了更多的api介面...

亂彈防毒軟體

最近一段時間,公司病毒氾濫,中招的機器也不少,公司要求安裝的趨勢根本沒有招架能力,幾乎是被病毒一招致命 藍 紅 無意間在晚上看到對當前使用比較多的防毒軟體的評價,很有意思,呵呵 卡巴就好象西毒,兇猛強悍,神功蓋世,對敵決不留情,出手狠辣,招招奪命,絕少失手,不愧為一代梟雄,但畢竟練的不是純正內功,容...