浅谈杀软挂钩技术
2020-12-23 11:3:8 Author: mp.weixin.qq.com(查看原文) 阅读量:0 收藏

2020年即将结束,我看过许多不同种类的杀毒规避方法。值得注意的是,之前的反钩挂技术再次兴起,可以应用于AV和EDR系统。如果我们被钩住了,那是谁在钩我们?若要检查杀毒软件或EDR系统是否已经安装好,可以用WMIC查询Windows安全中心记录的杀软。

wmic /node:localhost /namespace:\\root\SecurityCenter2 pathAntiVirusProduct Get DisplayName | findstr /V /B /C:displayName || echo NoAntivirus installed

(由StackOverflow的Sam Denty提供)

该方法适用于大多数情况。但如果杀毒软件或EDR系统注册了Windows安全中心的命名空间,那么该方法只返回一个字符串。如果软件尚未注册,那么查询失败。由于我们依靠的是安全无毒的软件来注册,我决定用不同的路径。本文用于记录杀毒后的残留物:计算机上的杀软能指出是否已经安装了安全无毒的软件,这样一来,我们就不用依赖Windows安全中心的命名空间。

本文描述了以下几款杀软:

小红伞(Avira):无法检测挂钩,可以定位驱动程序/minifilters

- F-secure:无法检测挂钩,可以定位驱动程序/minifilters

诺顿(Norton):3个被钩住的DLL,可以定位驱动程序/minifilters

- 趋势科技(TrendMicro):3个被钩住的DLL,可以定位驱动程序/minifilters

- WebRoot:5个被钩住的DLL,可以定位驱动程序/minifilters

比特梵德(BitDefender):6个被钩住的DLL,可以定位驱动程序/minifilters

- MalwareBytes:8个被钩住的DLL,可以定位驱动程序/minifilters

以上杀软纯属随机筛选,排位也是随机的。攥写本文的目的是为了回答以下问题:

  1. 什么功能会被钩住?

  2. 如果系统上有杀毒软件,那么是哪个杀毒软件?

小红伞(Avira)

驱动程序:

名称描述路径
avkmgr.sys小红伞管理驱动程序C:\Windows\System32\Drivers\
avipbb.sys小红伞增强安全性能的驱动程序C:\Windows\System32\Drivers\
avusbflt.sys小红伞USB过滤驱动程序C:\Windows\System32\Drivers\
avdevprot.sys小红伞USB功能驱动程序C:\Windows\System32\Drivers\
avnetflt.sys小红伞WFP网络驱动程序C:\Windows\System32\Drivers\
avgntflt.sys小红伞Minifilter驱动程序C:\Windows\System32\Drivers\

F-secure

驱动程序:

名称
描述
路径
nif2s64.sysF-Secure NIF2核心驱动程序

ProgramFilesx86\F-Secure\

Antivirus\Ultralight\..\
fshs.sysDG 64位内核模块

ProgramFilesx86\F-Secure\

Antivirus\Ultralight\..\
fsulgk.sysF-Secure Gatekeeper 64 位

ProgramFilesx86\F-Secure\

Antivirus\Ultralight\..\

诺顿(Norton)

驱动程序:

名称
描述
路径
BHDrvx64.sysBash驱动程序

ProgramFile\NortonSecurity

\NortonData\..\
IDSVia64.sysIDS核心驱动程序

ProgramFile\NortonSecurity

\NortonData\..\
SymEvnt.sys门铁克事件平台

ProgramFile\NortonSecurity

\NortonData\..\

被挂钩的函数

KERNELBASE.DLL

VirtualAllocExCreateFileMappingWCreateFileMappingNumaW
CreateFileWMapViewOfFileVirtualProtect
HeapCreateVirtualAllocMapViewOfFileEx
CreateRemoteThreadExWriteProcessMemoryVirtualProtectEx

NTDLL.DLL

RtlAddVectoredExceptionHandler

RtlRemoveVectoredExceptionHandler

