아이폰 앱 코드 패치 트윅 개발 with theos

홈 > IOS > IOS
IOS

아이폰 앱 코드 패치 트윅 개발 with theos

S zzanghacker 7 7207 1

설치 환경

  • 탈옥이된 iPhone
  • mac OS

설치 방법 (mac OS 기준)

Xcode 설치

Xcode Command Line 설치

$xcode-select --install

Homebrew 설치

$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

dpkg, ldid 설치

$brew install dpkg ldid

Theos 설치

  • Theos 파일 설치
$sudo SetFile -a v /opt
$cd ../../opt
$git clone --recursive https://github.com/theos/theos.git
  • 환경 변수 설정
touch ~/.bash_profile; open ~/.bash_profile
#THEOS SETTINGS
export THEOS=/opt/theos
export PATH=$THEOS/bin:$PATH
export THEOS_DEVICE_IP=xxx.xxx.xxx.xxx // IP 설정
export THEOS_DEVICE_PORT=22 // PORT 설정
  • SDK 헤더 파일 설정
$curl -LO https://github.com/theos/sdks/archive/master.zip
$TMP=$(mktemp -d)
$unzip master.zip -d $TMP
$mv $TMP/sdks-master/*.sdk $THEOS/sdks
$rm -r master.zip $TMP

설치 방법 (iPhone 기준)

repo 추가

트윅 설치

  • Theos Installer
  • Theos Dependencies
  • NewTerm 2 or MTerminal or etc Terminal
  • Filza File Manager or etc File Manager

Theos 설치 확인

  • Theos Installer를 설치 후 확인
$cd /private/var/theos/
  • SDK 설치
$su
$alpine
$theosinstaller
$theosinstaller <SDK Version>

Theos 실행 확인 (공통)

$ $THEOS/bin/nic.pl
NIC 2.0 - New Instance Creator
------------------------------
  [1.] iOSGods CSCI Patcher v2.2
  [2.] iOSGods MSHook Patcher v1.1
  [3.] iOSGods Patcher v1.2
  [4.] iOSGods Tweak v1.3
  [5.] iphone/activator_event
  [6.] iphone/application_modern
  [7.] iphone/application_swift
  [8.] iphone/flipswitch_switch
  [9.] iphone/framework
  [10.] iphone/library
  [11.] iphone/preference_bundle_modern
  [12.] iphone/tool
  [13.] iphone/tool_swift
  [14.] iphone/tweak
  [15.] iphone/xpc_service

Tweak 프로젝트 생성

  • Theos 실행
$THEOS/bin/nic.pl
  • tweak 선택 (아래 번호 기준으로 16번)
$ $THEOS/bin/nic.pl
NIC 2.0 - New Instance Creator
------------------------------
  [1.] iOSGods CSCI Patcher v2.2
  [2.] iOSGods MSHook Patcher v1.1
  [3.] iOSGods Patcher v1.2
  [4.] iOSGods Tweak v1.3
  [5.] iphone/activator_event
  [6.] iphone/application_modern
  [7.] iphone/application_swift
  [8.] iphone/flipswitch_switch
  [9.] iphone/framework
  [10.] iphone/library
  [11.] iphone/preference_bundle_modern
  [12.] iphone/tool
  [13.] iphone/tool_swift
  [14.] iphone/tweak
  [15.] iphone/xpc_service
Choose a Template (required): 16
  • 프로젝트명은 작성
Project Name (required): kmspatch
  • 패키지명은 소문자로 작성
  • 다른 패키지와 중복되지 않게 작성
Package Name [com.yourcompany.tweakhooktest]: com.hack.kmspatch1
  • "이름 <메일>" 형식으로 작성
Author/Maintainer Name [Kang]:  <root@vuln.kr>
  • SpringBoard에서 작동 시키고 싶으면 enter
  • 특정 앱을 동작시키고 싶으면 앱 번들을 지정
  • 예시는 페이코 번들 ID
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.AAA.BBB
  • 설치 후 강제 종료시킬 앱의 이름 입력
  • 강제 종료 시키고 싶지 않으면 "-"
  • 무시 "enter"
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: (enter)

Hook 코드

[

iOSCheaters/Battleheart-v1.5.2-Cheats

[Patcher][CSCI][sub_x]Complete Source. Contribute to iOSCheaters/Battleheart-v1.5.2-Cheats development by creating an account on GitHub.

github.com

](https://github.com/iOSCheaters/Battleheart-v1.5.2-Cheats)

system api

#import <substrate.h>

int (*old_function)(void);

void my_exit(int status)
{
    return;
}

// %ctor 앱 실행시 hook
%ctor
{
    @autoreleasepool
    {
        // MSHookFunction 사용
        // my_exit 동작
        MSHookFunction((void *)exit, (void *)&my_exit, (void **)&old_function1);
    }
    writeData(0x714C8,0x071081E0);
}

no symbol

#import <substrate.h>

int (*old_function)(void);

int my_hook(int status)
{
    return 1;
}

// %ctor 앱 실행시 hook
%ctor
{

    @autoreleasepool
    {
        unsigned long targetAddress = _dyld_get_image_vmaddr_slide(0) + 0x100b77738; // 메모리 시작 주소 번지 + 후킹 대상의 offset 위치

        MSHookFunction((void *)targetAddress, (void *)&my_hook, (void **)&old_function);
    }

}

Tweak 설치

단말기 IP 설정하여 설치

make package install

수동 설치

  • packages 경로에 deb 파일 생성
  • iFunbox를 통해서 iPhone에 저장
  • iFile을 통해 파일 선택
  • install 진행

7 Comments
S 붉은상어 2019.10.14 10:10  
굳굳 제가 다음에 적으려던 내용이 여기 다 나와있습니다 ~
5 파파엄마 2019.10.14 21:15  
아주 좋네요 ㅎㅎㅎㅎ 좋은 강좌입니다
1 논단 2019.11.08 21:03  
요즘은 iFile보다는 Filza를 많이 사용합니다
28 사딸라 2020.01.08 23:50  
좋은 정보 감사합니다
7 임중호 2020.05.24 00:43  
감사합니데이
4 쿨록 2020.08.09 17:10  
감사합니다
1 드봉 2021.09.21 14:41  
감사합니다...
Category