Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
macos_xprotect — 深入探究 Apple 内置恶意软件防护的教育性内容:签名数据库、YARA 规则、Gatekeeper 集成、修复二进制文件以及 macOS 检测流程。 | Kitploit
工具/GitHubGitHub/yo-yo-yo-jbo/macos_xprotect
防御工具恶意软件分析二进制分析学习与教育
GitHubyo-yo-yo-jbo/macos_xprotect

macos_xprotect

深入探究 Apple 内置恶意软件防护的教育性内容:签名数据库、YARA 规则、Gatekeeper 集成、修复二进制文件以及 macOS 检测流程。

查看仓库
311个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

macOS 简介 - XProtect

继续我关于 macOS 介绍的博客系列,我决定用一篇简短的博文专门介绍 XProtect。

什么是 XProtect?

XProtect 是 Apple 为 macOS 内置的防病毒和恶意软件签名系统。
它作为 XProtectService 的一部分运行,扫描应用程序和其他可执行内容以查找已知的恶意软件签名。
XProtect 在后台运行,由 Apple 通过 XProtectRemediator 机制静默更新(稍后会详细介绍)。
它有 3 个主要功能:

  • 基于签名的检测——它根据已知恶意软件签名数据库扫描文件。
  • 行为检测(XProtect Remediator)——在 macOS Monterey 中引入,使 XProtect 能够主动扫描并基于可疑行为(而不仅仅是静态签名)移除恶意软件。
  • 实时拦截——XProtect 在已知恶意软件运行之前阻止其执行。

传统 XProtect

目录 /Library/Apple/System/Library/CoreServices/XProtect.bundle 是包含 XProtect 配置和签名定义的主 bundle。
这是一个只读的系统目录,由 Apple 通过 XProtect 更新静默更新。
在其下,我们可以找到一些值得关注的文件,这些文件都由 Apple 定期更新,并受 System Integrity Protection (SIP) 保护。

XProtect.plist

文件 /Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.plist 存储 XProtect 用于检测已知威胁的恶意软件签名。
它包含将恶意软件家族映射到特定检测规则的条目,包括哈希和文件名模式。
以下是其中一个恶意软件家族——Bundalore 的示例:

root@kitploit:~
<dict>
        <key>Description</key>
        <string>OSX.Bundlore.D</string>
        <key>LaunchServices</key>
        <dict>
                <key>LSItemContentType</key>
                <string>com.apple.application-bundle</string>
        </dict>
        <key>Matches</key>
        <array>
                <dict>
                        <key>MatchFile</key>
                        <dict>
                                <key>NSURLTypeIdentifierKey</key>
                                <string>com.apple.applescript.script</string>
                        </dict>
                        <key>MatchType</key>
                        <string>Match</string>
                        <key>Pattern</key>
                        <string>46617364554153</string>
                </dict>
                <dict>
                        <key>MatchFile</key>
                        <dict>
                                <key>NSURLTypeIdentifierKey</key>
                                <string>com.apple.applescript.script</string>
                        </dict>
                        <key>MatchType</key>
                        <string>Match</string>
                        <key>Pattern</key>
                        <string>20006500630068006F002000</string>
                </dict>
                <dict>
                        <key>MatchFile</key>
                        <dict>
                                <key>NSURLTypeIdentifierKey</key>
                                <string>com.apple.applescript.script</string>
                        </dict>
                        <key>MatchType</key>
                        <string>Match</string>
                        <key>Pattern</key>
                        <string>20007C0020006F00700065006E00730073006C00200065006E00630020002D006100650073002D003200350036002D0063006600620020002D007000610073007300200070006100730073003A</string>
                </dict>
                <dict>
                        <key>MatchFile</key>
                        <dict>
                                <key>NSURLTypeIdentifierKey</key>
                                <string>com.apple.applescript.script</string>
                        </dict>
                        <key>MatchType</key>
                        <string>Match</string>
                        <key>Pattern</key>
                        <string>002D00730061006C00740020002D00410020002D00610020002D00640020007C002000620061007300680020002D0073</string>
                </dict>
        </array>
</dict>

这相当易读,唯一值得注意的是每个匹配中的 string 参数是十六进制表示,例如 002D00730061006C00740020002D00410020002D00610020002D00640020007C002000620061007300680020002D0073 对应 -salt -A -a -d | bash -s。
当然,这对恶意软件作者来说是一个金矿,因为他们确切知道要避免哪些模式。

XProtect.meta.plist

