Windows安全中心(病毒和威胁防护)的注册

devtools/2025/2/19 16:20:35/

文章目录

  • Windows安全中心(病毒和威胁防护)的注册
    • 1. 简介
    • 2. WSC注册初探
    • 3. WSC注册原理分析
    • 4. 关于AMPPL
    • 5. 参考

Windows安全中心(病毒和威胁防护)的注册

本文我们来分析一下Windows安全中心(Windows Security Center简称WSC)的注册原理,以及其中的一些比较有意思的技术性问题。

1. 简介

通常情况下,如果我们安装了一些第三方的安全软件之后,就会接管Windows的安全服务(Windows Defender);这里主要的原因大概是防止系统安全软件太多,导致Windows性能下降。可以看到如下:
在这里插入图片描述

以火绒为例,可以看到当系统安装了火绒安全软件之后,在Windows 安全中心的病毒和威胁防护就可以看到注册的安全软件信息了。

当系统注册了第三方安全软件之后,Windows Defender防病毒服务就停止了;这是Windows为第三方安全软件提供的一个入口,但是目前市面上很大安全软件还比不上Windows自带的Defender,也是比较讽刺。

那么怎么样才能将自己的安全软件注册到Windows安全中心呢?大致的步骤如下:

  1. 成为MVI会员。
  2. 微软提供一个内部的私有接口。
  3. 提供相关签名证书。

通过上面流程,我们就可以开发自己的安全软件,并且将自己的安全软件注册到WSC种。那么有没有办法可以绕过上面这些呢?这就是本文需要分析的技术性知识点。

2. WSC注册初探

WSC如果被注册成功之后,可以通过命令get-wmiObject -namespace root\SecurityCenter2 -class AntiVirusProduct来查询相关信息,结果如下:

> get-wmiObject  -namespace root\SecurityCenter2 -class AntiVirusProduct__GENUS                  : 2
__CLASS                  : AntiVirusProduct
__SUPERCLASS             :
__DYNASTY                : AntiVirusProduct
__RELPATH                : AntiVirusProduct.instanceGuid="{D68DDC3A-831F-4fae-9E44-DA132C1ACF46}"
__PROPERTY_COUNT         : 6
__DERIVATION             : {}
__SERVER                 : DESKTOP-1SIKOAK
__NAMESPACE              : ROOT\SecurityCenter2
__PATH                   : \\DESKTOP-1SIKOAK\ROOT\SecurityCenter2:AntiVirusProduct.instanceGuid="{D68DDC3A-831F-4fae-9E44-DA132C1ACF46}"
displayName              : Windows Defender
instanceGuid             : {D68DDC3A-831F-4fae-9E44-DA132C1ACF46}
pathToSignedProductExe   : windowsdefender://
pathToSignedReportingExe : %ProgramFiles%\Windows Defender\MsMpeng.exe
productState             : 393472
timestamp                : Tue, 17 Dec 2024 02:37:41 GMT
PSComputerName           : DESKTOP-1SIKOAK__GENUS                  : 2
__CLASS                  : AntiVirusProduct
__SUPERCLASS             :
__DYNASTY                : AntiVirusProduct
__RELPATH                : AntiVirusProduct.instanceGuid="{4C17E7AE-043A-D732-91B8-D139C9EB6B26}"
__PROPERTY_COUNT         : 6
__DERIVATION             : {}
__SERVER                 : DESKTOP-1SIKOAK
__NAMESPACE              : ROOT\SecurityCenter2
__PATH                   : \\DESKTOP-1SIKOAK\ROOT\SecurityCenter2:AntiVirusProduct.instanceGuid="{4C17E7AE-043A-D732-91B8-D139C9EB6B26}"
displayName              : 火绒安全软件
instanceGuid             : {4C17E7AE-043A-D732-91B8-D139C9EB6B26}
pathToSignedProductExe   : C:\Program Files\Huorong\Sysdiag\bin\wsctrlsvc.exe
pathToSignedReportingExe : C:\Program Files\Huorong\Sysdiag\bin\wsctrlsvc.exe
productState             : 266240
timestamp                : Tue, 17 Dec 2024 02:37:36 GMT
PSComputerName           : DESKTOP-1SIKOAK

在这里可以看到有两个类信息:

  1. Windows Defender表示默认的Windows Defender。
  2. 火绒安全软件表示火绒。

这里可以看到一个非常重要的信息,WSC注册的进程为C:\Program Files\Huorong\Sysdiag\bin\wsctrlsvc.exe

那么我们就可以请出IDA和调试神器WINDBG来分析和调试一下WSC注册的原理。

3. WSC注册原理分析

由于我们需要成为MVI会员之后,才能有相关私有SDK文档,这里我们就分析一下wsctrlsvc.exe这个程序,大致看一下私有SDK是怎么使用的。

