在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ iOS/ iOS7 的動態(tài)庫注入
Hack 實戰(zhàn)——支付寶 App 手勢密碼校驗欺騙
使用 Reveal 分析他人 App
后臺 daemon 非法竊取用戶 iTunesstore 信息
使用 iNalyzer 分析應用程序
越獄檢測的攻與防
使用 introspy 追蹤分析應用程序
廢除應用程序的 ASLR 特性
使用 Cycript 修改支付寶 App 運行時
敏感邏輯的保護方案
Fishhook
使用 class-dump-z 分析支付寶 App
static 和被裁的符號表
iOS7 的動態(tài)庫注入
二進制和資源文件自檢
Hack 實戰(zhàn)——探究支付寶 App 手勢密碼
使用 Keychain-Dumper 導出 keychain 數(shù)據(jù)
數(shù)據(jù)擦除
Hack 實戰(zhàn)——解除支付寶 App 手勢解鎖錯誤次數(shù)限制
Objective-C 代碼混淆
阻止 GDB 依附
基于腳本實現(xiàn)動態(tài)庫注入
Hack 必備的命令與工具
鍵盤緩存與安全鍵盤
數(shù)據(jù)保護 API

iOS7 的動態(tài)庫注入

iOS 系統(tǒng)不斷升級,結構不斷調整,所以我們可以利用的動態(tài)庫注入方法也根據(jù)系統(tǒng)版本的不同而不同。

在此之前,我們可以利用環(huán)境變量 DYLD_INSERT_LIBRARY 來添加動態(tài)庫,iOS7 被成功越獄后,我們需要自己去探索實踐 iOS7 動態(tài)庫注入的方式。

本文將在 iOS7.0.4 環(huán)境下,以 hook 支付寶 app 程序中 ALPLauncherController 的視圖加載方法為例,介紹在 iOS7 下,如何實現(xiàn)動態(tài)庫注入攻擊。

相關工具位置信息

先總結羅列一下相關編譯、鏈接工具的位置路徑信息,在各位自行下載的 iOS SDK中

clang :    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
gcc :    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
ld :   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld
                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
sdk  :   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/

動態(tài)庫源程序

我們編寫一個 hook 支付寶 app 程序中 ALPLauncherController 的 viewDidLoad 方法,具體方法是利用 Method Swizzling 。

不熟悉 Method Swizzling 的話,可以參看我之前的這篇文章:Objective-C的hook方案(一): Method Swizzling

#import <UIKit/UIKit.h>  
#import <objc/runtime.h>  

@implementation UIViewController (HookPortal)  

-(void)myViewDidLoad  
{  
    NSLog(@"----------------------- myViewDidLoad ----------------------");  
}  

@end  

static void __attribute__((constructor)) initialize(void)  
{  
    NSLog(@"======================= initialize ========================");  

    Class class = objc_getClass("ALPLauncherController");  
    Method ori_Method =  class_getInstanceMethod(class, @selector(viewDidLoad));  
    Method my_Method = class_getInstanceMethod(class, @selector(myViewDidLoad));  
    method_exchangeImplementations(ori_Method, my_Method);  
}  

編譯 dylib

我們可以利用 xcode 直接幫忙編譯 .o,或者自己手動使用 clang 編譯,然后手動 ld :

ld -dylib -lsystem -lobjc  -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/ -o libwq.dylib xxx.o  

安置、驗證 dylib

將編譯好的 libwq.dylib 拷貝到 iPhone 文件系統(tǒng)中 /Library/MobileSubstrate/DynamicLibraries/

如果不放心庫是否能正常工作,可以加一步驗證操作,寫一個 demo 嘗試打開自己的庫:

voidvoid *handle = (void*)dlopen("/Library/MobileSubstrate/DynamicLibraries/libwq.dylib", 0x2);  
handle = dlsym(handle, "myViewDidLoad");  
if (handle) {  
    NSLog(@"++++");  
}else{  
    NSLog(@"----");  
}  

運行檢驗效果

到了驗證效果的時候,重啟設備后者執(zhí)行: killall SpringBoard

啟動支付寶 app,然后觀察 log 信息:

Portal[3631] <Notice>: MS:Notice: Injecting: com.alipay.iphoneclient `[Portal] (847.21)`  
Portal[3631] <Notice>: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/libwq.dylib  
Portal[3631] <Warning>: ======================= initialize ========================  
Portal[3631] <Warning>: ----------------------- myViewDidLoad ----------------------  

證明我們的動態(tài)庫已經(jīng)被加載, 我們的 Hook 也成功了。 剩下的就要自己去思考了,除了加句無聊的 Log,我們還可以做點什么呢?