国外高手谈卡巴斯基存隐患(2)

豆豆网   技术应用频道   2007年06月22日  【字号: 收藏本文

内容摘要:KAV的杀毒软件依靠诸多不安全内核层的黑客程序,从而将系统稳定性置于危险中。想要解决这个问题,首先KAV需要去掉不安全的内核层黑客程序,比如给非输出函数打补丁或者不加验证地关联系统服务等等。

  该机制似乎是用来在加载DLL时,调查这些DLL的——这种工作本来最好应当由PsSetLoadImageNotifyRoutine来完成。

  创建新进程后,KAV给Kernel32.dll打上补丁,这样输出表就会指向所有的DLL——往调用内核层kav的驱动部分的thunk中加载例行程序(例如LoadLibraryA)。另外,KAV还修改它的代码的部分保护以及数据段,以便允许用户层进行读操作。

  KAV设置了PsLoadImageNotifyRoutine关联来检测kernel32.dll的加载,以便确定什么时候给kernel32的输出表打补丁。笔者想知道为什么KAV不只在PsLoadImageNotifyRoutine中直接工作,而是费尽千辛万苦地通过允许用户层来调用内核层来进行LoadLibrary关联。

  在新进程加载图片的时候,KAV会调用CheckInjectCodeForNewProcess函数,并且核查 kernel32是否被加载。如果Kernel32已经加载,那么它将安排APC队列给要执行补丁程序的进程。

.text:F82218B0 ; int __stdcall CheckInjectCodeForNewProcess(wchar_t *,PUCHAR ImageBase)
.text:F82218B0 CheckInjectCodeForNewProcess proc near ; CODE XREF: KavLoadImageNotifyRoutine+B5p
.text:F82218B0        ; KavDoKernel32Check+41p
.text:F82218B0
.text:F82218B0 arg_0      = dword ptr 4
.text:F82218B0 ImageBase    = dword ptr 8
.text:F82218B0
.text:F82218B0  mov   al, byte_F82282F9
.text:F82218B5  push  esi
.text:F82218B6  test  al, al
.text:F82218B8  push  edi
.text:F82218B9  jz   short loc_F8221936
.text:F82218BB  mov   eax, [esp+8+arg_0]
.text:F82218BF  push  offset aKernel32_dll ; "kernel32.dll"
.text:F82218C4  push  eax       ; wchar_t *
.text:F82218C5  call  ds:_wcsicmp
.text:F82218CB  add   esp, 8
.text:F82218CE  test  eax, eax
.text:F82218D0  jnz   short loc_F8221936
.text:F82218D2  mov   al, g_FoundKernel32Exports
.text:F82218D7  mov   edi, [esp+8+ImageBase]
.text:F82218DB  test  al, al
.text:F82218DD  jnz   short KavInitializePatchApcLabel
.text:F82218DF  push  edi
.text:F82218E0  call  KavCheckFindKernel32Exports
.text:F82218E5  test  al, al
.text:F82218E7  jz   short loc_F8221936
.text:F82218E9
.text:F82218E9 KavInitializePatchApcLabel:       ; CODE XREF: CheckInjectCodeForNewProcess+2Dj
.text:F82218E9  push  '3SeB'     ; Tag
.text:F82218EE  push  30h       ; NumberOfBytes
.text:F82218F0  push  0        ; PoolType
.text:F82218F2  call  ds:ExAllocatePoolWithTag
.text:F82218F8  mov   esi, eax
.text:F82218FA  test  esi, esi
.text:F82218FC  jz   short loc_F8221936
.text:F82218FE  push  edi
.text:F82218FF  push  0
.text:F8221901  push  offset KavPatchNewProcessApcRoutine
.text:F8221906  push  offset loc_F82218A0
.text:F822190B  push  offset loc_F8221890
.text:F8221910  push  0
.text:F8221912  call  KeGetCurrentThread
.text:F8221917  push  eax
.text:F8221918  push  esi
.text:F8221919  call  KeInitializeApc
.text:F822191E  push  0
.text:F8221920  push  0
.text:F8221922  push  0
.text:F8221924  push  esi
.text:F8221925  call  KeInsertQueueApc
.text:F822192B  test  al, al
.text:F822192D  jnz   short loc_F822193D
.text:F822192F  push  esi       ; P
.text:F8221930  call  ds:ExFreePool
.text:F8221936
.text:F8221936 loc_F8221936:       ; CODE XREF: CheckInjectCodeForNewProcess+9j
.text:F8221936        ; CheckInjectCodeForNewProcess+20j ...
.text:F8221936  pop   edi
.text:F8221937  xor   al, al
.text:F8221939  pop   esi
.text:F822193A  retn  8
.text:F822193D ; ---------------------------------------------------------------------------
.text:F822193D
.text:F822193D loc_F822193D:       ; CODE XREF: CheckInjectCodeForNewProcess+7Dj
.text:F822193D  pop   edi
.text:F822193E  mov   al, 1
.text:F8221940  pop   esi
.text:F8221941  retn  8

来源:赛迪网    作者:杜莉    责编:豆豆技术应用

正在加载评论...