文件 /Library/Apple/System/Library/CoreServices/XProtect.bundle/XProtect.meta.plist 是一个元数据文件,为 XProtect 定义附加规则,包括执行策略和版本信息。
它指定了哪些 macOS 版本强制执行某些 XProtect 规则、检测到威胁后采取的操作,以及插件黑名单。
以下是一个示例:

root@kitploit:~
<key>JavaWebComponentVersionMinimum</key>
<string>1.6.0_45-b06-451</string>
<key>PlugInBlacklist</key>
<dict>
        <key>10</key>
        <dict>
                <key>com.apple.java.JavaAppletPlugin</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>14.8.0</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
                <key>com.apple.java.JavaPlugin2_NPAPI</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>14.8.0</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
                <key>com.macromedia.Flash Player ESR.plugin</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>18.0.0.382</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
                <key>com.macromedia.Flash Player.plugin</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>32.0.0.101</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
                <key>com.microsoft.SilverlightPlugin</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>5.1.41212.0</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
                <key>com.oracle.java.JavaAppletPlugin</key>
                <dict>
                        <key>MinimumPlugInBundleVersion</key>
                        <string>1.8.51.16</string>
                        <key>PlugInUpdateAvailable</key>
                        <true/>
                </dict>
        </dict>
</dict>

如你所见,这些包含“黑名单”插件的版本信息,例如。

XProtect.yara

在最近的版本中,XProtect 似乎开始支持 YARA。
文件 /Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.yara 包含若干文本格式的 YARA 规则,以下是其中的一个简短示例:

root@kitploit:~
rule XProtect_MACOS_SLEEPYSTEGOSAURUS_SYM {
    meta:
        description = "MACOS.SLEEPYSTEGOSAURUS.SYM"
        uuid = "BB4F7D16-C939-4047-A9AF-E74E7B51FAC1"
    strings:
        $a1 = { 45 78 65 63 43 6D 64 }
        $a2 = { 47 65 74 48 6F 73 74 49 6E 66 6F }
        $a3 = { 52 75 6E 53 63 72 69 70 74 }
        $a4 = { 52 75 6E 53 63 72 69 70 74 55 72 6C }
        $a5 = { 4C 61 75 6E 63 68 50 6C 69 73 74 }
        $a6 = { 43 68 65 63 6B 50 72 6F 63 65 73 73 }
        $a7 = { 43 68 65 63 6B 49 6E }
        $a8 = { 52 75 6E 43 6D 64 46 69 6C 65 }
        $a9 = { 53 68 6F 77 48 74 6D 6C }
        $a10 = { 50 6C 69 73 74 48 65 6C 70 65 72 }
        $a11 = { 4C 61 75 6E 63 68 64 48 65 6C 70 65 72 }
        $a12 = { 43 6F 6D 6D 61 6E 64 46 69 6C 65 }
        $a13 = { 57 72 69 74 65 50 6C 69 73 74 }
        $a14 = { 4A 53 4F 4E 46 69 6C 65 50 72 6F 63 65 73 73 6F 72 }
        $a15 = { 43 68 72 6F 6D 65 48 65 6C 70 65 72 }
        $a16 = { 53 61 6E 64 62 6F 78 65 72 }
    condition:
        Macho and filesize < 2MB and all of them
}

这不是一篇关于 YARA 规则的博文,但和之前一样——这对恶意软件作者来说是一个金矿(例如 43 68 65 63 6B 50 72 6F 63 65 73 73 就是 CheckProcess)。

gk.db

在这里你可以看到 Apple 如何设计 XProtect 与 Gatekeeper 集成——尽管这个文件主要供 syspolicyd 使用。
文件 /Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Resources/gk.db 是一个 SQLite 数据库,包含要阻止的文件哈希和团队 ID 的“黑名单”。
你可以使用 sqlite3 实用程序查看它:

root@kitploit:~
jbo@McJbo ~ $ sqlite3 "/Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Resources/gk.db" .schema
CREATE TABLE settings (name TEXT, value TEXT, PRIMARY KEY (name));
CREATE TABLE blocked_hashes (hash BLOB, hash_type INTEGER, flags INTEGER, PRIMARY KEY (hash, hash_type));
CREATE TABLE blocked_teams (team_id TEXT, flags INTEGER, PRIMARY KEY (team_id));
jbo@McJbo ~ $ sqlite3 "/Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Resources/gk.db" "SELECT * FROM blocked_teams LIMIT 5;"
F9X83Q5222|1
Q6XAB4776L|0
DK5C9Y86C8|0
8VK2WEPW22|0
5LWMEF3EX3|0
jbo@McJbo ~ $

