IOS Frameworks Hook 另类hook方法 Logos hook 对照表 Frameworks插件 Twea ...

打印 上一主题 下一主题

主题 993|帖子 993|积分 2979


  • (void)viewDidLoad{
    %orig;
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 80, 37)];
    nameLabel.font = [UIFont systemFontOfSize:15];
    nameLabel.text = @“您APP已被hook”;
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.numberOfLines = 2;
    //用于设置UILabel中文本的行数
    [self.view addSubview:nameLabel];
    // 移动圆圆 界面位置信息
    1. CGRect rect_screen = [[UIScreen mainScreen]bounds];
    2. CGSize size_screen = rect_screen.size;
    3. int height = size_screen.height;
    4. int width  = size_screen.width;
    5. // 移动圆圆 初始化
    6. BallUIView *baView = [[BallUIView alloc] initWithFrame:CGRectMake(width-80, height/2-200, 50, 50)];
    7. baView.backgroundColor = [UIColor whiteColor];
    8. baView.layer.cornerRadius = 25;
    9. baView.layer.masksToBounds = YES;
    10. // 移动圆圆 小圆球图标
    11. UIImageView *imgViewM = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon40x40@3x.png"]];
    12. imgViewM.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    13. imgViewM.frame = CGRectMake(0, 0, 50, 50);
    14. [baView insertSubview:imgViewM atIndex:0];
    复制代码
    __weak typeof(self) weakSelf = self;
    1. //按钮点击事件
    2. baView.btnClick = ^(UIButton *sender) {
    3.     NSLog(@"btn.btnClick ~");
    4.     WebUrlViewController * xddweb = [[WebUrlViewController alloc] init];
    5.     [xddweb setUrl:@"http://www.baidu.com"];//页面打开网页
    6.    
    7.     [weakSelf.navigationController pushViewController:xddweb animated:YES];
    8. };
    9. [self.view addSubview:baView];//显示到界面
    复制代码
}
%end
//头文件 ProfileViewController 为了编译通过
@interface ProfileViewController: UIViewController
{
}
@property (nonatomic, copy) NSString* newProperty;


  • (void)classMethod;
@end
  1. Method Swizzle
  2. ### 转换为 Frameworks 插件 Hook
  3. 新建Frameworks项目 名称:frameworkxdds 会出现frameworkxdds.h 不用理会
  4. 反手就 新建 frameworkMain 文件 NSObject
  5. ↓得到 两个文件↓
  6. frameworkMain.m
  7. frameworkMain.h
  8. ### 运行初始化自动加载方法
  9. frameworkMain.m
  10. 添加 +(void)load
复制代码
@implementation frameworkMain
//我的界面加载完毕hook
IMP (* old_pviewDidLoad)(id self, SEL cmd);
//获取返回 sting tokrn
id (* old_appToken)(id self, SEL cmd);
//获取返回 sting tokrn
id (* old_userId)(id self, SEL cmd);
+(void)load{
[self addimg];//添加图标
[self getUserinfo];//hooh 用户信息
}
  1. ### 用户信息hook
  2. Frameworks hook HMIDAppTokenItem 类的 appToken方法
  3. Frameworks hook HMIDAppTokenItem 类的 userId方法
复制代码
//获取用户信息
+(void)getUserinfo {
  1. //HMIDAppTokenItem
  2. Method * appToken = class_getInstanceMethod(NSClassFromString(@"HMIDAppTokenItem"), @selector(appToken));
  3. //获取原方法保存
  4. old_appToken = method_getImplementation(appToken);
  5. //重新赋值IMP方法
  6. method_setImplementation(appToken, (IMP)my_appToken);
  7. //============2222=============
  8. Method * userId = class_getInstanceMethod(NSClassFromString(@"HMIDAppTokenItem"), @selector(userId));
  9. //获取原方法保存
  10. old_userId = method_getImplementation(userId);
  11. //重新赋值IMP方法
  12. method_setImplementation(userId, (IMP)my_userId);
复制代码
}
  1. ### 用户信息hook流程控制
  2. Frameworks hook HMIDAppTokenItem 类的 appToken 方法执行流程控制
  3. Frameworks hook HMIDAppTokenItem 类的 userId 方法执行流程控制
