catbyte-security/catbyte-toolkit
GitHub: catbyte-security/catbyte-toolkit
一个面向 macOS/iOS 的二进制安全分析工具包,整合静态与动态分析能力,帮助安全团队高效发现与验证漏洞。
Stars: 1 | Forks: 0
# cb - macOS/iOS 安全研究用的二进制分析工具包
一个用于 macOS 和 iOS 目标的二进制安全分析、漏洞研究和漏洞利用开发的命令行工具包。包含 30 多个命令,涵盖侦察、漏洞扫描、IPC 分析、崩溃分类、模糊测试生成、Ghidra/LLDB 集成等功能。
专为安全研究人员、漏洞赏金猎人和 Apple 平台上的红队成员设计。
## 功能
**侦察**
- `cb triage` - 快速安全概览(保护措施、导入项、字符串、节区)
- `cb attack` - 攻击面映射(IPC 端点、解析器、权限)
- `cb objc` - Objective-C 运行时分析(类、选择器、危险方法)
- `cb grep` - 二进制内容搜索(反汇编、字节、字符串、ROP/JOP 小工具)
**漏洞分析**
- `cb vuln` - 基于模式的漏洞扫描器(可选 Ghidra 反编译)
- `cb variant` - 从 12 种已知漏洞模式中查找变体漏洞
- `cb taint` - 跨过程污点跟踪(通过 Ghidra 从源点到汇点)
- `cb callgraph` - 调用图恢复与危险汇点可达性分析
- `cb audit` - 完整安全审计(运行 triage + attack + vuln + objc + ipc + sandbox + variant)
**IPC 与沙箱**
- `cb ipc` - XPC/Mach/MIG 处理器分析
- `cb sandbox` - 沙箱配置文件与权限分析
- `cb probe` - 实时 XPC 服务探测(首次使用时编译 ObjC 探测二进制文件)
**动态分析**
- `cb lldb` - 脚本化 LLDB 调试(模块、符号、内存、断点)
- `cb hook` - Frida 仪器化框架生成
- `cb verify` - 在 macOS 内存保护机制下运行二进制文件(MallocGuardEdges、MallocScribble)
**漏洞利用开发**
- `cb cache` - 从 dyld 共享缓存中提取二进制文件
- `cb struct` - 从 ARM64 反汇编中恢复结构体字段布局
- `cb heap` - macOS 堆区分类与喷射规划
- `cb gadget` - ARM64 ROP/JOP 小工具查找与链构建(支持 PAC)
**崩溃分析**
- `cb crash` - 崩溃报告解析器(包含可利用性评估与 PoC 生成)
- `cb diff` - 二进制版本差异分析(安全聚焦模式)
**Web 安全**
- `cb web` - 安全标头、CSP、CORS、Cookie 与端点审计
**工作流**
- `cb plan` - 从侦察数据生成确定性审计计划
- `cb report` - 结构化漏洞报告(Markdown、HTML、漏洞赏金模板)
- `cb context` - AI 辅助工作流的令牌预算管理
## 安装
```
# 克隆并安装
git clone https://github.com/catbyte-security/catbyte-toolkit.git
cd catbyte-toolkit
pip install -e .
# 具备完整的 Mach-O 解析支持
pip install -e ".[full]"
```
**要求:** Python 3.10+、macOS(主要目标平台)
**必需依赖:** pwntools、capstone、pyelftools、ROPGadget
**可选依赖:** [LIEF](https://lief.re/)(更优的 Mach-O 解析)、[Ghidra](https://ghidra-sre.org/)(反编译/污点/调用图)、[Frida](https://frida.re/)(动态钩子)、LLDB(调试)
## 快速开始
```
# 二进制的安全概览
cb triage /usr/libexec/syspolicyd
# 全面审计
cb audit /usr/libexec/syspolicyd
# 攻击面映射
cb attack /usr/libexec/syspolicyd --depth deep
# 使用 Ghidra 反编译查找漏洞
cb vuln target --decompiled --severity high
# XPC 服务分析流水线
cb ipc target --protocol
cb sandbox target --reachable-from /usr/libexec/sandboxd
cb probe com.apple.securityd --enumerate-messages
# 崩溃驱动的漏洞利用开发
cb crash report.ips --generate-poc --poc-output poc.py
cb variant --from-crash report.ips --heuristic
# 漏洞利用链开发
cb cache extract-all --targets exploit
cb struct recover ~/.cb/dsc_extract/*/SkyLight --functions SLSSetWindowLevel,SLSSetWindowAlpha
cb heap plan 288 --spray-count 5000 --language objc
cb gadget chain ~/.cb/dsc_extract/*/WindowServer --template mprotect_shellcode
```
## 管道串联
所有命令均输出 JSON,并可通过管道连接:
```
# 分类 -> 漏洞扫描
cb triage target | cb vuln --from-triage -
# 崩溃 -> 变体分析
cb crash report.ips | cb variant --from-crash -
# 全面审计 -> 报告
cb audit target | cb report --from-audit - --template bugbounty --markdown
# 分类 -> 计划 -> 执行
cb triage target --full | cb plan target --from-triage -
```
## 输出格式
每个命令均支持结构化输出:
```
cb triage target --format json # JSON (default, for AI/pipeline)
cb triage target --format text # Human-readable
cb triage target --summary # One-line summary
cb triage target --max-results 20 # Cap list lengths
cb triage target -q # Suppress progress messages
```
## 配置
可选配置文件位于 `~/.cbconfig.json`:
```
{
"ghidra_home": "/Applications/ghidra_11.0",
"ghidra_project_dir": "~/.cb/ghidra_projects",
"default_format": "json",
"default_max_results": 50
}
```
若未配置,工具会自动从常见安装位置检测 Ghidra。
## Chrome/Chromium 分析
包含针对 Chrome 安全研究的专用模式:
```
cb vuln /path/to/Chromium.app --chrome # Mojo IPC, V8, sandbox patterns
cb fuzz chrome_helper --mojo --target MyInterface # Mojo IPC fuzzer (MojoLPM)
cb sandbox /path/to/Chrome.app --chrome # Chrome sandbox profile analysis
```
## 架构
```
cb/
cli.py # Unified dispatcher: cb
output.py # OutputFormatter (JSON/text/summary)
config.py # ~/.cbconfig.json loader
macho.py # Mach-O parser (otool/nm/codesign/LIEF)
disasm.py # Capstone disassembler + objdump fallback
ghidra_bridge.py # Ghidra headless analysis
lldb_bridge.py # LLDB scripted debugging
commands/ # One file per command (30 modules)
patterns/ # Vulnerability signatures, gadget patterns, Chrome patterns
ghidra_scripts/ # Java scripts for Ghidra headless
lldb_scripts/ # Python scripts for LLDB
probe_scripts/ # ObjC probing tools
```
## 测试
```
pip install -e .
pytest tests/ -v
```
## 许可证
MIT
标签:Apple platform security, attack, binary analysis toolkit, bug bounty, callgraph, CLI, crash triage, Docker支持, dyld共享缓存, entitlement, exploit development, Frida, fuzzer generation, Ghidra, iOS安全, ipc, JOP, LLDB, Mach-O分析, macOS安全, MallocGuardEdges, MallocScribble, PAC, recon, ROP, sandbox, taint, vuln, WiFi技术, XPC分析, 三振分析, 二进制分析, 云安全监控, 云安全运维, 云资产清单, 内存防护, 堆喷射, 崩溃分析, 数据展示, 服务器监控, 沙盒分析, 漏洞利用开发, 漏洞模式, 系统运维工具, 红队, 调用图分析, 逆向工具, 逆向工程, 静态分析