程序兼容性助手 (PCA:Program Compatibility Assistant)

目录

程序兼容性助手 (PCA:Program Compatibility Assistant) 

1. 简介

2. 文件存储位置

3. 以下注册表键存储一些已知兼容性问题的程序数据库。

4. 以下注册表键存储程序所应用的兼容性方案:

5. 以下注册表键存储当前用户的所有程序列表,不管有没有应用兼容模式:

6. 以下注册表值存储无需 PCA 检查的应用程序,   这些程序包含具有 UAC 运行级别(管理员或受限用户)的标记。

7. 组策略可以设置禁用所有程序的 PCA

8. 相关引用

应用程序兼容性缓存(Application Compatibility Cache / Shimcache)

1. 简介

2. 原理

3. 工作方式

4. 容量

5. Shim 子项

    (1) 关联的文件完整路径。

    (2) 在 Windows 2003 和 XP 64 位及更早版本中的文件大小。

    (3) 应用程序的最近执行时间(LastModifiedTime $Standard_Information)

    (4) 是否已执行标志

    (5) 在 Windows XP 32 位上,还有个可执行文件最近更新时间戳(Last Update Time) 。

6. Shim 数据库缓存位置

7. 工具

8. 相关引用



程序兼容性助手 (PCA:Program Compatibility Assistant) 

    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags]

1. 简介

    程序兼容性助手 (PCA) 是 Windows Vista® 和 Windows Server® 2008 中的一项新功能,
    用于监视由用户安装和运行的程序,并检测已知兼容性问题,提示用户使用推荐的设置重新安装,用户也可忽略提示继续运行。
    旨在保持对现有桌面应用程序对新版本的 Windows 操作系统(如 Shimcache 和 Amcache 工件)的支持。

    PCA 仅包含以下的信息:
    * 执行时具有图形界面的程序
    * 已安装的程序
    * 从可移植(portable)可执行文件执行的程序
    * 作为 GUI 程序执行的命令行程序(例如,通过 Windows 资源管理器双击 CLI 可执行文件)

    PCA 识别:
    * 由版本不匹配导致的程序安装错误
    * 由于已弃用的二进制文件
    * 由于用户帐户控制 (UAC) 设置而导致的运行时问题

    PCA 链接服务名称:
        PcaSvc
    可执行文件的路径:
        C:\Windows\system32\svchost.exe -k LocalSystemNetworkRestricted

2. 文件存储位置

    PCA 存储的信息分为 3 个基于文本的文件:
    (1) PcaAppLaunchDic.txt
        从取证的角度来看,它是最有价值的文件,也是程序执行的可靠来源。
        每行一个条目,包含可执行文件的完整路径和以 UTC 格式的执行时间戳(在竖线分隔的字符串中)。
            例: %SystemRoot%\FOLDER\executable.exe\|2023-05-25 01:20:30.123.

    (2) PcaGeneralDb0.txt and PcaGeneralDb1.txt:
        条目少于 PcaAppLaunchDic.txt 中的条目,大多数条目似乎与执行错误时退出代码(非 0x0 )相关。
        每行一个条目,在竖线分隔的字符串中包含以下信息:
        * 执行时间戳(Execution timestamp)
        * 执行状态(Execution status)
        * 可执行程序完整路径(Full path of the executable)
        * 可执行文件的描述及其供应商名称(Description of the executable and its vendor name)
        * 可执行文件版本(File version)
        * 可执行程序 ID, 在 Amcache 注册表配置单元(InventoryApplicationFile 键)中引用。
        * 退出代码(Exit code of the execution)

3. 以下注册表键存储一些已知兼容性问题的程序数据库。

    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store]

4. 以下注册表键存储程序所应用的兼容性方案:

    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]

    其中包括程序完整路径的键名称和正在应用的兼容模式名称的字符串值。

    参考:
        https://www.jianshu.com/p/e413455729d0#Windows 兼容模式具体项

    系统将把它复制到 HKEY_LOCAL_MACHINE 下,以应用到所有用户。

    但在显示 PCA 对话框之前自动应用 ELEVATECREATEPROCESS (提升(权限?)创建进程)兼容模式的情况除外。