LdrLoadDll
RtlCreateHeapNtSetInformationProcessNtMapViewOfSection
NtWriteVirtualMemoryNtCreateSectionNtProtectVirtualMemory
NtCreateFileNtCreateProcessNtCreateThreadEx
NtCreateUserProcessKiUserExceptionDispatcherN/A

KERNEL32.DLL

CreateFileMappingASetProcessDEPPolicyVirtualAlloc
MapViewOfFileCreateFileMappingWVirtualProtect
HeapCreateMapViewOfFileExCreateRemoteThread
VirtualAllocExVirtualProtectExWriteProcessMemory
WinExecN/AN/A

趋势科技(TrendMicro)

驱动程序:

名称
描述
路径
TMBEC64.sys趋势科技早期启动驱动程序C:\Windows\System32\Drivers\
tmnciesc.sys趋势科技NICE扫描器C:\Windows\System32\Drivers\
tmeevw.sys趋势科技鹰眼驱动程序C:\Windows\System32\Drivers\
tmeyes.sys趋势科技鹰眼驱动程序模块C:\Windows\System32\Drivers\
TMUMH.sys趋势科技UMH驱动程序x64C:\Windows\System32\Drivers\
tmusa.sys趋势科技Osprey扫描驱动程序C:\Windows\System32\Drivers\

DLL:

名称
描述
路径
tmmon64.dll趋势科技UMH检测引擎System32\tmumh\20019\..\
TmUmEvt64.dll趋势科技用户模式钩子System32\tmumh\20019\..\
TmAMSIProvider64.dll趋势科技AMSI提供者模块

System32\TmAMSI\TmAMSIProvider64.dll

被挂钩的函数

KERNELBASE.DLL

CreateFileACreateFileWLoadLibraryExW
CreateFileMappingWLoadLibraryExACreateRemoteThreadEx
VirtualAllocMapViewOfFileVirtualProtect
HeapCreateWriteProcessMemoryVirtualProtectEx
LoadLibraryALoadLibraryWN/A

KERNEL32.DLL

NTDLL.DLL

RtlCreateHeapLdrUnloadDllLdrUnloadDll
NtMapViewOfSectionNtUnmapViewOfSectionNtContinue
NtCreateSectionNtProtectVirtualMemoryNtCreateFile
NtSetContextThreadN/AN/A

WebRoot

驱动程序:

名称
描述
路径
WRkm.sysWebroot SecureAnywhereC:\Windows\System32\Drivers\

DLL

名称
描述
路径
WRusr.dllWebroot SecureAnywhereWindows\SysWOW64\WRusr.dll

被挂钩的函数

ADVAPI32.DLL

OpenSCManagerWOpenServiceWOpenSCManagerA
StartServiceWControlServiceCreateServiceA
CreateServiceWDeleteServiceOpenServiceA
StartServiceAWmiExecuteMethodWN/A

USER32.DLL

PostThreadMessageAPostMessageASendMessageA
SendMessageTimeoutASetWindowTextACreateWindowExA
SetWindowsHookExADrawTextExWCreateWindowExW
PostMessageWSendMessageWSetWindowTextW
PostThreadMessageWSendMessageTimeoutWSetWindowsHookExW
SetWinEventHookSendMessageCallbackWSendNotifyMessageW
ExitWindowsExMessageBoxTimeoutWSendMessageCallbackA

KERNELBASE.DLL

OutputDebugStringACreateProcessInternalWN/A

NTDLL.DLL

NtWaitForSingleObjectNtDeviceIoControlFileNtRequestWaitReplyPort
NtOpenProcessNtMapViewOfSectionNtTerminateProcess
NtDelayExecutionNtWriteVirtualMemoryNtOpenEvent
NtAdjustPrivilegesTokenNtQueueApcThreadNtCreateEvent
NtCreateSectionNtCreateThreadNtProtectVirtualMemory
NtTerminateThreadNtWaitForMultipleObjectsNtSetValueKey
NtAlpcConnectPortNtAlpcCreatePortNtAlpcCreatePortSection
NtAlpcCreateSectionViewNtAlpcSendWaitReceivePortNtAssignProcessToJobObject
NtConnectPortNtCreateMutantNtCreatePort
NtCreateSemaphoreNtCreateThreadExNtDeleteKey
NtDeleteValueKeyNtMakeTemporaryObjectNtOpenMutant
NtOpenSemaphoreNtOpenThreadNtQueueApcThreadEx
NtRequestPortNtSecureConnectPortNtSetContextThread
NtShutdownSystemNtSystemDebugControlCsrClientCallServer