复制代码
id my_appToken(id self,SEL sel){
  1. //执行原方法
  2. NSString*tk = old_appToken(self, sel);
  3. [xddCode toeknSet:tk];//存储token
  4. return tk;
复制代码
}
id my_userId(id self,SEL sel){
  1. //执行原方法
  2. NSString*uid = old_userId(self, sel);
  3. [xddCode userIDSet:uid];//存储uuid
  4. return uid;
复制代码
}
  1. ### hook添加界面图标
  2. Frameworks hook ProfileViewController 类的 viewDidLoad 方法
复制代码
//添加图标
+(void)addimg {
  1. //ProfileViewController
  2. Method * viewDidLoad = class_getInstanceMethod(NSClassFromString(@"ProfileViewController"), @selector(viewDidLoad));
  3. //获取原方法保存
  4. old_pviewDidLoad = method_getImplementation(viewDidLoad);
  5. //重新赋值IMP方法
  6. method_setImplementation(viewDidLoad, (IMP)my_pviewDidLoad);
复制代码
}
  1. ### hook添加界面图标 流程控制
复制代码
void my_pviewDidLoad(id self,SEL sel) {
  1. ProfileViewController*v = self;
  2. //执行原方法
  3. old_pviewDidLoad(self, sel);
  4. UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 120, 80, 37)];
  5. nameLabel.font = [UIFont systemFontOfSize:15];
  6. nameLabel.text = @"您已hook成功";
  7. nameLabel.backgroundColor = [UIColor clearColor];
  8. nameLabel.textAlignment = NSTextAlignmentLeft;
  9. nameLabel.numberOfLines = 2;
  10. [v.view addSubview:nameLabel];
  11. //坐标初始化
  12. CGRect rect_screen = [[UIScreen mainScreen]bounds];
  13.   CGSize size_screen = rect_screen.size;
  14.   int height = size_screen.height;
  15.   int width  = size_screen.width;
  16.   
  17.   // 移动圆圆
  18.   BallUIView *baView = [[BallUIView alloc] initWithFrame:CGRectMake(width-80, height/2-200, 50, 50)];
  19.   baView.backgroundColor = [UIColor whiteColor];
  20.   baView.layer.cornerRadius = 25;
  21.   baView.layer.masksToBounds = YES;
  22.   
  23.   //小圆球 图标
  24.   UIImageView *imgViewM = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon40x40@3x.png"]];
  25.   imgViewM.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  26.   imgViewM.frame = CGRectMake(0, 0, 50, 50);
  27.   [baView insertSubview:imgViewM atIndex:0];
  28. __weak typeof(self) weakSelf = v;
  29.   baView.btnClick = ^(UIButton *sender) {
  30.       NSLog(@"btn.btnClick ~");
  31.       WebUrlViewController * xddweb = [[WebUrlViewController alloc] init];
  32.       [xddweb setUrl:@"http://www.baidu.com"];//打开网页
  33.       
  34.       [v.navigationController pushViewController:xddweb animated:YES];
  35.   };
  36.   [v.view addSubview:baView];
复制代码
}
  1. 附工程图
  2. ![](https://img-blog.csdnimg.cn/20200604140431251.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMDUxNTAz,size_16,color_FFFFFF,t_70)
  3. ![](https://img-blog.csdnimg.cn/20200604140609531.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMDUxNTAz,size_16,color_FFFFFF,t_70) ![](https://img-blog.csdnimg.cn/2020060414075081.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMDUxNTAz,size_16,color_FFFFFF,t_70)
  4. ![](https://img-blog.csdnimg.cn/20200604140905622.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMDUxNTAz,size_16,color_FFFFFF,t_70) 
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

道家人

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表