iOS逆向篇——Theos中的Tweak使用

2021-03-24  本文已影响0人  Lucky_Blue

Theos 环境配置安装

1.安装ldid
brew install ldid
2.Theos安装

官方建议把Theos安装在/opt/theos目录下

sudo git clone --recursive https://github.com/theos/theos.git /opt/theos

然后把/opt/theos的权限改为自己所拥有

sudo chown $(id -u):$(id -g) /opt/theos
3.环境变量
export THEOS=/opt/theos
export PATH=/opt/theos/bin/:$PATH
4.测试安装是否成功

在任意路径下输入nic.pl

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):

Tweak项目创建

1. 输入nic.pl后,选择模板输入10
Choose a Template (required): 10
2.输入tweak的工程名
Project Name (required): readerTweak
3.输入deb包名(格式类似bundle Identifier
Package Name [com.yourcompany.readertweak]: com.lb.readertweak
4. 输入作者或维护人名字
Author/Maintainer Name [mac]: Lucky Blue
5. 输入tweak作用的对象,就是需要需要HOOKAPPbundle Identifier
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.tencent.ied.app.comic
6.输入tweak安装完成后需要重启的应用,以进程名表示,比如系统的桌面:
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: SpringBoard

成功终端就会显示

Instantiating iphone/tweak in readertweak/...
Done.
完整步骤
成功后会生成下面四个文件

Tweak项目编写

在Makefile文件最上面加入下面两行代码

export THEOS_DEVICE_IP=127.0.0.1
export THEOS_DEVICE_PORT=5757

删除所有Tweak.x文件里默认的注释,然后输入如下
Logos官方文档

%hook ComicHomeViewController //%hook 类名
-(void)viewWillAppear:(BOOL)animated{
    %orig;// %orig是Logos语法,先调用上一层的代码,跟oc的 [super xxxx]差不多的意思
//创建UIAlertView
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"注意" 
        message:@"这是第一个tweak项目" 
        delegate:nil 
        cancelButtonTitle:@"确定" 
        otherButtonTitles:nil];
    [alert show];
}
%end

编译,打包和安装

make clean && make && make package && make install
编译打包安装成功
Cydia可以看到已安装
上一篇 下一篇

猜你喜欢

热点阅读