URLMON.DLL

URLDownloadToFileWURLDownloadToFileAN/A

WININET.DLL

InternetOpenAInternetCloseHandleInternetOpenUrlA

GDI32.DLL

KERNEL32.DLL

RPCRTT4.DLL

RpcSendRpcSendReceiveNdrSendReceive

比特梵德(BitDefender)

驱动程序:

名称
描述
路径
atc.sysBitDefender主动威胁服务C:\Windows\System32\Drivers\

DLL:

名称描述路径
bdhkm64.dllBitDefender钩住DLLProgram Files\BitDefender AntivirusFree\bdkdm\...\
atcuf64.dllBitDefender主动威胁服务Program Files\BitDefender AntivirusFree\atcuf\...\

被挂钩的函数

KERNELBASE.DLL

DefineDosDeviceWCreateProcessWCreateProcessA
CreateProcessInternalACreateProcessInternalWPeekConsoleInputW
CloseHandleDeleteFileWOpenThread
CreateRemoteThreadExGetProcAddressMoveFileWithProgressW
MoveFileExWGetModuleBaseNameWGetModuleInformation
GetModuleFileNameExWEnumProcessModulesSetEnvironmentVariableW
EnumDeviceDriversSetEnvironmentVariableAQueueUserAPC
GetLogicalProcessorInformationExLoadLibraryALoadLibraryW
GetLogicalProcessorInformationGetApplicationRecoveryCallbackEnumProcessModulesEx
PeekConsoleInputAReadConsoleInputAReadConsoleInputW
GenerateConsoleCtrlEventReadConsoleAReadConsoleW
CreateRemoteThreadN/AN/A

USER32.DLL

SetWindowsHookExWCallNextHookExFindWindowExA
SendMessageAPeekMessageAPeekMessageW
GetDesktopWindowSendMessageWSetWindowLongW
GetKeyStatePostMessageWEnumDesktopWindows
EnumWindowsGetMessageWSystemParametersInfoW
FindWindowWGetAsyncKeyStateSetPropW
FindWindowExWGetDCGetMessageA
SystemParametersInfoASendNotifyMessageWSetWinEventHook
PostMessageAUnhookWindowsHookExGetClipboardData
SetWindowLongASetClipboardDataSendNotifyMessageA
GetDCExGetKeyboardStateGetRawInputData
GetWindowDCRegisterRawInputDevicesSetWindowsHookExA
FindWindowASetPropAN/A

COMBASE.DLL

CoCreateInstanceCoGetClassObjectN/A

KERNEl32.DLL

Process32NextWCreateToolhelp32SnapshotMoveFileExA
MoveFileWithProgressADefineDosDeviceAN/A

GDI32.DLL

CreateDCWBitBltCreateCompatibleDC
CreateBitmapCreateDCACreateCompatibleBitmap

NTDLL.DLL

RtlImageNtHeaderExNtSetInformationThreadNtClose
NtOpenProcessNtMapViewOfSectionNtUnmapViewOfSection
NtTerminateProcessNtWriteVirtualMemoryNtDuplicateObject
NtReadVirtualMemoryNtAdjustPrivilegesTokenNtQueueApcThread
NtCreateProcessExNtCreateThreadNtResumeThread
NtAlpcConnectPortNtAlpcCreatePortNtAlpcSendWaitReceivePort
NtCreateProcessNtCreateThreadExNtCreateUserProcess
NtQuerySystemEnvironmentValueExNtRaiseHardErrorNtSetContextThread
NtSetSystemEnvironmentValueExRtlWow64SetThreadContextRtlReportException

