美文网首页iOS逆向工程Reverse逆向
theos越狱开发流程以及相关问题

theos越狱开发流程以及相关问题

作者: 西博尔 | 来源:发表于2016-07-14 16:21 被阅读2909次

1.环境安装

a.指定xcode(根据自己xcode路径来):

sudo xcode-select -s/Applications/Xcode.app/Contents/Developer

b.下载Theos(export很重要):

export THEOS=/opt/theos        
sudo git clone git://github.com/DHowett/theos.git $THEOS

c.下载ldid :

http://joedj.net/ldid  然后复制到/opt/theos/bin 
然后sudo chmod 777 /opt/theos/bin/ldid

d.配置CydiaSubstrate:

用iFun等iPhone上的工具,将iOS上
/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate拷贝到电脑上 
 然后改名为libsubstrate.dylib , 然后拷贝到/opt/theos/lib 中.

e.配置dkpg

sudo port install dpkg
不需要再下载那个dpkg-deb了

f.配置Theos NIC templates(可选)

就是额外多添加5中Theos工程模板 
从https://codeload.github.com/DHowett/theos-nic-templates/zip/master下载 
然后将解压后的5个.tar放到/opt/theos/templates/iphone/下即可

2.构建使用

a.创建iphone/tweak


/opt/theos/bin/nic.pl

NIC 1.0 - New Instance Creator
——————————
  [1.] iphone/application
  [2.] iphone/library
  [3.] iphone/preference_bundle
  [4.] iphone/tool
  [5.] iphone/tweak
Choose a Template (required): 1
Project Name (required): firstdemo
Package Name [com.yourcompany.firstdemo]: 
Author/Maintainer Name [Author Name]: 
Instantiating iphone/application in firstdemo/…
Done.

选择 [5.] iphone/tweak

Project Name (required): Test
Package Name [com.yourcompany.test]: com.test.firstTest
Author/Maintainer Name [小伍]: xiaowu
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.apple.springboard
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: SpringBoard

第一个相当于工程文件夹的名字
第二个相当于bundle id
第三个就是作者
第四个是作用对象的bundle identifier
第五个是要重启的应用

b.修改Makefile

TWEAK_NAME = iOSRE
iOSRE_FILES = Tweak.xm
include $(THEOS_MAKE_PATH)/tweak.mk
THEOS_DEVICE_IP = 192.168.1.34
iOSRE_FRAMEWORKS=UIKit Foundation
ARCHS = arm64

上面的ip必须写, 当然写你测试机的ip , 然后archs 写你想生成对应机型的型号

c.便携Tweak.xm

#import <UIKit/UIKit.h>


#import <SpringBoard/SpringBoard.h>

%hook SpringBoard

-(void)applicationDidFinishLaunching:(id)application {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
message:@"Welcome to your iPhone!"
delegate:nil
cancelButtonTitle:@"Thanks"
otherButtonTitles:nil];
[alert show];
[alert release];
%orig;

}

%end

你默认的Tweak.xm里面的代码都是被注销的

d.设置环境变量
打开terminal输入

export THEOS=/opt/theos/
export THEOS_DEVICE_IP=xxx.xxx.xxx.xxx(手机的ip地址)

3.构建工程

第一个命令:make

$ make
Making all for application firstdemo…
 Compiling main.m…
 Compiling firstdemoApplication.mm…
 Compiling RootViewController.mm…
 Linking application firstdemo…
 Stripping firstdemo…
 Signing firstdemo…

第二个命令:make package

make package
Making all for application firstdemo…
make[2]: Nothing to be done for ‘internal-application-compile’.
Making stage for application firstdemo…
 Copying resource directories into the application wrapper…
dpkg-deb: building package ‘com.yourcompany.firstdemo’ in ‘/Users/author/Desktop/firstdemo/com.yourcompany.firstdemo_0.0.1-1_iphoneos-arm.deb’.

