iOS逆向:Theos与Tweak进阶篇
2020-07-23 本文已影响0人
码小菜

目录
一,实现原理
二,使用进阶
三,实战练习:皮皮搞笑
四,实战练习:腾讯视频
一,实现原理
1,编译,打包和安装
-
make
:将代码编译为动态库

-
make package
:将动态库和plist
文件打包为deb
文件

-
make install
:将deb
文件通过本机10010端口发送到iPhone上,然后通过Cydia
来安装

-
Cydia
会将deb
文件安装在/Library/MobileSubstrate/DynamicLibraries
目录下,该目录由Cydia Substrate
插件来管理的

2,加载
-
plist
文件中存放的是目标APP的bundleId

- 当启动目标APP时,
Cydia Substrate
插件会根据plist
文件中的bundleId
加载对应的动态库

- 这种方式只是修改了内存中的代码,并没有修改可执行文件中的代码,所以每次启动目标APP都需要重新加载动态库

二,使用进阶
1,文件管理
- 位置

- 路径

- 导入

- 使用

- 结果(用
Xcode
查看)

2,版本号,序号和模式
- 版本号

- 序号:每次
make package
会自动+1

- 模式:debug(
make package
),release(make package debug=0
)

- 结果

三,实战练习:皮皮搞笑
1,目标:移除首页广告

2,用MJAppTools查询APP基本信息

3,查询列表控件的地址

4,查询列表控件的数据源

5,hook代码
%hook PPFeedPostADCell
// 移除数据
- (void)bindViewModel:(id)arg1 {
}
%end
%hook IGListAdapter
// 修改高度
- (struct CGSize)collectionView:(UICollectionView *)collectionView
layout:(id)arg2
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
// %c表示获取class
if ([cell isKindOfClass:%c(PPFeedPostADCell)]) {
cell.backgroundColor = UIColor.redColor;
return CGSizeMake(UIScreen.mainScreen.bounds.size.width, 20);
}
return %orig;
}
%end
6,最终效果

四,实战练习:腾讯视频
1,目标:移除视频广告

2,用frida-ios-dump进行脱壳

3,用all_class_dump导出头文件
- 说明
1>
class_dump
只能导出可执行文件,有些APP会把代码封装成动态库,这样就会导致很多文件找不到
2>all_class_dump
能同时导出可执行文件和动态库
- 下载工具:
git clone https://github.com/QingangGit/all_class_dump.git

- 在
all_class_dump.py
文件第一行加入:# coding:utf-8

- 开始导出:
python [all_class_dump.py文件路径] [ipa包路径]

- 导出的头文件存放在
dump_heads
文件夹中

4,查询相关控制器

5,hook代码
// 方法在父类中
%hook QNBPlayerVideoAdsViewController
- (id)initWithEventProxy:(id)arg1
withPlayerInfo:(id)arg2
withParentViewController:(id)arg3
withPageViewController:(id)arg4
withAddToParenViewControllerNow:(_Bool)arg5 {
return nil;
}
- (id)initWithEventProxy:(id)arg1
withPlayerInfo:(id)arg2
withParentViewController:(id)arg3
withParentEventViewController:(id)arg4
withAddToParenViewControllerNow:(_Bool)arg5 {
return nil;
}
%end
%hook QADInteractAdBussinessVC
- (id)initWithCustomParentView:(id)arg1 {
return nil;
}
%end
%hook QADMobileNewVideoController
- (id)initWithScenesType:(long long)arg1 screenMode:(long long)arg2 {
return nil;
}
%end
6,最终效果
