LogosTweak,可以帮我们在不用重签名的情况下进行代码的动态注入,它的使用前提是在越狱设备上,下面记录下新建项目的效果,以及在使用时遇到的坑
创建第一个LogosTweak项目
-
创建LogosTweak工程
创建工程 -
添加配置
添加配置
在这里我做了一个端口的映射,在我们运行项目前如果没有做映射则在编译时会报错
Creating zip /Users/liumingfei/Desktop/HelloLogosTweak/Packages/com.lmf.HelloLogosTweak_0.1-1_iphoneos-arm.zip... Done.
ssh: connect to host localhost port 2222: Connection refused
ssh -p2222 root@localhost mkdir -p "/var/root/MonkeyDevPackages"
Command PhaseScriptExecution failed with a nonzero exit code
所以在运行前需要先做下端口映射,这里使用的是
iproxy 2222 22
- 运行项目Cmd + B,出现报错
An empty identity is not valid when signing a binary for the product type 'Dynamic Library'.
碰到这个问题,需要在该项目的target的build settings 中添加一个参数
Add User-Defined Setting点击Add User-Defined Setting
CODE_SIGNING_ALLOWED
添加CODE_SIGNING_ALLOWED=NO,重新编译,编译成功
- 下面添加logos代码,这里只hook SpringBoard方法,以做演示
#import <UIKit/UIKit.h>
%hook SpringBoard
- (void)applicationDidFinishLaunching:(id)application {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello"message:@"My LogosTeak Tip!!!"delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil];
[alert show];
%orig;
}
%end
连接设备Cmd + B,Build Successed
Build Successedg
工程目录介绍
工程目录- xm - 写logos hook代码的地方
- mm - 编译成功后会将xm代码转换成OC、C++代码
- control - 里面是一些工程信息包括作者、项目名。。。
- HelloLogosTweak.plist - 这里填写需要hook的进程的BundleID,这里是com.apple.springboard
- Packages 这个目录没有关联到项目里,在编译成功后会生成一个.deb和一个.zip的文件
注:在装MonkeyDev的环境时,一定要做免密设置或者安装sshpass.,这里在安装sshpass时失败,所以在运行时报错
Command /bin/sh failed with exit code 1
解决就是安装好sshpass,即可
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
使用官网的安装路径一直失败的话,可以用下面的一条
brew install http://git.io/sshpass.rb
生活如此美好,今天就点到为止。。。
网友评论