MalwareBytes

驱动程序:

名称
描述
路径
mbae64.sysMalwareBytes反漏洞利用C:\Windows\System32\Drivers\
farft.sysMalwareBytes Bytes AntiransomwareC:\Windows\System32\Drivers\
MbamChameleon.sysMalwareBytes ChameleonC:\Windows\System32\Drivers\
mbam.sysMalwareBytes实时保护C:\Windows\System32\Drivers\
mbamswissarmy.sysMalwareBytes SwissArmyC:\Windows\System32\Drivers\
mwac.sysMalwareBytes网络保护C:\Windows\System32\Drivers\

DLL:

名称
描述
路径
mbae.dllMalwareBytes反漏洞利用Program Files\MalwareBytes\AntiMal ware\mbae.dll

被挂钩的函数

MSCVRT.DLL

WSA_32.DLL

SHELL32.DLL

ShellExecuteWShellExecuteExWN/A

NTDLL.DLL

ResolveDelayLoadedAPIGetDllHandleCreateProcessInternalW
NtAllocateVirtualMemoryNtProtectVirtualMemoryN/A

KERNELBASE.DLL

VirtualAllocExCreateProcessWCreateProcessInternalW
GetModuleHandleWCreateFileWLoadLibraryExW
VirtualProtectHeapCreateVirtualAlloc
WriteProcessMemoryCreateFileAVirtualProtectEx
CreateProcessACreateProcessInternalAN/A

URLMON.DLL

URLDownloadToFileWURLDownloadToCacheFileAURLDownloadToCacheFileW
URLDownloadToFileAURLOpenBlockingStreamAURLOpenBlockingStreamW
URLOpenStreamAURLOpenStreamWN/A

WININET.DLL

InternetReadFileInternetReadFileExWHttpOpenRequestW
HttpSendRequestWHttpSendRequestExWHttpSendRequestA
HttpSendRequestExAInternetOpenUrlAInternetOpenUrlW
HttpOpenRequestAN/AN/A

KERNEL32.DLL

SetProcessDEPPolicyCopyFileAMoveFileA
MoveFileWCopyFileWWinExec

总结

本文展现了杀软以下特点:

  • 一些杀软需要依靠旧的恶意软件方法和技术。

  • 一些杀软无法监测网络流量,若要检测网络流量,这些杀软必须是完全独立的软件,会向客户收取额外费用。

  • 一些杀软无法检测API转发,让恶意软件的作者有机会从NTDLL而不是KERNELBASE或KERNEL32的姐妹DLL发起功能调用,完全绕过API钩子。

许多杀软依靠YARA规则,或者YARA执行基本静态二进制分析的操作。

我在自己开发的键盘记录器上测试了本文提到的杀软。这个键盘记录器叫“UnderTaker.exe”,它用USER32.dll中的RegisterRawInputDevices和GetRawInputData函数键盘记录用户输入。在测试环境中,除了F-Secure和BitDefender,它基本规避了所有杀软。在本文所讲到的杀软里,能检测RegisterRawInputDevices和GetRawInputData函数的只有BitDefender。

POC IOC:

2a419d2ddf31ee89a8deda913abf1b25d45bb0dc59a93c606756cfa66acb0791

木星安全实验室(MxLab),由中国网安·广州三零卫士成立,汇聚国内多名安全专家和反间谍专家组建而成,深耕工控安全、IoT安全、红队评估、反间谍、数据保护、APT分析等高级安全领域,木星安全实验室坚持在反间谍和业务安全的领域进行探索和研究。

文章来源: https://mp.weixin.qq.com/s?__biz=MzU1Mzk4Mzc5MA==&mid=2247485544&idx=1&sn=485633c72653fc608dfb832523ffef77&chksm=fbebc229cc9c4b3f3dd25811db04bd48ebf01abcc3c4979d4c45cf0ec7d02e0dcf6c3ca8a96a&scene=58&subscene=0#rd
如有侵权请联系:admin#unsafe.sh