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沒有為格式帶來任何更改。
加入我們的不和諧進行現場討論。