这对恶意软件作者来说又是一条有趣的信息,例如——用来了解他们用来签署恶意软件的 Team ID 何时进入 Apple 的监控范围。

修复二进制文件

虽然 XProtect 二进制文件位于 /Library/Apple/System/Library/CoreServices/XProtect.app/Contents/MacOS/ 下,但你会在那里找到其他二进制文件。
这些是针对特定家族的修复文件:

root@kitploit:~
jbo@McJbo ~ $ ls -l /Library/Apple/System/Library/CoreServices/XProtect.app/Contents/MacOS/
total 47256
-rwxr-xr-x  1 root  wheel   513696 Feb 27 16:54 XProtect
-rwxr-xr-x  1 root  wheel  2498784 Feb 27 16:54 XProtectRemediatorAdload
-rwxr-xr-x  1 root  wheel  2367952 Feb 27 16:54 XProtectRemediatorBadGacha
-rwxr-xr-x  1 root  wheel  2053968 Feb 27 16:54 XProtectRemediatorBlueTop
-rwxr-xr-x  1 root  wheel  2332752 Feb 27 16:54 XProtectRemediatorBundlore
-rwxr-xr-x  1 root  wheel  2299648 Feb 27 16:54 XProtectRemediatorCardboardCutout
-rwxr-xr-x  1 root  wheel  2333248 Feb 27 16:54 XProtectRemediatorColdSnap
-rwxr-xr-x  1 root  wheel  2052736 Feb 27 16:54 XProtectRemediatorCrapyrator
-rwxr-xr-x  1 root  wheel  2859040 Feb 27 16:54 XProtectRemediatorDolittle
-rwxr-xr-x  1 root  wheel  2205520 Feb 27 16:54 XProtectRemediatorDubRobber
-rwxr-xr-x  1 root  wheel  2334752 Feb 27 16:54 XProtectRemediatorEicar
-rwxr-xr-x  1 root  wheel  2053120 Feb 27 16:54 XProtectRemediatorFloppyFlipper
-rwxr-xr-x  1 root  wheel  2053616 Feb 27 16:54 XProtectRemediatorGenieo
-rwxr-xr-x  1 root  wheel  2053504 Feb 27 16:54 XProtectRemediatorGreenAcre
-rwxr-xr-x  1 root  wheel  2332800 Feb 27 16:54 XProtectRemediatorKeySteal
-rwxr-xr-x  1 root  wheel  4659088 Feb 27 16:54 XProtectRemediatorMRTv3
-rwxr-xr-x  1 root  wheel  2382448 Feb 27 16:54 XProtectRemediatorPirrit
-rwxr-xr-x  1 root  wheel  2333024 Feb 27 16:54 XProtectRemediatorRankStank
-rwxr-xr-x  1 root  wheel  2299728 Feb 27 16:54 XProtectRemediatorRoachFlight
-rwxr-xr-x  1 root  wheel  2384416 Feb 27 16:54 XProtectRemediatorSheepSwap
-rwxr-xr-x  1 root  wheel  2053232 Feb 27 16:54 XProtectRemediatorSnowBeagle
-rwxr-xr-x  1 root  wheel  2350624 Feb 27 16:54 XProtectRemediatorSnowDrift
-rwxr-xr-x  1 root  wheel  2019712 Feb 27 16:54 XProtectRemediatorToyDrop
-rwxr-xr-x  1 root  wheel  2105696 Feb 27 16:54 XProtectRemediatorTrovi
-rwxr-xr-x  1 root  wheel  2332768 Feb 27 16:54 XProtectRemediatorWaterNet
jbo@McJbo ~ $

XProtect Remediator

一个存储在 /Library/Apple/System/Library/CoreServices/XProtect.app 的新 XProtect 系统应用程序在 macOS Monterey 中引入,负责运行 XProtect Remediator。
与传统的 XProtect(主要使用基于签名的检测)不同,XProtect Remediator 主动扫描并从受感染的系统中移除恶意软件。
它作为后台进程运行,可以在无需用户干预的情况下自动移除检测到的威胁。
目录 /Library/Apple/System/Library/CoreServices/XProtect.app/Contents/Resources 包含用于主动扫描的修复脚本和附加检测逻辑。

com.apple.XProtect.agent.scan.plist

文件 /Library/Apple/System/Library/CoreServices/XProtect.app/Contents/Resources/com.apple.XProtect.agent.scan.plist 包含有关何时运行定期扫描的设置。
例如:

root@kitploit:~
<key>com.apple.XProtect.PluginService.agent.slow.scan</key>
<dict>
        <key>Repeating</key>
        <true/>
        <key>PowerNap</key>
        <true/>
        <key>CPUIntensive</key>
        <true/>
        <key>DiskIntensive</key>
        <true/>
        <key>AllowBattery</key>
        <false/>
        <key>Priority</key>
        <string>Utility</string>
        <key>Interval</key>
        <integer>604800</integer>
</dict>

这显示了某些性能条件,甚至扫描的周期(604800 秒 = 每 7 天一次)。

MRT

有些人可能听说过 MRT (Malware Removal Tool)。
MRT 存储在 /Library/Apple/System/Library/CoreServices/MRT.app,它是另一个与 XProtect 协同工作的 macOS 安全组件。
它负责移除 XProtect 检测到的恶意软件,并在后台静默运行。
在清除检测到的威胁方面,MRT 比 XProtect 更激进,即使恶意文件当前正在运行,也能将其移除。
请注意,与 XProtect 不同,MRT 不维护配置文件——所有内容都内置在二进制文件中。
即使查看主二进制文件(/Library/Apple/System/Library/CoreServices/MRT.app/Contents/MacOS/MRT)的字符串,也会发现一些有趣的字符串,例如:

root@kitploit:~
import sys,base64;exec(base64.b64decode('
import sys,base64,warnings;warnings.filterwarnings('ignore');exec(base64.b64decode('
import sys;import re, subprocess;cmd = "ps -ef | grep Little\ Snitch | grep -v grep"

各组件如何协同工作

当文件通过浏览器或应用程序(例如 Safari、邮件、信息)下载时,它会被标记上隔离标志(com.apple.quarantine)——我在之前的关于 Gatekeeper 的博文中已经提到过这个标志。
Gatekeeper 会检查文件是否已签名和公证。如果没有,用户会在执行前收到警告。
如果允许执行,XProtect 会根据其已知的恶意软件签名(来自 XProtect.plist、XProtect.yara 等)扫描文件。
如果检测到恶意软件,系统会阻止执行。如果该恶意软件已知且可以修复,XProtect Remediator 或 MRT 可能会删除或使其失效。
Apple 通过 XProtectService 进程在后台静默更新 XProtect、MRT 和 XProtect Remediator。

特别提及 - Banshee

今年早些时候,CheckPoint 发布了一篇关于名为 Banshee 的恶意软件样本的博文。
这篇文章引起了相当大的关注,因为它使用了与 XProtect Remediator 二进制文件用来“隐藏其 YARA 规则”相同的加密算法。
该算法本身很简单:

root@kitploit:~
def macos_xprotect_string_decryption(encrypted: bytes, encr_key: int) -> str:
    """
    Author: @Check Point Research
    Decrypts MacOS Xprotect binaries & Banshee Stealer encrypted strings.
    """
    decrypted = "".join(
        chr(
            (encr_key >> ((i * 8) & 0x38) & 0xFF) ^ encrypted[i]
        )
        for i in range(len(encrypted))
    )
    return decrypted.partition("\\x00")[0]

显然,恶意软件作者认为这种算法无法被静态签名检测(因为它必然会产生误报)。
我在大多数修复二进制文件中都发现了类似的代码,例如:

root@kitploit:~
10000592a      if (data_1000ffe7e != 0)
10000592c          void* rax_1 = &data_1000fb0a0
100005933          int64_t i = 0
100005951          do
100005940              *rax_1 = *rax_1 ^ (0x363a34363a303900 u>> (i.b & 0x38)).b
100005943              i = i + 8
100005947              rax_1 = rax_1 + 1
100005951          while (i != 0x26ef0)
100005953          data_1000ffe7e = 0

最初发现这一点(initial)的安全研究人员(ald3ns)发布了一个名为 XPR-dump 的工具,该工具似乎仍然可以在最新的 XProtect 版本上运行。你一定要去看看!

总结

这篇博文最大的收获是,XProtect 与攻击者玩着猫捉老鼠的游戏(就像任何防病毒软件一样)——黑名单、运行 YARA 或简单的静态签名都在其范围之内。
这些文件被部署到所有终端,并且易于分析,这一事实使得恶意软件作者很容易找到绕过许多这些检查的方法。

敬请期待!

Jonathan Bar Or (https://jonathanbaror.com)

下载工具