IOS Frameworks Hook 另类hook方法 Logos hook 对照表 Frameworks插件 Tweak 插件
[*] (void)viewDidLoad{
%orig;
UILabel *nameLabel = [initWithFrame:CGRectMake(10, 60, 80, 37)];
nameLabel.font = ;
nameLabel.text = @“您APP已被hook”;
nameLabel.backgroundColor = ;
nameLabel.textAlignment = NSTextAlignmentLeft;
nameLabel.numberOfLines = 2;
//用于设置UILabel中文本的行数
;
// 移动圆圆 界面位置信息
CGRect rect_screen = [bounds];
CGSize size_screen = rect_screen.size;
int height = size_screen.height;
int width= size_screen.width;
// 移动圆圆 初始化
BallUIView *baView = [ initWithFrame:CGRectMake(width-80, height/2-200, 50, 50)];
baView.backgroundColor = ;
baView.layer.cornerRadius = 25;
baView.layer.masksToBounds = YES;
// 移动圆圆 小圆球图标
UIImageView *imgViewM = [ initWithImage:];
imgViewM.autoresizingMask = UIViewAutoresizingFlexibleWidth;
imgViewM.frame = CGRectMake(0, 0, 50, 50);
;
__weak typeof(self) weakSelf = self;
//按钮点击事件
baView.btnClick = ^(UIButton *sender) {
NSLog(@"btn.btnClick ~");
WebUrlViewController * xddweb = [ init];
;//页面打开网页
;
};
;//显示到界面
}
%end
//头文件 ProfileViewController 为了编译通过
@interface ProfileViewController: UIViewController
{
}
@property (nonatomic, copy) NSString* newProperty;
[*](void)classMethod;
@end
Method Swizzle
### 转换为 Frameworks 插件 Hook
新建Frameworks项目 名称:frameworkxdds 会出现frameworkxdds.h 不用理会
反手就 新建 frameworkMain 文件 NSObject
↓得到 两个文件↓
frameworkMain.m
frameworkMain.h
### 运行初始化自动加载方法
frameworkMain.m
添加 +(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{
;//添加图标
;//hooh 用户信息
}
### 用户信息hook
Frameworks hook HMIDAppTokenItem 类的 appToken方法
Frameworks hook HMIDAppTokenItem 类的 userId方法
//获取用户信息
+(void)getUserinfo {
//HMIDAppTokenItem
Method * appToken = class_getInstanceMethod(NSClassFromString(@"HMIDAppTokenItem"), @selector(appToken));
//获取原方法保存
old_appToken = method_getImplementation(appToken);
//重新赋值IMP方法
method_setImplementation(appToken, (IMP)my_appToken);
//============2222=============
Method * userId = class_getInstanceMethod(NSClassFromString(@"HMIDAppTokenItem"), @selector(userId));
//获取原方法保存
old_userId = method_getImplementation(userId);
//重新赋值IMP方法
method_setImplementation(userId, (IMP)my_userId);
}
### 用户信息hook流程控制
Frameworks hook HMIDAppTokenItem 类的 appToken 方法执行流程控制
Frameworks hook HMIDAppTokenItem 类的 userId 方法执行流程控制
id my_appToken(id self,SEL sel){
//执行原方法
NSString*tk = old_appToken(self, sel);
;//存储token
return tk;
}
id my_userId(id self,SEL sel){
//执行原方法
NSString*uid = old_userId(self, sel);
;//存储uuid
return uid;
}
### hook添加界面图标
Frameworks hook ProfileViewController 类的 viewDidLoad 方法
//添加图标
+(void)addimg {
//ProfileViewController
Method * viewDidLoad = class_getInstanceMethod(NSClassFromString(@"ProfileViewController"), @selector(viewDidLoad));
//获取原方法保存
old_pviewDidLoad = method_getImplementation(viewDidLoad);
//重新赋值IMP方法
method_setImplementation(viewDidLoad, (IMP)my_pviewDidLoad);
}
### hook添加界面图标 流程控制
void my_pviewDidLoad(id self,SEL sel) {
ProfileViewController*v = self;
//执行原方法
old_pviewDidLoad(self, sel);
UILabel *nameLabel = [initWithFrame:CGRectMake(10, 120, 80, 37)];
nameLabel.font = ;
nameLabel.text = @"您已hook成功";
nameLabel.backgroundColor = ;
nameLabel.textAlignment = NSTextAlignmentLeft;
nameLabel.numberOfLines = 2;
;
//坐标初始化
CGRect rect_screen = [bounds];
CGSize size_screen = rect_screen.size;
int height = size_screen.height;
int width= size_screen.width;
// 移动圆圆
BallUIView *baView = [ initWithFrame:CGRectMake(width-80, height/2-200, 50, 50)];
baView.backgroundColor = ;
baView.layer.cornerRadius = 25;
baView.layer.masksToBounds = YES;
//小圆球 图标
UIImageView *imgViewM = [ initWithImage:];
imgViewM.autoresizingMask = UIViewAutoresizingFlexibleWidth;
imgViewM.frame = CGRectMake(0, 0, 50, 50);
;
__weak typeof(self) weakSelf = v;
baView.btnClick = ^(UIButton *sender) {
NSLog(@"btn.btnClick ~");
WebUrlViewController * xddweb = [ init];
;//打开网页
;
};
;
}
附工程图

 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]