DVIA - Jailbreak 우회 3 (Tweak)

Cydia Substrate를 이용한 후킹인데,
THEOS를 이용하여 좀 더 쉽게 트윅을 작성할 수 있다.
 
 

Theos 설치

1. Theos Dependencies 설치

notion image
필요한 dependencies를 cydia에서 설치하자.
 

2. $THEOS 환경변수 설정

이건 그냥 편의성을 위한 환경변수 설정이다.
#환경변수 설정 iphone$ echo "export THEOS=-/theos" >> ~/.profile #잘 설정됐는지 확인 iphone$ cat ~/.profile
 

3. Theos git clone

#환경변수 설정한 경로에 깃 클론 iphone$ git clone --recursive https://github.com/theos/theos.git $THEOS
 

4. SDKs 복사

#master.zip 다운받고 #압축 풀고 #sdk들을 전부 $THEOS/sdks/ 경로 아래로 복사 #끝. #따라서 커맨드라인이 불편하다면, 그냥 Cyberduck 같은 걸로 옮기는게 더 편함. #다운 curl -L0 https://github.com/theos/sdks/archive/master.zip --output theos.zip #임시 TMP 환경변수 등록 및 폴더생성 TMP=$(mktemp -d) #TMP 디렉토리에 압축 풀기 unzip theos.zip -d $TMP #모든 sdks들 $THEOS/sdks/ 아래로 옮김 mv $TMP/sdks-master/*.sdk $THEOS/sdks #필요없는 나머지들 다 정리 rm -r theos.zip $TMP/
 

5. 트윅 경로 생성

이것도 단지 편의성을 위한 디렉토리 생성이다.
#THEOS경로 바로 바깥에 Tweaks 폴더를 만든다. #여기에 모든 작성한 트윅을 몰아넣으면 관리가 편하다. mkdir $THEOS/../Tweaks
 

DVIA 우회 트윅 작성

 

1, 트윅 생성

#트윅을 생성할 위치로 이동한다. cd $THEOS/../Tweaks #트윅 생성 도구를 켠다 $THEOS/bin/nic.pl NIC 2.0 - New Instance Creator ------------------------------ [1.] iphone/activator_event [2.] iphone/application_modern [3.] iphone/application_swift [4.] iphone/flipswitch_switch [5.] iphone/framework [6.] iphone/library [7.] iphone/preference_bundle_modern [8.] iphone/tool [9.] iphone/tool_swift [10.] iphone/tweak [11.] iphone/xpc_service Choose a Template (required): 10 (트윅을 작성할 거니까) Project Name (required): dviajbbypass (생성될 폴더 이름) Package Name [com.yourcompany.dviajbbypass]: ohl.dviajbbypass (dpkg -l 했을 때 식별될 이름) Author/Maintainer Name [System Administrator]: night-ohl (트윅 작성자 이름) [iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.highaltitudehacks.dvia (트윅이 적용됐으면 하는 앱의 Bundle ID) [iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: (그냥 엔터) Instantiating iphone/tweak in dviajbbypass/... Done.
 
Bundle ID : 앱.app/Info.plist 에서 CFBundleIdentifier 확인.
notion image
notion image
 

2. 트윅 작성

# $THEOS/../Tweaks/ 경로 아래에 새로운 트윅 폴더가 생성된 상태. # 트윅 폴더로 이동하자 $ cd dviajbbypass #기본적으로 폴더 구성은 다음과 같다. #Makefile, Tweak.x, control, dviajbbypass.plist $ ls #Tweak.x 파일을 수정하여 후킹문을 작성한다. $ nano Tweak.x

Tweak.x

  • (void)jailbreakTest1Tapped:(id)arg1;
  • (void)jailbreakTest2Tapped:(id)arg1;
둘다 우회하는 트윅 코드
#isLoginValidated가 항상 1을 반환하도록 %hook RuntimeManipulationDetailsVC -(_Bool)isLoginValidated{ %log; return true; } %end #isJailbroken이 항상 0을 반환하도록 %hook JailbreakDetectionVC - (_Bool)isJailbroken { %log; return NO; } %end #엡에서 검사하는 특정 URL Scheme를 요청할 때 항상 0을 반환하도록 %hook UIApplication -(BOOL)canOpenURL:(NSURL *)url { %log; NSLog(@"%@", url); if([url isEqual:[[NSURL alloc] initWithString:@"cydia://package/com.example.package"]]){ NSLog(@"hehe openurl bypassed!"); return NO; } NSLog(@"openurl not bypassed!"); return %orig; } %end #앱에서 검사하는 각종 파일시스템 기반 검사를 항상 0을 반환하도록 %hook NSFileManager -(BOOL)fileExistsAtPath:(NSString *)path { %log; NSLog(@"%@", path); if([path hasSuffix:@"Cydia.app"] || [path hasSuffix:@"MobileSubstrate.dylib"] || [path hasSuffix:@"bash"] || [path hasSuffix:@"sshd"] || [path hasSuffix:@"/etc/apt"] || [path hasSuffix:@"jailbreak.txt"]) return 0; else return %orig; } %end
 

3. 트윅 패키징 및 설치

#패키징 하여 .deb 파일 형태로 뽑아냄 $ make package #deb파일 설치 $ make install #혹은 dpkg -i 명령어로 패키지 폴더에 있는 deb파일 설치 $ dpkg -i /packages/~~.deb [콘솔 로그] ==> Installing… Selecting previously unselected package com.ohl.dviajbbypass. (Reading database ... 12898 files and directories currently installed.) Preparing to unpack .../com.ohl.dviajbbypass_0.0.1-12+debug_iphoneos-arm.deb ... Unpacking com.ohl.dviajbbypass (0.0.1-12+debug) ... Setting up com.ohl.dviajbbypass (0.0.1-12+debug) ... ==> Unloading SpringBoard… #dpkg 설치 목록을 출력하여 제대로 설치됐는지 확인 #grep 패키지 이름으로 필터링 하면 된다. $ dpkg -l | grep ohl.dviajbbypass
 

동작 확인

 
notion image
Jailbreak Test 1
notion image
Jailbreak Test 2
둘 다 잘 우회된다.
끝.