IOS逆向安全(2)-小试插件有根越狱
0x01 Reveal反调试UI
手机端打开APP,电脑端在Reveal工具上选择:
然后就可以看到下面的界面:
分析发现,微信的“发现”页面就是Class (MMMainTableView)
远程到手机的ssh,使用cycript确认内存地址 0x124ddca00是否为MMMainTableView
cycript -p WeChat
#0x124ddca00
查找它继承哪个类
#0x124ddca00.superclass
所以它的父类为:UITableView
查找它的数据源
#0x124ddca00.dataSource
刚好对应上了UI的View控制器:
所以对FindFriendEntryViewController进行变更即可
0x02 Class-dump微信的头文件
首先对微信进行脱壳操作,这里我直接使用AppDump3进行脱壳,然后传到电脑里
将ipa进行解压
找到其中的Macho文件,拖到桌面
class-dump -H WeChat -o Headers
这个报错是Xcode15的兼容问题,找个兼容的class-dump即可
https://github.com/tangxiaofeng7/class-dump-bin
微信很大,耐心等待即可,我本地跑了4分多钟
最后在文件夹HeaderWechat中找到所有的头文件
找到数据源FindFriendEntryViewController的头文件
转换为diy代码
logify.pl HeaderWechat/FindFriendEntryViewController.h > Tweak.xm
这里转换后的文件为空,有点奇怪。
0x03 插件代码
nic.pl
文件Makefile修改为:
TARGET := iphone:clang:latest:7.0
ARCHS := arm64
export THEOS_DEVICE_IP=192.168.1.102
export THEOS_DEVICE_PORT=22
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = tweakwechat
tweakwechat_FILES = Tweak.x
tweakwechat_CFLAGS = -fobjc-arc
include $(THEOS_MAKE_PATH)/tweak.mk
文件Tweak.x修改为:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface FindFriendEntryViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
%hook FindFriendEntryViewController
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return %orig + 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section == [self numberOfSectionsInTableView:tableView] -1 ) {
return 2;
} else{
return %orig;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section != [self numberOfSectionsInTableView:tableView] -1) {
return %orig;
}
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.backgroundColor = [UIColor whiteColor];
cell.textLabel.text = @"txf牛逼";
return cell;
}
%end
执行编译
make clean && make && make package && make install
输入root密码即可成功安装插件
微信效果:
License:
杭州小单纯