5. 以下注册表键存储当前用户的所有程序列表,不管有没有应用兼容模式:

    [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted]

6. 以下注册表值存储无需 PCA 检查的应用程序,
   这些程序包含具有 UAC 运行级别(管理员或受限用户)的标记。

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant]
    "ExecutablesToExclude"=hex(7):...

7. 组策略可以设置禁用所有程序的 PCA

    策略名为 Turn Off Program Compatibility Assistant(关闭应用程序兼容性助理),位于
    Administrative Templates\Windows Components\Application Compatibility
    管理模板 - Windows 组件 - 应用程序兼容性
    gpedit.msc 中以下项中存储一些特定的检测方案
    Administrative Templates\System\Troubleshooting and Diagnostics\Application Compatibility Diagnostics
    管理模板 - 系统 - 疑难解答和诊断 - 应用程序兼容性诊断

8. 相关引用

    Application Compatibility: Program Compatibility Assistant (PCA)
    https://learn.microsoft.com/en-us/previous-versions/bb756937(v=msdn.10)

    AboutDFIR.com - Andrew Rathbun and Lucas Gonzalez - New Windows 11 Pro (22H2) Evidence of Execution Artifact!
    https://aboutdfir.com/new-windows-11-pro-22h2-evidence-of-execution-artifact/

    13Cubed - A New Program Execution Artifact - Windows 11 22H2 Update!
    https://www.youtube.com/watch?v=rV8aErDj06A

:: -----------------------------------------------------------------------------------------------------------

应用程序兼容性缓存(Application Compatibility Cache / Shimcache)

    Windows Server 2003 和 Windows XP 64-bit 起:
    [HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\AppCompatCache]
    "AppCompatCache"=hex:(REG_BINARY)

    Windows XP 32-bit:
    [HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\AppCompatibility]
    "AppCompatCache"=hex:(REG_BINARY)

1. 简介

    Application Compatibility Cache 也称为 Shimcache,是 Application Compatibility Infrastructure (Shim Infrastructure) 的一部分,在 Windows XP 中引入。

    填充程序基础结构(Shim Infrastructure)旨在识别应用程序兼容性问题,并保持对现有软件对新版本的 Windows 操作系统的支持。

2. 原理

    Shim 基础架构实现了一种“应用程序编程接口挂钩”(application programming interface (API) hooking)形式,以便将应用程序发出的 API 调用重定向到包含存根函数的替代库,称为 Shim。通过 Shims 使应用程序与新版本的 Windows 兼容的过程称为“填充”。

    Shimcache 包含有关已进行此类查找的文件的元数据,用于优化和提高最终后续查找的速度。

3. 工作方式

    每当从特定路径执行程序时,都会创建一个 Shimcache 条目。

    但是,从 Windows Vista 和 Windows Server 2008 操作系统开始,还可以为以交互方式访问的目录中的文件创建条目。

    实际上,使用 explorer.exe 浏览目录将为存储在目录中的可执行文件生成 Shimcache 条目(如果可执行文件在 Windows 资源管理器窗口中可见)。

    Shimcache 条目仅在系统关闭时写入注册表。因此,自上次系统引导以来生成的 Shimcache 条目仅存储在内存中。

4. 容量

    Windows XP / Windows Server 2003 中最多存储 96 个 Shimcache 条目,

    从 Windows Vista 和 Windows Server 2008 操作系统开始最多可以存储 1024 个条目。

    虽然在删除关联文件时未删除 Shimcache 条目,但 Shimcache 条目可能会被覆盖,并且信息可能会丢失,因为最早的条目被新数据替换。

    Shimcache 条目根据系统上的活动级别进行滚动,历史数据在 Windows Server 上可以延长长达几个月,而用户活动历史最少。

