本文主要是以WeChat为例,讲解如何破坏WeChat注册、以及如何获取登录密码
引子
在进行WeChat实践操作时,首先需要了解一个概念:Method Swizzing(即方法交换)
Method Swizzing(即方法交换)是利用OC的Runtime
特性,动态改变SEL(方法编号)和IMP(方法实现)的对应关系
,达到OC方法调用流程改变的目的,主要用于OC方法。
在OC中,SEL和IMP之间的关系,类似与一本书的目录,是一一对应的
-
SEL
:方法编号,类似于目录中的标题 -
IMP
:方法实现的真实地址指针,类似于目录中的页码
同时,Runtime中也提供了用于交换两个SEL和IMP的方法,method_exchangeIMP
,我们可以通过这个函数交换两个SEL和IMP的对应关系
破坏微信注册
准备工作:需要新建一个工程,并重签名,且采用Framework注入的方式
- 重签名参考文章:iOS逆向之应用重签名(下)
- Framework注入方式参考文章:iOS逆向之代码注入(上)
这里破坏的微信的注册,主要是通过runtime
方法进行注册方法的hook
1、获取注册的相关信息
-
1、通过
lldb
调试获取WeChat的注册
-
2、获取注册的target、action
-
target
:WCAccountLoginControlLogic -
action
:onFirstViewRegister
-
2、简单hook演示
- 1、通过
class_getInstanceMethod
+method_exchangeImplementations
方法,hook注册的点击事件
@implementation inject
+ (void)load{
// 改变微信的注册
Method oldMethod = class_getInstanceMethod(objc_getClass("WCAccountLoginControlLogic"), @selector(onFirstViewRegister));
Method newMethod = class_getInstanceMethod(self, @selector(my_method));
method_exchangeImplementations(oldMethod, newMethod);
}
- (void)my_method{
NSLog(@"CJLHook --- 注册不了了!");
}
@end