第三个命令: make install

$ make package install
Making all for application firstdemo…
make[2]: Nothing to be done for `internal-application-compile’.
Making stage for application firstdemo…
 Copying resource directories into the application wrapper…
dpkg-deb: building package ‘com.yourcompany.firstdemo’ in ‘/Users/author/Desktop/firstdemo/com.yourcompany.firstdemo_0.0.1-1_iphoneos-arm.deb’.
...
root@ip’s password: 
...

过程会让你输入两次iphoen密码 , 默认是alpine

** 当然你也可以直接 make package install 一步到位, 直接编译, 打包, 安装一气呵成**

说一说 遇到的坑

1.在 环境安装 的第二步骤 下载theos , 下载好的theos有可能是有问题的

 /opt/theos/vendor/  里面的文件是否是空的? 仔细检查 否则在make编译的时候回报一个 什么vendor 的错误

2.如果在make成功之后还想make 发现报了Nothing to be done for `internal-library-compile’错误

那就把你刚才创建出来的obj删掉和packages删掉 , 然后显示隐藏文件, 你就会发现和obj同一个目录有一个.theos , 吧.theos里面的东西删掉就好了

3.简单总结下

基本问题就一下几点:
1.代码%hook ClassName 没有修改
2.代码没调用头文件
3.代码注释没有解开(代码写错)
4.makefile里面东西写错
5.makefile里面没有写ip地址
6.没有配置环境地址
7.遇到路径的问题你就 export THEOS_DEVICE_IP=192.168.1.34
8.遇到路径问题你就THEOS=/opt/theos 
基本就这样了

** 有什么问题欢迎留言讨论 , 谢谢大家 **

相关文章

网友评论

  • 鱼与熊掌不能兼得:我按照你的做下来,没有效果,都检查了,是什么原因呢
  • NBeanN:博主第二步写错了,少了一个空格,我找了很久才发现是命令错了
    sudo git clonegit://github.com/DHowett/theos.git $THEOS [博主的]
    sudo git clone git://github.com/DHowett/theos.git $THEOS [修改的]
    pro_cookies:我在输入make package install的时候出现如下问题
    ==> Error: Could not find “./packages/com.pcookie.myfirstyy_0.0.1-30+debug_iphoneos-arm.deb” to install. Aborting.
    然后我发现/packages/文件夹里并没有生成.deb文件 希望博主能帮忙告知下什么原因
    流浪瑞兹:执行了make 终端打印出了如下信息
    /Users/mengyijie/Desktop/练习代码/Theos/iosregreetings/theos/makefiles/targets/Darwin/iphone.mk:41: Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.
    Making all for tweak iOSREGreetings...
    Linking tweak iOSREGreetings...
    clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7
    ld: library not found for -ldylib1.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [obj/iOSREGreetings.dylib.ba964c90.unsigned] Error 1
    make[1]: *** [internal-library-all_] Error 2
    make: *** [iOSREGreetings.all.tweak.variables] Error 2
    请问博主这个问题是怎么导致的?该如何解决呢
    西博尔:非常感谢 确实少了一个
  • ba79ec38f5ac:你好,楼主 我的theos环境搭建好了make的时候make不出 生成除了g个文件以外还有个文件obj和debug 没有dylib请问我是哪里出了问题,配置环境重复很多次了
    CGPointZero:删了还是报错
    make[2]: Nothing to be done for `internal-library-compile'.
    西博尔:@iwexin dylib是在一个隐藏文件中, 打开隐藏文件就能看到了
  • Ecolean:/Applications/Xcode.app/Contents/Developer/usr/bin/make package requires dpkg-deb 这个错误你遇到过么
    西博尔:@Ecolean dpkg-deb 你看看你这个对不对 , 你看看资料dpkg-deb安装了么

本文标题:theos越狱开发流程以及相关问题

本文链接:https://www.haomeiwen.com/subject/hvbejttx.html