
LiberiOS 및 Electra 탈옥과 함께 iOS 11.0 - 11.1.2용 Dylib 주입
탈옥된 64비트 iOS 11.0 - 11.1.2용 간편한 dylib 주입 도구입니다. Electra 및 LiberiOS 탈옥과 호환됩니다.
bfinject는 실행 중인 App Store 앱에 임의의 dylib를 로드합니다. App Store 앱 복호화를 기본 지원하며, iSpy 및 Cycript가 번들로 포함되어 있습니다.
bfinject는 bfinject4realz를 사용하여 dylib를 주입하기 전에 올바르게 코드사인하는 작업을 처리하는 래퍼입니다. 완전히 독립적이며 jailbreakd, QiLin 등을 필요로 하지 않습니다. 그냥 동작합니다.
참고: "Tweaks"가 활성화된 Electra에서는 bfinject가 작동하지 않습니다. bfinject를 사용하려면 재부팅한 후 트윅 없이 Electra를 다시 실행하십시오. "thread_create" 관련 오류가 보이면 이것이 원인입니다.
참고: bfdecrypt는 여기에서 독립형 dylib로 제공됩니다: https://github.com/BishopFox/bfdecrypt/
wget은 SSL을 지원하지 않으므로, 먼저 랩톱으로 복사해야 할 수도 있습니다.ssh root@your-device-ip # (the password is 'alpine')
mkdir bfinject
cd bfinject
wget http://<your_server>/bfinject.tar
tar xvf bfinject.tar
wget은 SSL을 지원하지 않으므로, 먼저 랩톱으로 복사해야 할 수도 있습니다.ssh root@your-device-ip # (the password is 'alpine')
export PATH=$PATH:/jb/usr/bin:/jb/bin:/jb/sbin:/jb/usr/sbin:/jb/usr/local/bin:
cd /jb
mkdir bfinject
cd bfinject
wget http://<your_server>/bfinject.tar
tar xvf bfinject.tar
bash bfinject를 입력하십시오.bash를 붙이는 것이 중요합니다. 그렇지 않으면 작동하지 않습니다. 샌드박스 어쩌구저쩌구.-bash-3.2# bash bfinject
Syntax: bfinject [-p PID | -P appname] [-l /path/to/yourdylib | -L feature]
For example:
bfinject -P Reddit.app -l /path/to/evil.dylib # Injects evil.dylib into the Reddit app
or
bfinject -p 1234 -L cycript # Inject Cycript into PID
or
bfinject -p 4566 -l /path/to/evil.dylib # Injects the .dylib of your choice into PID
Instead of specifying the PID with -p, bfinject can search for the correct PID based on the app name.
Just enter "-P identifier" where "identifier" is a string unique to your app, e.g. "fing.app".
Available features:
cycript - Inject and run Cycript
decrypt - Create a decrypted copy of the target app
test - Inject a simple .dylib to make an entry in the console log
ispy - Inject iSpy. Browse to http://<DEVICE_IP>:31337/
더 복잡한 작업을 하기 전에 제대로 작동하는지 테스트하십시오. bfinject에는 내장 자체 테스트가 있습니다. Reddit 앱을 대상으로 한 예시는 다음과 같습니다.
Cs-iPhone:~ root# bash bfinject -P Reddit -L test
[+] Electra detected.
[+] Injecting into '/var/containers/Bundle/Application/55C94FAA-A282-4FDC-967D-6A012D01087E/Reddit.app/Reddit'
[+] Getting Team ID from target application...
[+] Thinning dylib into non-fat arm64 image
[+] Signing injectable .dylib with Team ID 2TDUX39LX8 and platform entitlements...
[bfinject4realz] Calling task_for_pid() for PID 486.
[bfinject4realz] Calling thread_create() on PID 486
[bfinject4realz] Looking for ROP gadget... found at 0x1019a2ba0
[bfinject4realz] Fake stack frame at 0x12ac5c000
[bfinject4realz] Calling _pthread_set_self() at 0x182bfb814...
[bfinject4realz] Returned from '_pthread_set_self'
[bfinject4realz] Calling dlopen() at 0x1829bb460...
[bfinject4realz] Returned from 'dlopen'
[bfinject4realz] Success! Library was loaded at 0x1c016e1c0
[+] So long and thanks for all the fish.
기기 화면에 다음과 같은 화면이 보여야 합니다:
그렇지 않다면 뭔가 고장난 것입니다 ;)
Electra로 탈옥된 iPhone에서 Reddit 앱을 복호화하는 예시입니다:
Cs-iPhone:~ root# bash bfinject -P Reddit -L decrypt
[+] Electra detected.
[+] Injecting into '/var/containers/Bundle/Application/BCEBDD64-6738-45CE-9B3C-C6F933EA0793/Reddit.app/Reddit'
[+] Getting Team ID from target application...
[+] Thinning dylib into non-fat arm64 image
[+] Signing injectable .dylib with Team ID 2TDUX39LX8 and platform entitlements...
[bfinject4realz] Calling task_for_pid() for PID 3218.
[bfinject4realz] Calling thread_create() on PID 3218
[bfinject4realz] Looking for ROP gadget... found at 0x1016a5110
[bfinject4realz] Fake stack frame at 0x10a06c000
[bfinject4realz] Calling _pthread_set_self() at 0x181303814...
[bfinject4realz] Returned from '_pthread_set_self'
[bfinject4realz] Calling dlopen() at 0x1810c3460...
[bfinject4realz] Returned from 'dlopen'
[bfinject4realz] Success! Library was loaded at 0x1c03e1100
[+] So long and thanks for all the fish.
기기에서 다음 화면이 표시됩니다:
완료되면 복호화된 IPA를 다운로드할 수 있는 서비스를 시작할지 묻는 UI 알림이 표시됩니다:
Yes를 탭하면 기기의 31336 포트에서 서비스가 시작됩니다. 연결하면 IPA의 원본 복사본이 전송되며 다음과 같이 netcat으로 다운로드할 수 있습니다:
carl@calisto-3 /tmp $ nc 192.168.1.33 31336 > decrypted.ipa
carl@calisto-3 /tmp $ ls -l decrypted.ipa
-rw-r--r-- 1 carl wheel 14649063 Jan 25 16:57 decrypted.ipa
carl@calisto-3 /tmp $ file decrypted.ipa
decrypted.ipa: iOS App Zip archive data, at least v2.0 to extract
또는 기기의 콘솔 로그를 확인하면 복호화된 IPA가 저장된 위치를 알 수 있습니다. 예:
[dumpdecrypted] Wrote /var/mobile/Containers/Data/Application/6E6A5887-8B58-4FC5-A2F3-7870EDB5E8D1/Documents/decrypted-app.ipa
다음과 같이 파일시스템에서 IPA를 검색할 수도 있습니다:
find /var/mobile/Containers/Data/Application/ -name decrypted-app.ipa
.ipa를 기기에서 가져오려면 netcat을 사용할 수 있습니다. 랩톱에서 리스너 서비스를 설정하십시오:
ncat -l 0.0.0.0 12345 > decrypted.ipa
그리고 탈옥된 기기에서:
cat /path/to/decrypted.ipa > /dev/tcp/<IP_OF_YOUR_COMPUTER>/12345
.ipa는 App Store의 원본 .ipa 복제본이지만, 메인 바이너리와 함께 포함된 모든 프레임워크 및 공유 라이브러리는 복호화됩니다. 이전에 암호화된 각 파일에서 CRYPTID 플래그는 0이 됩니다. .ipa를 가져와 앱을 추출하고, 필요에 따라 수정한 다음, 자신의 개발자 인증서로 다시 서명하고, 필요에 따라 탈옥되지 않은 기기에 배포할 수 있습니다.
bfinject의 기능 중 하나는 Cycript와 같은 일반적인 펜테스팅 도구를 통합하는 것입니다. 시간이 지나면서 더 추가될 예정입니다. Cycript를 사용하려면 MacBook에 Cycript 명령줄 클라이언트(http://www.cycript.org/)가 설치되어 있어야 합니다. 그런 다음 테스트 기기에 bfinject가 설치되면 Reddit 앱에 Cycript를 주입하는 다음 예시와 같이 하면 됩니다:
Cs-iPhone:~ root# bash bfinject -P Reddit -L cycript
[+] Electra detected.
[+] Injecting into '/var/containers/Bundle/Application/55C94FAA-A282-4FDC-967D-6A012D01087E/Reddit.app/Reddit'
[+] Getting Team ID from target application...
[+] Thinning dylib into non-fat arm64 image
[+] Signing injectable .dylib with Team ID 2TDUX39LX8 and platform entitlements...
[bfinject4realz] Calling task_for_pid() for PID 486.
[bfinject4realz] Calling thread_create() on PID 486
[bfinject4realz] Looking for ROP gadget... found at 0x1019a2ba0
[bfinject4realz] Fake stack frame at 0x10ab00000
[bfinject4realz] Calling _pthread_set_self() at 0x182bfb814...
[bfinject4realz] Returned from '_pthread_set_self'
[bfinject4realz] Calling dlopen() at 0x1829bb460...
[bfinject4realz] Returned from 'dlopen'
[bfinject4realz] Success! Library was loaded at 0x1c01786c0
[+] Injecting into '/var/containers/Bundle/Application/55C94FAA-A282-4FDC-967D-6A012D01087E/Reddit.app/Reddit'
[+] Getting Team ID from target application...
[+] Thinning dylib into non-fat arm64 image
[+] Signing injectable .dylib with Team ID 2TDUX39LX8 and platform entitlements...
[bfinject4realz] Calling task_for_pid() for PID 486.
[bfinject4realz] Calling thread_create() on PID 486
[bfinject4realz] Looking for ROP gadget... found at 0x1019a2ba0
[bfinject4realz] Fake stack frame at 0x10ab00000
[bfinject4realz] Calling _pthread_set_self() at 0x182bfb814...
[bfinject4realz] Returned from '_pthread_set_self'
[bfinject4realz] Calling dlopen() at 0x1829bb460...
[bfinject4realz] Returned from 'dlopen'
[bfinject4realz] Success! Library was loaded at 0x1c4179680
[+] So long and thanks for all the fish.
Cycript가 주입되면 기기에 다음 메시지가 표시됩니다:
MacBook에서 다음과 같이 Cycript에 연결할 수 있습니다(Cycript를 ~/bin/에 설치했다고 가정):
carl@calisto-3 /tmp $ ~/bin/cycript -r 192.168.1.33:1337
cy# UIApp
#"<RedditApplication: 0x102304a30>"
cy#
대략적으로 말하면, bfinject4realz는 실행 중인 Apple 서명 App Store 앱에 자체 서명된 .dylib를 사이드로드합니다.
이 과정은 두 단계로 이루어집니다.
iOS의 코드사인 검사는 사용자 공간 서비스(amfid)와 커널 서비스(AppleMobileFileIntegrity)로 구성됩니다. LiberiOS와 Electra 모두 사용자 공간의 amfid 프로세스를 패치하여 코드사인 검사를 우회하지만, 커널이 수행하는 추가 검사가 여전히 남아 있습니다.
그러나 Electra와 LiberiOS는 KPPless입니다. 즉, 커널에서 어떤 것도 패치하지 않습니다. 단 한 바이트도 패치하지 않습니다. 이는 커널 패치를 탐지하고 차단하기 위해 정교한 커널 내부 검사를 수행하는 Apple의 보안 기술인 KPP(Kernel Patch Protection) 때문입니다. 그 결과 커널 코드사인 검사는 그대로 유지됩니다.
다행히도 커널은 amfid가 dylib의 자격에 첨부된 암호화 서명의 유효성을 이미 검증했다고 가정하는 것으로 보입니다. 따라서 커널이 이를 수락하도록 하려면 dylib에 두 가지 자격을 자체 서명하기만 하면 됩니다:
platform-application 자격입니다. dylib가 Apple 소프트웨어임을 나타내는 것으로 생각됩니다.2TDUX39LX8로 서명됩니다. 따라서 Reddit 앱에 dylib를 주입하려면 dylib를 동일한 Team ID(2TDUX39LX8)로 서명해야 합니다.bfinject가 모든 서명 관련 복잡한 작업을 처리해 주므로 편리합니다.
task_for_pid()를 사용하여 대상 프로세스의 mach 포트를 얻습니다.낮은 수준의 설명은 소스를 참조하십시오.
참고: Electra에서 jtool(@morpheus의 코드사인 멀티툴) 버전은 플랫폼 바이너리 자격을 지원하지 않으므로, bfinject는 LiberiOS의 jtool을 제공하여 대신 사용합니다. bfinject는 Electra의 inject_criticald를 사용하지 않습니다.