machscope 是一个终端原生的 macOS 浏览器,能将进程、launchd 任务、Mach 服务、程序包、签名、授权以及 Mach-O 链接关系转化为一个可交互的图谱。
它存在的目的是为了残忍地准确回答一个简单问题:
这个进程、服务、二进制文件或程序包究竟与什么相关联?
它将 进程、可执行文件、launchd 任务、Mach 服务、程序包、嵌入式 XPC 服务、代码签名、授权、Mach-O 链接关系 以及 信任/异常发现 关联到一个视图中。
如果 活动监视器、ps、lsof、launchctl、codesign 和 otool 有一个偏执且对操作人员友好的孩子,那非它莫属。
macOS 的内部机制很优雅,但真相是分散的。
要了解一个可疑的进程,你往往需要在以下工具间来回切换:
pslsoflaunchctlcodesignotoolInfo.plistmachscope 将这一工作流程压缩成一个单一的终端工具。
它专为以下场景而构建:
给定一个 PID、路径、launchd label 或 Mach 服务名称,machscope 可以关联:
ps 的进程元数据lsof 的可执行文件路径和打开文件上下文launchctl 的 launchd 状态和 label 提示MachServices.xpc 服务codesign 的代码签名标识符、团队 ID、证书链和运行时提示codesign 的授权数据otool 的 Mach-O 头部、链接的动态库、加载命令和 rpath它 不 假装能观察到每一个实时的 XPC 关系。有些关系是 声明的,而非 观察到的。这种诚实是有意为之。
ps 显示的是进程,而不是所有权链launchctl 显示的是任务,而不是完整的二进制/程序包/信任上下文codesign 显示的是身份,而不是运行时关系otool 显示的是链接关系,而不是 launchd 或 Mach 服务暴露情况machscope 一次性关联所有信息--follow 解析器跳转
graph.nodes 和 graph.edges 旨在支持未来的 TUI、渲染器或 diff 工作流./machscope.py inspect <pid|path|launchd-label|mach-service>
./machscope.py inspect <target> --follow
./machscope.py inspect <target> --json
./machscope.py scan --limit 40 --min-score 1
./machscope.py services [filter]
./machscope.py inspect 1
./machscope.py inspect 57382
./machscope.py inspect /System/Applications/Calculator.app --follow
./machscope.py inspect /usr/libexec/remoted
./machscope.py inspect com.apple.WindowServer --follow
./machscope.py inspect ai.openclaw.gateway --follow
./machscope.py inspect com.apple.dnssd.service --follow
./machscope.py scan --limit 40 --min-score 1
./machscope.py scan --limit 10 --min-score 6
./machscope.py services
./machscope.py services mDNS
./machscope.py services com.apple
Target: com.apple.dnssd.service [mach-service follow]
Resolved via: mach-service-launchd
Executable: /usr/sbin/mDNSResponder
Launchd: com.apple.mDNSResponder.reloaded
Plist: /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
Signature: apple-platform team=not set id=com.apple.mDNSResponder
Mach services: com.apple.dnssd.service, com.apple.mDNSResponder.control, com.apple.mDNSResponder.log_utility
Entitlements: 0
Linked dylibs: 25 RPATHs: 0
Trust: score=1 verdict=ordinary
Findings:
- [LOW] T012 Odd launchd label suffix
inspect --json 返回一个结构化的对象,专为脚本编写和未来的 UI 工作设计。
顶层结构:
targettarget_resolutionprocessbinarybundlelaunchdtrustgraph.nodesgraph.edges图谱设计得很简单,以便可以提供给:
--follow 的工作原理--follow 让 machscope 开始感觉不再像是一个元数据转储器,而更像一个浏览器。
它添加了解析器跳转,例如:
launchctl print 状态 → 如果有的话,实时 PID这很重要,因为 macOS 中最有趣的工件往往不是你字面上输入的东西,而是它背后的东西。
machscope 包含一个简单的信任/异常层。
它能够揭示的例子包括:
.reloaded这 不是 一个恶意软件判定引擎。 它是一种发现线索、减少盲点、让可疑链条更容易审查的方式。
第一个版本有意使用:
包装的工具包括:
pslsoflaunchctlcodesignotoolfile这使得该工具易于克隆、审查并在一个比较标准的系统上运行。
有些关系是声明的,而非观察到的。
例如:
machscope 宁愿明确,也不假装确定。
ps、lsof、launchctl、codesign、otool 和 file首先以普通用户身份运行。
这通常足够获得有用的答案。
某些细节在没有提升权限的情况下可能不完整,尤其是在以下方面:
lsoflaunchctl如果你要提权,请有意识地去做。
machscope 并不试图成为:
它是一个锋利的本地工具,用于让 macOS 内部变得清晰易懂。
早期阶段,但已经很有用。
当前的输出和图模型被刻意塑造,以便未来版本可以添加:
--