Sandblaster는 바이너리 애플 샌드 박스 프로파일을 되돌리기위한 도구입니다. Apple Sandbox 프로파일은 체계와 같은 언어 인 SBPL ( Sandbox Profile Language )으로 작성된 다음 문서화되지 않은 이진 형식으로 컴파일되어 배송됩니다. iOS에 주로 사용되는 샌드 박스 프로파일은 MacOS에도 존재합니다. Sandblaster는 우리가 아는 한, 바이너리 샌드 박스 프로파일을 원래 SBPL 형식으로 되돌리는 첫 번째 도구입니다. Sandblaster는 iOS 11을 포함하여 버전 7의 iOS에서 작업합니다.
Technical Report Sandblaster : Apple Sandbox를 뒤집는 것은 Sandblaster Internals에 대한 광범위한 (약간 구식) 정보를 제공합니다.
Sandblaster는 Dionysus Blazakis와 Stefan Esser의 코드 및 슬라이드의 이전 작업에 의존했습니다.
Reverser ( reverse-sandbox/ Folder) 및 도우미 도구 ( helpers/ Folder)는 모든 Python Running 플랫폼에서 실행됩니다.
Sandblaster는 IEXTractor 내에서 설치 및 실행을 권장하지만 Sandblaster를 설치하고 실행할 수 있습니다. 정보는 ixtractor 문서를 확인하십시오.
IEXTractor는 3- 클라스 BSD 라이센스에 따라 출시 된 오픈 소스 소프트웨어입니다.
Sandblaster는 리버 서 ( reverse-sandbox/ ) 용 Python2, 헬퍼 스크립트 용 lief 라이브러리가있는 Python3가 필요합니다 ( helpers/ ).
Sandblaster 저장소를 복제 한 후 Python3 용 lief 설치해야합니다.
pip3 install lief
lief 설치가 실패하면 컴파일이 필요합니다. 컴파일 방법에 대한 자세한 내용은 Wiki 페이지에서 확인할 수 있습니다.
샌드 블래스터를 사용하려면 이진 샌드 박스 프로파일과 샌드 박스 작업에 액세스 할 수 있어야합니다. 샌드 박스 별 동작을 정의하는 문자열 세트입니다. 샌드 박스 작업 및 샌드 박스 프로파일은 helpers/extract_sandbox_data.py 스크립트를 사용하여 추출됩니다. 샌드 박스 프로파일은 커널 샌드 박스 확장 (iOS 4 및 9-11 용 번들) 또는 커널 캐시 (iOS 12 용 번들) 또는 iOS 파일 시스템 (iOS 5-8 용 sandboxd 파일)에서 추출됩니다. 샌드 박스 작업은 커널 확장 (iOS 4-11의 경우) 또는 커널 캐시 (iOS 12의 경우)에서 추출됩니다.
따라서 입력 데이터로서 Sandblaster는 KernelCache, Kernel Sandbox Extension 및 sandboxd 파일이 필요합니다. 공개적으로 사용 가능한 IPSW ( iPhone Software ) 파일에서 추출에 대한 정보 및 스크립트는 IExtractor가 제공합니다.
다음은 샌드 박스 커널 확장 ( com.apple.security.sandbox.kext )을 가정하고 iOS 8.4.1의 샌드 sandboxd 프로파일을 뒤집는 단계와 명령입니다.
# 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
다음은 샌드 박스 커널 확장 ( com.apple.security.sandbox.kext )을 사용할 수 있다고 가정 할 때 iOS 9.3의 샌드 박스 프로파일을 뒤집는 단계와 명령입니다.
# 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 스크립트는 다른 Python 모듈과 logger.config 파일이 필요하므로 디렉토리 ( reverse-sandbox/ )에서 실행해야합니다.
helpers/ Subfolder에는 외부 도구에 더 좋은 인터페이스를 제공하는 도우미 스크립트가 포함되어 있습니다.
실제 리버서는 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 파일에 인쇄됩니다. iOS 버전 4를 포함하여 iOS 버전 4의 Sandblaster는 샌드 박스 프로파일의 이진 형식에 대한 업데이트를 만들고 있습니다. iOS 9 샌드 박스 프로파일은 번들에 저장되므로 iOS 10 문자열은 특수 바이너리 형식으로 함께 집계됩니다. iOS 11은 형식을 변경하지 않았습니다.
라이브 토론을 위해 Discord에 우리와 함께하십시오.