我们可以看到WSC相关的主要文件有如下几个:

  1. wscisvif.dll这个是WSC客户端的接口提供DLL。
  2. wscapi.dll这个是WSC客户端的核心DLL。
  3. wscsvc.dll这个是WSC的核心服务DLL。

可以看到私有SDK就是对wscisvif.dll未公开的SDK的调用,我们可以对这些使用接口进行分析,可以看到核心接口如下:

virtual long _IWscAVStatus4<class CWscIsv>::Register(unsigned short *, unsigned short *, int, int)
virtual long _IWscAVStatus4<class CWscIsv>::Unregister(void)
virtual long _IWscAVStatus4<class CWscIsv>::UpdateStatus(enum  _WSC_SECURITY_PRODUCT_STATE, int)
virtual long _IWscAVStatus4<class CWscIsv>::InitiateOfflineCleaning(unsigned short *, unsigned short *)
virtual long _IWscAVStatus4<class CWscIsv>::NotifyUserForNearExpiration(unsigned long)

可以发现核心接口就是如下三个:

  1. Register注册WSC产品。
  2. Unregister反注册WSC产品。
  3. UpdateStatus更新产品的状态。

根据这些分析我们就可以自己向Windows安全中心注册自己的安全软件了,例如可以如下(这里注册了一个我的安全软件产品):
在这里插入图片描述

4. 关于AMPPL

通过上面的分析,我们成功向Windows安全中心注册了自己的安全软件,但是在某些情况下可能会失败,并且Register返回的结果为0x800704dc;这就是AMPPL安全检测导致的结果。

我们分析s_wscRegisterSecurityProduct函数,可以导致得到如下的判断:

if ( type == SECURITY_PRODUCT_TYPE_ANTIVIRUS )
{ValidateCallerAMPPL((int *)&v34, a1, L"s_wscRegisterSecurityProduct", a3, a4);v12 = (unsigned int)v34;if ( (_DWORD)v34 )goto Exit1;
} 

ValidateCallerAMPPL这个函数就是检测AMPPL的,大致检测的结果如下:

v12 = NtQueryInformationProcess(v9,  61, &v15, 1);
if ( (unsigned __int8)((v15.Level & 7) - 1) > IsAm1PPL || (v15.Level & 0xF0) != 0x30 )IsAmPPL = 0;

也就是说我们需要检测进程AMPPL的标记,通过NtQueryInformationProcess查询ProcessProtectionInformation,改查询得到的结构体信息如下:

typedef enum _PS_PROTECTED_SIGNER
{PsProtectedSignerNone = 0,PsProtectedSignerAuthenticode = 1,PsProtectedSignerCodeGen = 2,PsProtectedSignerAntimalware = 3,PsProtectedSignerLsa = 4,PsProtectedSignerWindows = 5,PsProtectedSignerWinTcb = 6,PsProtectedSignerMax = 7
} PS_PROTECTED_SIGNER;typedef enum _PS_PROTECTED_TYPE
{PsProtectedTypeNone = 0,PsProtectedTypeProtectedLight = 1,PsProtectedTypeProtected = 2,PsProtectedTypeMax = 3
} PS_PROTECTED_TYPE;typedef union _PS_PROTECTION
{UCHAR Level;struct{int Type : 3;int Audit : 1;int Signer : 4;} Flags;
} PS_PROTECTION, *PPS_PROTECTION;

这些结构体字段中Type含义如下:

  • PsProtectedTypeNone (0) - the process is not running as protected.

  • PsProtectedTypeProtectedLight (1) - the process is running as light-protected (PPL).

  • PsProtectedTypeProtected (2) - the process is running as fully-protected.

Signer字段的含义如下:

  • PsProtectedSignerNone (0) - the process has no signature that grants it protection.

  • PsProtectedSignerAuthenticode (1) - the process has an Authenticode signature.

  • PsProtectedSignerCodeGen (2) - the process has a Code Generation signature.

  • PsProtectedSignerAntimalware (3) - the process has an Antimalware signature.

  • PsProtectedSignerLsa (4) - the process has an LSA signature.

  • PsProtectedSignerWindows (5) - the process has a Windows signature.

  • PsProtectedSignerWinTcb (6) - the process has a WinTCB (trusted computer base) signature.

  • PsProtectedSignerWinSystem (7) - the process has a WinSystem signature.

  • PsProtectedSignerApp (8) - the process has a Store Application signature.

在进程启动的时候,内核会更加启动进程是否有签名(或者签名的类型)来设置相关值,流程为:

NtCreateUserProcess --> SeQuerySigningPolicy