5. Shim 子项

    (1) 关联的文件完整路径。

    (2) 在 Windows 2003 和 XP 64 位及更早版本中的文件大小。

    (3) 应用程序的最近执行时间(LastModifiedTime $Standard_Information)

    (4) 是否已执行标志

    (5) 在 Windows XP 32 位上,还有个可执行文件最近更新时间戳(Last Update Time) 。

    (3) 应用程序的最近执行时间
        * 不一定反映执行时间。事实上,Shimcache 条目并不直接与 insert / executed 时间戳相关联。
          某些可执行文件(如 PsExesvc)的 LastModifiedTime 对应于其执行时间戳 (因为二进制文件会自动下载/上传和执行) 。
        * 缓存条目位置,以 0 开头的数值表示 Shimcache 中的插入位置。
          最低值表示最近被填充程序的时间。但是,有时可以就地更新 Shimcache 条目,而无需生成具有较低位置的新条目。

    (4) 是否已执行标志
        * 从 Windows Vista/Windows Server 2008 到 Windows 8.1/Windows Server 2012 R2, Insert Flag(插入标志)被设置后,表示该条目已执行。
        * 从 Windows 10/Windows Server 2016 开始,此标志不再存在,因此 Shimcache 条目不一定反映执行时间戳(因为也可能是 explorer.exe 在浏览目录中的执行文件时创建条目)。

6. Shim 数据库缓存位置

    %windir%\AppPatch\sysmain.sdb

7. 工具

    * AppCompatCacheParser 工具(KAPE 关联模块 AppCompatCacheParser)
    * ShimCacheParser.py Python 脚本可用于解析 Shimcache 条目。
    * Chainsaw 
    * Volatility2’s shimcache 

    (1) 默认情况下,前两个工具都将解析在配置单元(SYSTEM hive)中找到的所有 ControlSet。

    # 解析正在运行的系统配置单元.
        AppCompatCacheParser.exe --csv <OUTPUT_FOLDER>
        python ShimCacheParser.py --local -o <OUTPUT_FILE>

    # 解析指定的系统配置单元
    # --nl:强制解析 Hive 的选项,即使 event 处于“dirty”状态并且没有可用的事务日志(transaction logs)。
        AppCompatCacheParser.exe [--nl] -f <SYSTEM_HIVE_FILE> --csv <OUTPUT_FOLDER>
        python ShimCacheParser.py [--hive <SYSTEM_HIVE_FILE> | --reg <EXPORTED_SYSTEM_FILE>] -o <OUTPUT_FILE>

    (2) Chainsaw 可用于使用 novel techniques 技术绘制基于时间戳的 Shimcache 条目时间线。

    # https://labs.withsecure.com/tools/chainsaw-analyse-shimcache#novel techniques
    
    # tspair: Enable near timestamp pair detection between shimcache and amcache for finding additional insertion timestamps for shimcache entries.
    # tspair:在 shimcache 和 amcache 之间启用相近时间戳配对检测,以查找 shimcache 条目的 additional(其他?)插入时间戳。

        chainsaw analyse shimcache <SYSTEM_HIVE> --regexfile ./analysis/shimcache_patterns.txt [--amcache <AMCACHE_HIVE> --tspair] --output <OUTPUT_CSV>

    (3) Volatility2 的 shimcache 插件可用于提取内存中的 Shimcache 条目(自上次系统启动以来生成)。

        vol.py -f <MEMORY_IMAGE> --profile=<PROFILE> shimcache

8. 相关引用

    Application Compatibility Cache / Shimcache
    https://artefacts.help/windows_shimcache.html

    Microsoft - Application Compatibility Database
    https://docs.microsoft.com/en-us/windows/win32/devnotes/application-compatibility-database

    Mandiant - TIMOTHY PARISI - Caching Out: The Value of Shimcache for Investigators
    https://www.fireeye.com/blog/threat-research/2015/06/caching_out_the_val.html

    FireEye - Shimcache whitepaper
    https://www.fireeye.com/content/dam/fireeye-www/services/freeware/shimcache-whitepaper.pdf

    Alex Ionescu - Secrets of the Application Compatilibity Database (SDB) - Part 1
    http://www.alex-ionescu.com/?p=39

    LIFARS - Amcache and Shimcache Forensics
    https://lifars.com/wp-content/uploads/2017/03/Technical_tool_Amcache_Shimcache.pdf

    WithSecure - Markus Tuominen & Mehmet Mert Surmeli - Unleashing the Power of Shimcache with Chainsaw
    https://labs.withsecure.com/tools/chainsaw-analyse-shimcache

    详解 Windows Shim 的攻防利用
    https://www.sohu.com/a/114212574_354899

 

  • 12
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值