【iOS逆向】微信发现添加cell 关联 数据存储 加载图片资源

总结:1、%orig和%new两个方法;2、宏定义#path方法;3、资源加载打包方法

需求:微信“发现”界面增加2行cell

【iOS逆向】微信发现添加cell 关联 数据存储 加载图片资源

找到数据源控制器

image.png

找到手机中的Mach-O文件,查看是否脱壳,如果已脱壳,直接复制出进行dump头文件。

image.png
image.png
image.png

返回cell

image.png

退出微信功能实现

image.png

数据存储

image.png
image.png

崩溃了 因为找不到autoChange这个方法

查看手机的崩溃信息

image.png
image.png

在hook里面写的方法都认为是替换以前的方法。

新方法(最好都加一个前缀)需要添加一个%new

image.png

加载图片资源

写全路径

在tweak工程文件夹中新建一个layout(相当于手机中的Devices)文件夹

image.png

和以下层级文件夹放入图片在Preferences然后再新建一个App单独的文件夹(防止冲突)

image.png
image.png

则路径

image.png

宏定义优化

image.png
image.png

[图片上传中...(image-ea1e30-1524636864290-0)]

未越狱手机也可以写插件,后面可能会讲到。

shift+command+.显示隐藏文件

所有代码

define MJDefaults [NSUserDefaults standardUserDefaults]

define MJAutoKey @"mj_auto_key"

define MJFile(path) @"/Library/PreferenceLoader/Preferences/MJWeChat/" #path

%hook FindFriendEntryViewController

// 一共有多少组

  • (long long)numberOfSectionsInTableView:(id)tableView

{

return %orig + 1;

}

// 每一组有多少行

  • (long long)tableView:(id)tableView numberOfRowsInSection:(long long)section

{

if (section == [self numberOfSectionsInTableView:tableView] - 1) {

    return 2;

} else {

    return %orig;

}

}

// 监听自动抢红包的开关(新方法需要添加%new)

%new

  • (void)mj_autoChange:(UISwitch *)switchView

{

[MJDefaults setBool:switchView.isOn forKey:MJAutoKey];

[MJDefaults synchronize];

}

// 返回每一行的cell

  • (id)tableView:(id)tableView cellForRowAtIndexPath:(id)indexPath

{

if ([indexPath section] !=

    [self numberOfSectionsInTableView:tableView] - 1) {

    return %orig;

}

// 最后一组cell的公共代码

NSString *cellId = ([indexPath row] == 1) ? @"exitCellId" : @"autoCellId";

UITableViewCell *cell = [tableView

        dequeueReusableCellWithIdentifier:cellId];

if (cell == nil) {

    cell = [[UITableViewCell alloc]

            initWithStyle:UITableViewCellStyleDefault

            reuseIdentifier:cellId];

    cell.backgroundColor = [UIColor whiteColor];

    // 图片

    cell.imageView.image = [UIImage imageWithContentsOfFile:MJFile(skull.png)];

}

// 最后一组cell的具体代码

if ([indexPath row] == 0) {

    cell.textLabel.text = @"自动抢红包";

    // 开关

    UISwitch *switchView = [[UISwitch alloc] init];

    switchView.on = [MJDefaults boolForKey:MJAutoKey];

    [switchView addTarget:self

        action:@selector(mj_autoChange:)

        forControlEvents:UIControlEventValueChanged];

    cell.accessoryView = switchView;

} else if ([indexPath row] == 1) {

    cell.textLabel.text = @"退出微信";

}

return cell;

}

// 每一行的高度

  • (double)tableView:(id)tableView heightForRowAtIndexPath:(id)indexPath

{

if ([indexPath section] !=

    [self numberOfSectionsInTableView:tableView] - 1) {

    return %orig;

}

return 44;

}

// 点击的监听

  • (void)tableView:(id)tableView didSelectRowAtIndexPath:(id)indexPath

{

if ([indexPath section] !=

    [self numberOfSectionsInTableView:tableView] - 1) {

    %orig;

    return;

}

[tableView deselectRowAtIndexPath:indexPath animated:YES];

if ([indexPath row] == 1) {

    // exit(0);

    // 终止进程

    abort();

}

}

%end

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.ios高性能编程 (1).内层 最小的内层平均值和峰值(2).耗电量 高效的算法和数据结构(3).初始化时...
    欧辰_OSR阅读 29,612评论 8 265
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,090评论 3 38
  • { 24、Sqlite数据库 1、存储大数据量,增删改查,常见管理系统:Oracle、MSSQLServer、DB...
    CYC666阅读 961评论 0 1
  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,211评论 30 472
  • 公司最近在招人,领导让我负责面试。在接到这个任务的时候我是一脸懵逼的,之前我是被面试者,现在要农奴翻身把歌唱去面...
    藤吖吖阅读 297评论 0 0