Sandblaster是逆转(分解)二进制苹果沙盒配置文件的工具。 Apple Sandbox配置文件用SBPL( Sandbox Profice语言)编写,该语言是一种类似方案的语言,然后被编译成无证件的二进制格式并发货。 MACOS上也存在主要用于iOS的沙盒配置文件。据我们所知,Sandblaster是将二进制沙盒配置文件逆转其原始SBPL格式的第一个工具。 Sandblaster从版本7开始的iOS上工作,包括iOS 11。
技术报告Sandblaster:逆转Apple Sandbox,提供了有关Sandblaster内部内容的广泛信息(尽管有点过时)。
Sandblaster依靠Dionysus Blazakis和Stefan Esser的代码和幻灯片的先前工作。
Reverser(在reverse-sandbox/文件夹中)和辅助工具(在helpers/文件夹中)在任何Python运行平台上运行。
可以安装SandBlaster并独立运行,尽管我们建议从Inctractor内部安装和运行它。查看INVERSTRATER文档以获取信息。
IExtractor是根据BSD BSD许可证发布的开源软件。
Sandblaster需要Python2进行反向器(在reverse-sandbox/中),python3与lief库中的helper脚本(在helpers/ )中。
克隆Sandblaster存储库后,您必须为Python3安装lief :
pip3 install lief
如果lief的安装失败,则需要对其进行编译。有关如何编译它的更多信息,请访问Wiki页面。
为了使用Sandblaster,您需要访问二进制沙盒配置文件和沙盒操作,这是一组定义特定于沙盒的动作的字符串。使用helpers/extract_sandbox_data.py脚本提取沙盒操作和沙盒配置文件。沙盒配置文件是从内核沙盒扩展程序(作为iOS 4和9-11的捆绑包)或内核缓存(作为iOS 12的捆绑包)或iOS文件系统中的sandboxd文件(iOS 5-8)中提取的。沙盒操作是从内核扩展(对于iOS 4-11)或内核缓存中提取的(对于iOS 12)。
因此,作为输入数据,SandBlaster需要内核冰淇淋,内核沙盒扩展名和sandboxd文件。 Iextractor提供了有关从公开可用的IPSW( iPhone软件)文件中提取它们的信息和脚本。
以下是假设SandBox内核扩展程序( com.apple.security.sandbox.kext )和sandboxd文件可用的,可以扭转iOS 8.4.1的沙盒配置文件的步骤和命令:
# Extract sandbox operations from kernelcache.
cd helpers/
./extract_sandbox_data.py -o iPad2,1_8.4.1_12H321.sb_ops iPad2,1_8.4.1_12H321.com.apple.security.sandox.kext 8.4.1
# Extract binary sandbox profile files from sandboxd.
mkdir iPad2,1_8.4.1_12H321.sandbox_profiles
./extract_sandbox_data.py -O iPad2,1_8.4.1_12H321.sandbox_profiles/ iPad2,1_8.4.1_12H321.sandboxd 8.4.1
# Reverse all binary sandbox profiles.
cd ../reverse-sandbox/
mkdir iPad2,1_8.4.1_12H321.reversed_profiles
for i in ../helpers/iPad2,1_8.4.1_12H321.sandbox_profiles/*; do python reverse_sandbox.py -r 8.4.1 -o ../helpers/iPad2,1_8.4.1_12H321.sb_ops -d iPad2,1_8.4.1_12H321.reversed_profiles/ "$i"; done
以下是逆转iOS 9.3的沙盒配置文件的步骤和命令,假设可以使用Sandbox内核扩展名( com.apple.security.sandbox.kext ):
# Extract sandbox operations from kernelcache.
cd helpers/
./extract_sandbox_data.py -o iPhone5,1_9.3_13E237.sb_ops iPhone5,1_9.3_13E237.com.apple.security.sandox.kext 9.3
# Extract sandbox profile bundle from kernel sandbox extension.
./extract_sandbox_data.py -O . iPhone5,1_9.3_13E237.com.apple.security.sandox.kext 9.3
cd ../reverse-sandbox/
# Reverse all binary sandbox profiles in sandbox bundle.
mkdir iPhone5,1_9.3_13E237.reversed_profiles
# Print all sandbox profiles in bundle.
python reverse_sandbox.py -r 9.3 -o ../helpers/iPhone5,1_9.3_13E237.sb_ops -d iPhone5,1_9.3_13E237.reversed_profiles/ ../helpers/sandbox_bundle -psb
# Do actual reversing.
python reverse_sandbox.py -r 9.3 -o ../helpers/iPhone5,1_9.3_13E237.sb_ops -d iPhone5,1_9.3_13E237.reversed_profiles/ ../helpers/sandbox_bundle
二进制沙盒曲线的提取在iOS <= 8和ios> = 9之间不同。由于ios> = 9,二进制沙盒轮廓存储在内核沙盒扩展中的沙盒束中。 helpers/extract_sandbox_data.py脚本根据iOS版本适当提取它们。
reverse_sandbox.py的-psb选项将在不进行实际反转的情况下打印出沙盒捆绑包的一部分。
reverse_sandbox.py脚本需要在其目录( reverse-sandbox/ )中运行,因为它需要其他python模块和logger.config文件。
helpers/子文件夹包含辅助脚本,为外部工具提供更好的接口。
实际反转器是reverse-sandbox/文件夹的一部分。此处的文件可以分类如下:
reverse_sandbox.py 。它解析了命令行参数,对输入二进制文件(提取部分)进行基本解析,并从其他模块调用适当的功能。operation_node.py 。它提供了构建对应于沙盒配置文件并将图形转换为SBPL的规则图的功能。它由reverse_sandbox.py调用。sandbox_filter.py中的实现以及filters.json , filter_list.py和filters.py中的配置来处理沙盒过滤器(即沙盒配置文件中的匹配规则)。过滤器特定的功能由operation_node.py调用。sandbox_regex.py和regex_parse.py处理。 regex_parse.py是将二进制表示形式转换为基本图的后端解析器。 sandbox_regex.py将图表表示(自动机)转换为实际的正则表达式(即一串字符和Metacharacters)。它由reverse_sandbox.py调用,用于解析正则表达式,并将结果的正则表达式列表传递给operation_node.py公开的函数; operation_node.py将它们传递到沙盒过滤器处理文件。reverse_string.py处理。 reverse_string.py中的主要SandboxString类在sandbox_filter.py中使用。logger.config文件中配置。默认情况下,将INFO和更高级别的消息打印到控制台,而DEBUG和更高级别的消息则将其打印到reverse.log文件。 SandBlaster为iOS版本的第4版作品(包括iOS 12)。苹果一直在对沙盒配置文件的二进制格式进行更新:因为iOS 9沙盒配置文件存储在捆绑包中,因为iOS 10字符串以专用二进制格式聚合在一起。 iOS 11没有为格式带来任何更改。
加入我们的不和谐进行现场讨论。