这里似乎看起来又比较麻烦了,因为需要防病毒MVI相关证书才行。这里NtQueryInformationProcess查询的是EPROCESS中的字段的值,我们只要想办法修改这些值就可以了,例如我们可以将我们自己的进程EPROCESS修改为如下:

kd> dx -id 0,0,94040040 -r1 (*((ntkrpamp!_PS_PROTECTION *)0x940403a6))
(*((ntkrpamp!_PS_PROTECTION *)0x940403a6))                 [Type: _PS_PROTECTION][+0x000] Level            : 0x31 [Type: unsigned char][+0x000 ( 2: 0)] Type             : 0x1 [Type: unsigned char][+0x000 ( 3: 3)] Audit            : 0x0 [Type: unsigned char][+0x000 ( 7: 4)] Signer           : 0x3 [Type: unsigned char]

这样我们就可以完成ValidateCallerAMPPL这个函数的检测了,WSC也完全正常注册了。

5. 参考

WSC本来就是一个私有的接口文档,参考资料也非常少,下面是网上相关的一些参考文章:

  1. https://bbs.kanxue.com/thread-282498.htm
  2. https://github.com/m417z/ntdoc/blob/main/descriptions/ps_protection.md
  3. https://stackoverflow.com/questions/3698285/how-can-i-tell-the-windows-security-center-that-im-an-antivirus
  4. https://learn.microsoft.com/en-us/defender-xdr/virus-initiative-criteria

http://www.ppmy.cn/devtools/143279.html

相关文章

Vulhub:Jackson[漏洞复现]

CVE-2017-7525(Jackson反序列化) 启动漏洞环境 docker-compose up -d 阅读vulhub给出的漏洞文档 cat README.zh-cn.md # Jackson-databind 反序列化漏洞&#xff08;CVE-2017-7525&#xff09; Jackson-databind 支持 [Polymorphic Deserialization](https://github.com/Fas…

(六)Spring Cloud Alibaba 2023.x:Sentinel 流量控制与熔断限流实现

目录 前言 准备 下载sentinel控制台 项目集成 引入依赖 配置yml文件 限流控制 Sentinel注解 前言 在微服务架构中&#xff0c;流量控制组件至关重要&#xff0c;它是保障系统稳定性与高可用性的核心手段之一 。Sentinel 是面向分布式、多语言异构化服务架构的流量治理…

Axure9设置画布固定

在使用AxureRP9设计原型时&#xff0c;如果遇到画布在拖动时变得难以控制&#xff0c;可以尝试在Windows系统中通过‘文件’>‘首选项’&#xff0c;或在Mac系统中通过‘AxureRP9’>‘偏好设置’进行设置&#xff0c;以稳定画布的行为。 现象 页面底层的画布&#xff0…

类和对象 如何理解面向对象

目录 1. 面向对象的初步认知 2. 类定义和使用 3. 类的实例化 4. this引用 5. 对象的构造及初始化 6. 封装 7. static成员 8. 代码块 9. 内部类 10. 对象的打印 正文开始 1. 面向对象的初步认知 1.1 什么是面向对象 Java是一门纯面向对象的语言(Object Oriented Pro…

HarmonyOS 非线性容器LightWeightMap 常用的几个方法

LightWeightMap可用于存储具有关联关系的key-value键值对集合&#xff0c;存储元素中key值唯一&#xff0c;每个key对应一个value。 LightWeightMap依据泛型定义&#xff0c;采用轻量级结构&#xff0c;初始默认容量大小为8&#xff0c;每次扩容大小为原始容量的两倍。 集合中k…

Not using native diff for overlay2, this may cause degraded performance……

问题现象 案例&#xff1a;Anolis 8.9&#xff08;4.19.91-26.an8.x86_64&#xff09; Overlay2存储驱动程序&#xff09; 当我们安装好Docker之后&#xff0c;通过systemctl status docker -l 会发现有一个告警信息&#xff1a;levelwarning msg"Not using native dif…

【时间序列分析】距离相关系数(Distance Correction)理论及Python代码实现

文章目录 1. 距离相关系数算法介绍2. Python代码实现3. 优缺点及作用4.总结4.1 线性依赖关系4.2 非线性依赖关系4.3 单调依赖关系4.4 复杂依赖关系 1. 距离相关系数算法介绍 距离相关系数&#xff1a;研究两个变量之间的独立性&#xff0c;距离相关系数为0表示两个变量是独立的…

使用二分查找法找出给定点距离给定点集合距离最近的点

1、场景描述 给定点Point A &#xff08;x,y&#xff09;和 直线点集合 Points [(x1,y1),(x2,y2),(x3,y3),(x4,y4),(x5,y5)......],计算出集合中距离点A最近的一个点 &#xff08;如果集合中的两个点距离A点最近且相等&#xff0c;则只取其中一个&#xff09; 2、代码&#x…