追蹤iOS某APP的驗(yàn)證簽名過程

利用反匯編追蹤iOS某APP的驗(yàn)證簽名過程


環(huán)境需求

  • 越獄iOS設(shè)備一臺(tái)奥喻,

  • Openssh

  • Cycript

  • Hopper Disassembler v4*

  • iProxy

對iOS APP進(jìn)行砸殼

首先用USB連接越獄手機(jī),使用USB進(jìn)行端口映射到本機(jī)

iproxy 2222 22

新開終端

ssh root@127.0.0.1 -p 2222

開始砸殼

DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /var/mobile/Containers/Bundle/Application/1999C8D2-58C1-43C0-A717-A44B55CC1FEA/***.app/***

得到砸殼后的文件

Testerde-iPhone:~/decrypted root# ls
cf.decrypted
Testerde-iPhone:~/decrypted root#

使用Hopper載入砸殼后的文件同時(shí)使用class-dump導(dǎo)出頭文件

class-dump -H ./cf.decrypted -o ./header --arch arm64

注意在砸殼手機(jī)上運(yùn)行的是什么CPU架構(gòu)的念秧,我們這里是arm64

在使用charles抓包時(shí)發(fā)現(xiàn)URL中使用auth_key參數(shù)傳遞了驗(yàn)證簽名鲸匿,所以在hopper 中搜索auth_key
得到以下片段

00000001011436a9         db         "WSOpenMemberViewController", 0             ; DATA XREF=cfstring_WSOpenMemberViewController
00000001011436c4         db         "loadedTimeRanges", 0                       ; DATA XREF=cfstring_loadedTimeRanges
00000001011436d5         db         "v32@?0{?=qiIq}8", 0
00000001011436e5         db         "mm:ss", 0                                  ; DATA XREF=cfstring_mm_ss
00000001011436eb         db         "%@-%.f-0-0-%@", 0                          ; DATA XREF=cfstring______f_0_0___
00000001011436f9         db         "%@?auth_key=%.f-0-0-%@", 0                 ; DATA XREF=cfstring____auth_key___f_0_0___
0000000101143710         db         "player", 0                                 ; DATA XREF=0x10138cc60, 0x1013d6b60, 0x1013e1218, 0x101484138, 0x1014e82c8, 0x1014f6400, 0x10155c500, 0x101592bb8, 0x101593f18
0000000101143717         db         "T@\"AVPlayer\",&,N,V_player", 0            ; DATA XREF=0x10138cc60, 0x1013d6b60, 0x101484138, 0x1014f6400, 0x101592bb8, 0x101593f18
0000000101143731         db         "playerItem", 0                             ; DATA XREF=0x10138cc70, 0x1013d6b70
000000010114373c         db         "T@\"AVPlayerItem\",&,N,V_playerItem", 0    ; DATA XREF=0x10138cc70, 0x1013d6b70
000000010114375e         db         "playerLayer", 0                            ; DATA XREF=0x10138cc80, 0x1013d6b80, 0x1013e1228, 0x1014f6410, 0x10155c510
000000010114376a         db         "T@\"AVPlayerLayer\",&,N,V_playerLayer", 0  ; DATA XREF=0x10138cc80, 0x1013d6b80, 0x1014f6410

雙擊

00000001011436f9         db         "%@?auth_key=%.f-0-0-%@", 0                 ; DATA XREF=cfstring____auth_key___f_0_0___

查看到

 cfstring____auth_key___f_0_0___:
00000001012e7760         dq         ___CFConstantStringClassReference, 0x7c8, 0x1011436f9, 0x16 ; "%@?auth_key=%.f-0-0-%@", DATA XREF=-[WSAVPlayerView encryptionUrl:andVideoKey:]+368, -[WSSpecialColumPlayerView encryptionUrl:andVideoKey:]+368

這可以可以得出auth_key這個(gè)字符串在

  • [WSAVPlayerView encryptionUrl:andVideoKey:]+368
  • [WSSpecialColumPlayerView encryptionUrl:andVideoKey:]+368

這兩個(gè)地方使用過烤惊,這查看使用class_dump導(dǎo)出的頭文件
WSAVPlayerView.h

//
//     Generated by class-dump 3.5 (64 bit).
//
//     class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//

#import "UIView.h"

@class AVPlayer, AVPlayerItem, AVPlayerLayer, NSString, NSTimer, UIButton, UIImageView, UILabel, UIProgressView, UISlider, UITapGestureRecognizer;

@interface WSAVPlayerView : UIView
{
    _Bool _isPortraitShow;
    _Bool _isVIP;
    _Bool _isNetWorkWiFi;
    _Bool _isSeeking;
    _Bool _isShowingTool;
    NSString *_currentUrlString;
    NSString *_videoKey;
    double _time;
    id <WSAVPlayerViewDelegate> _delegate;
    AVPlayer *_player;
    AVPlayerItem *_playerItem;
    AVPlayerLayer *_playerLayer;
    UISlider *_progressSlider;
    UIView *_topToolView;
    UIView *_bottomToolView;
    UIView *_vipView;
    UILabel *_vipLabel;
    UIButton *_vipButton;
    UIButton *_continueButton;
    UIImageView *_vipBgImageView;
    UIButton *_backButton;
    UIButton *_lockButton;
    UIButton *_playButton;
    UILabel *_progressTimeLabel;
    UILabel *_restTimeLabel;
    UIButton *_expandOrShrinkButton;
    AVPlayerItem *_currentPlayerItem;
    NSTimer *_progressTimer;
    UIProgressView *_progressView;
    UITapGestureRecognizer *_tapGesture;
    NSTimer *_toolControlTimer;
}

+ (Class)layerClass;
@property(nonatomic) _Bool isShowingTool; // @synthesize isShowingTool=_isShowingTool;
@property(nonatomic) _Bool isSeeking; // @synthesize isSeeking=_isSeeking;
@property(retain, nonatomic) NSTimer *toolControlTimer; // @synthesize toolControlTimer=_toolControlTimer;
@property(retain, nonatomic) UITapGestureRecognizer *tapGesture; // @synthesize tapGesture=_tapGesture;
@property(retain, nonatomic) UIProgressView *progressView; // @synthesize progressView=_progressView;
@property(retain, nonatomic) NSTimer *progressTimer; // @synthesize progressTimer=_progressTimer;
@property(retain, nonatomic) AVPlayerItem *currentPlayerItem; // @synthesize currentPlayerItem=_currentPlayerItem;
@property(retain, nonatomic) UIButton *expandOrShrinkButton; // @synthesize expandOrShrinkButton=_expandOrShrinkButton;
@property(retain, nonatomic) UILabel *restTimeLabel; // @synthesize restTimeLabel=_restTimeLabel;
@property(retain, nonatomic) UILabel *progressTimeLabel; // @synthesize progressTimeLabel=_progressTimeLabel;
@property(retain, nonatomic) UIButton *playButton; // @synthesize playButton=_playButton;
@property(retain, nonatomic) UIButton *lockButton; // @synthesize lockButton=_lockButton;
@property(retain, nonatomic) UIButton *backButton; // @synthesize backButton=_backButton;
@property(retain, nonatomic) UIImageView *vipBgImageView; // @synthesize vipBgImageView=_vipBgImageView;
@property(retain, nonatomic) UIButton *continueButton; // @synthesize continueButton=_continueButton;
@property(retain, nonatomic) UIButton *vipButton; // @synthesize vipButton=_vipButton;
@property(retain, nonatomic) UILabel *vipLabel; // @synthesize vipLabel=_vipLabel;
@property(retain, nonatomic) UIView *vipView; // @synthesize vipView=_vipView;
@property(retain, nonatomic) UIView *bottomToolView; // @synthesize bottomToolView=_bottomToolView;
@property(retain, nonatomic) UIView *topToolView; // @synthesize topToolView=_topToolView;
@property(retain, nonatomic) UISlider *progressSlider; // @synthesize progressSlider=_progressSlider;
@property(retain, nonatomic) AVPlayerLayer *playerLayer; // @synthesize playerLayer=_playerLayer;
@property(retain, nonatomic) AVPlayerItem *playerItem; // @synthesize playerItem=_playerItem;
@property(retain, nonatomic) AVPlayer *player; // @synthesize player=_player;
@property(nonatomic) _Bool isNetWorkWiFi; // @synthesize isNetWorkWiFi=_isNetWorkWiFi;
@property(nonatomic) _Bool isVIP; // @synthesize isVIP=_isVIP;
@property(nonatomic) _Bool isPortraitShow; // @synthesize isPortraitShow=_isPortraitShow;
@property(nonatomic) __weak id <WSAVPlayerViewDelegate> delegate; // @synthesize delegate=_delegate;
@property(readonly, nonatomic) double time; // @synthesize time=_time;
@property(retain, nonatomic) NSString *videoKey; // @synthesize videoKey=_videoKey;
@property(readonly, copy, nonatomic) NSString *currentUrlString; // @synthesize currentUrlString=_currentUrlString;
- (void).cxx_destruct;
- (void)layoutSubviews;
- (void)dealloc;
- (id)getPrivateKey:(id)arg1;
- (id)encryptionUrl:(id)arg1 andVideoKey:(id)arg2;
- (void)seekTime:(double)arg1;
- (id)convertTime:(double)arg1;
- (double)availableDuration;
- (void)observeValueForKeyPath:(id)arg1 ofObject:(id)arg2 change:(id)arg3 context:(void *)arg4;
- (void)playerDidFinishPlaying:(id)arg1;
- (void)prepareToPlay;
- (void)removeSystemNotifications;
- (void)addSystemNotifications;
- (void)removeTimeObserver;
- (void)addTimeObserver;
- (void)removePlayerItemStatusObserver;
- (void)addPlayerItemStatusObserver;
- (void)refreshProgessUI;
- (void)showVIPView:(_Bool)arg1;
- (void)hideVIPView;
- (void)hideToolView;
- (void)showToolView;
- (void)continuePlayVideo;
- (void)openVIPAction;
- (void)expandOrShrinkAction:(id)arg1;
- (void)playAction:(id)arg1;
- (void)lockAction:(id)arg1;
- (void)backAction:(id)arg1;
- (void)resumeRefreshing;
- (void)pauseRefreshing;
- (void)seek:(id)arg1;
- (void)addExternToolView;
- (void)playWithUrlString:(id)arg1;
- (void)clean;
- (void)pause;
- (void)play;
@property(readonly, nonatomic) _Bool isPlaying;
- (void)initializeAVPlayer;
- (id)initWithFrame:(struct CGRect)arg1;
- (id)initWithFrame:(struct CGRect)arg1 playUrl:(id)arg2;

@end

通過查看頭文件可以看到
[WSAVPlayerView encryptionUrl:andVideoKey:]
方法中的VideoKey會(huì)保存在view的屬性里面,我們來看看這個(gè)VideoKey是什么吁朦?

在終端查看進(jìn)程id

 ps -e

 5507 ??         0:14.64 /var/mobile/Containers/Bundle/Application/3912B0D8-705D-42E0-A087-D7A9711CB464/QQ.app/QQ
 5703 ??         0:05.17 /var/mobile/Containers/Bundle/Application/30C91D48-B9A6-4CA2-9669-A76073893084/WeChat.app/WeChat
 5830 ??         0:00.30 /usr/libexec/rtcreportingd
 5976 ??         0:00.64 /System/Library/Frameworks/SystemConfiguration.framework/SCHelper
 6030 ??         1:01.96 /var/mobile/Containers/Bundle/Application/1999C8D2-58C1-43C0-A717-A44B55CC1FEA/***.app/***

這時(shí)使用cycript附加上去

cycript -p 6030
cy#

我們先讓這個(gè)播放器初始化完成并傳入數(shù)據(jù)柒室,這時(shí)需要在手機(jī)上進(jìn)入到響應(yīng)頁面點(diǎn)擊播放按鈕

查看當(dāng)前的視圖層次

UIApp.keyWindow.recursiveDescription().toString()

<WSAVPlayerView: 0x12688de50; frame = (0 0; 320 201); hidden = YES; gestureRecognizers = <NSArray: 0x170846180>; layer = <AVPlayerLayer: 0x1748221a0>>

發(fā)現(xiàn) WSAVPlayerView的內(nèi)存地址為0x12688de50
這時(shí)為了方便下次的調(diào)用我們聲明一個(gè)變量

cy# var pv = #0x12688de50
#"<WSAVPlayerView: 0x12688de50; frame = (0 0; 320 201); hidden = YES; gestureRecognizers = <NSArray: 0x170846180>; layer = <AVPlayerLayer: 0x1748221a0>>"

查看屬性VideoKey

cy# pv.videoKey
@"NnVpU1VEc2drMTIzQVB4dDY="

通過對比發(fā)現(xiàn)NnVpU1VEc2drMTIzQVB4dDY=的值是在請求視頻資料中傳入的

我們把輸入帶入[WSAVPlayerView encryptionUrl:andVideoKey:]
這個(gè)方法需要傳入兩個(gè)參數(shù),第一個(gè)為url逗宜,第二個(gè)為key

cy# [pv encryptionUrl:@"http://www.baidu.com/class/18007651/454eae93a1963d7c31b1076b7c5a6e58_18007651_480.mp4" andVideoKey:@"NnVpU1VEc2drMTIzQVB4dDY="]
@"http://www.baidu.com/class/18007651/454eae93a1963d7c31b1076b7c5a6e58_18007651_480.mp4?auth_key=1503547268-0-0-077178daad75b10032af437b1d5d4cfb"

這里返回了正確的auth_key說明我們找的函數(shù)對了

那么我們來看看hopper這個(gè)函數(shù)大致做了一些什么

00000001000ee4b4         mov        x23, x0
00000001000ee4b8         adrp       x8, #0x101615000                            ; @selector(setStarImage:highlightedStarImage:)
00000001000ee4bc         ldr        x1, [x8, #0x948]                            ; "timeIntervalSince1970",@selector(timeIntervalSince1970)
00000001000ee4c0         bl         imp___stubs__objc_msgSend
00000001000ee4c4         mov        v8, v0
00000001000ee4c8         adrp       x28, #0x101643000                           ; @selector(wifiReachability)
00000001000ee4cc         ldr        x0, [x28, #0x9d0]                           ; objc_cls_ref_WOWSUtils,__objc_class_WOWSUtils_class
00000001000ee4d0         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee4d4         ldr        x1, [x8, #0x660]                            ; "base64Decode:",@selector(base64Decode:)
00000001000ee4d8         mov        x2, x20
00000001000ee4dc         bl         imp___stubs__objc_msgSend
00000001000ee4e0         mov        x29, x29
00000001000ee4e4         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee4e8         mov        x25, x0
00000001000ee4ec         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee4f0         ldr        x1, [x8, #0x668]                            ; "getPrivateKey:",@selector(getPrivateKey:)
00000001000ee4f4         mov        x0, x24
00000001000ee4f8         mov        x2, x25
00000001000ee4fc         bl         imp___stubs__objc_msgSend
00000001000ee500         mov        x29, x29
00000001000ee504         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee508         mov        x24, x0
00000001000ee50c         adrp       x21, #0x101643000                           ; @selector(wifiReachability)
00000001000ee510         ldr        x0, [x21, #0xab0]                           ; objc_cls_ref_NSString,_OBJC_CLASS_$_NSString
00000001000ee514         adrp       x8, #0x101612000
00000001000ee518         ldr        x26, [x8, #0xad0]                           ; "stringWithFormat:",@selector(stringWithFormat:)
00000001000ee51c         str        x24, [sp, #0x10]
00000001000ee520         str        d8, [sp, #0x8]
00000001000ee524         str        x22, sp
00000001000ee528         adrp       x2, #0x1012e7000
00000001000ee52c         add        x2, x2, #0x740                              ; @"%@-%.f-0-0-%@"
00000001000ee530         mov        x1, x26
00000001000ee534         bl         imp___stubs__objc_msgSend
00000001000ee538         mov        x29, x29
00000001000ee53c         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee540         mov        x27, x0
00000001000ee544         ldr        x0, [x28, #0x9d0]                           ; objc_cls_ref_WOWSUtils,__objc_class_WOWSUtils_class
00000001000ee548         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee54c         ldr        x1, [x8, #0x670]                            ; "getMD5String:",@selector(getMD5String:)
00000001000ee550         mov        x2, x27
00000001000ee554         bl         imp___stubs__objc_msgSend
00000001000ee558         mov        x29, x29
00000001000ee55c         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee560         mov        x28, x0
00000001000ee564         ldr        x0, [x21, #0xab0]                           ; objc_cls_ref_NSString,_OBJC_CLASS_$_NSString
00000001000ee568         str        x28, [sp, #0x10]
00000001000ee56c         str        d8, [sp, #0x8]
00000001000ee570         str        x19, sp
00000001000ee574         adrp       x2, #0x1012e7000
00000001000ee578         add        x2, x2, #0x760                              ; @"%@?auth_key=%.f-0-0-%@"
00000001000ee57c         mov        x1, x26
00000001000ee580         bl         imp___stubs__objc_msgSend
00000001000ee584         mov        x29, x29
00000001000ee588         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee58c         mov        x26, x0
00000001000ee590         mov        x0, x28
00000001000ee594         bl         imp___stubs__objc_release
00000001000ee598         mov        x0, x27
00000001000ee59c         bl         imp___stubs__objc_release
00000001000ee5a0         mov        x0, x24
00000001000ee5a4         bl         imp___stubs__objc_release
00000001000ee5a8         mov        x0, x25
00000001000ee5ac         bl         imp___stubs__objc_release
00000001000ee5b0         mov        x0, x23
00000001000ee5b4         bl         imp___stubs__objc_release
00000001000ee5b8         mov        x0, x22
00000001000ee5bc         bl         imp___stubs__objc_release
00000001000ee5c0         ldr        x0, [sp, #0x18]
00000001000ee5c4         bl         imp___stubs__objc_release
00000001000ee5c8         b          loc_1000ee5d8

                     loc_1000ee5cc:
00000001000ee5cc         mov        x0, x19                                     ; CODE XREF=-[WSAVPlayerView encryptionUrl:andVideoKey:]+68, -[WSAVPlayerView encryptionUrl:andVideoKey:]+72
00000001000ee5d0         bl         imp___stubs__objc_retain
00000001000ee5d4         mov        x26, x0

                     loc_1000ee5d8:
00000001000ee5d8         mov        x0, x20                                     ; CODE XREF=-[WSAVPlayerView encryptionUrl:andVideoKey:]+448
00000001000ee5dc         bl         imp___stubs__objc_release
00000001000ee5e0         mov        x0, x19
00000001000ee5e4         bl         imp___stubs__objc_release
00000001000ee5e8         mov        x0, x26
00000001000ee5ec         ldp        x29, x30, [sp, #0x80]
00000001000ee5f0         ldp        x20, x19, [sp, #0x70]
00000001000ee5f4         ldp        x22, x21, [sp, #0x60]
00000001000ee5f8         ldp        x24, x23, [sp, #0x50]
00000001000ee5fc         ldp        x26, x25, [sp, #0x40]
00000001000ee600         ldp        x28, x27, [sp, #0x30]
00000001000ee604         ldp        d9, d8, [sp, #0x20]
00000001000ee608         add        sp, sp, #0x90
00000001000ee60c         b          imp___stubs__objc_autoreleaseReturnValue
                        ; endp

用hopper查看得出大致流程

  • 解密base64的VideoKey
  • 格式化需要簽名的字符串
  • 生成效驗(yàn)字符串MD5
  • 格式化成最終URL雄右,也就是上面返回值

解密base64的VideoKey


那現(xiàn)在我們來看看怎么解密VideoKey的
服務(wù)器傳下來的
VideoKey是NnVpU1VEc2drMTIzQVB4dDY=
base64解碼以后的字符為
6uiSUDsgk123APxt6

00000001000ee4cc         ldr        x0, [x28, #0x9d0]                           ; objc_cls_ref_WOWSUtils,__objc_class_WOWSUtils_class
00000001000ee4d0         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee4d4         ldr        x1, [x8, #0x660]                            ; "base64Decode:",@selector(base64Decode:)
00000001000ee4d8         mov        x2, x20
00000001000ee4dc         bl         imp___stubs__objc_msgSend
00000001000ee4e0         mov        x29, x29
00000001000ee4e4         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee4e8         mov        x25, x0
00000001000ee4ec         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee4f0         ldr        x1, [x8, #0x668]                            ; "getPrivateKey:",@selector(getPrivateKey:)

在反匯編中可以看到解碼以后調(diào)用了getPrivateKey方法
那么我們這里在cycript中帶入看看

cy# [pv getPrivateKey:@"6uiSUDsgk123APxt6"]
@"sgk123"

發(fā)現(xiàn)這個(gè)結(jié)果是正確的

這是在hopper中查看[WSAVPlayerView getPrivateKey:]方法

00000001000ee610         stp        x24, x23, [sp, #-0x40]!                     ; Objective C Implementation defined at 0x10138c348 (instance method), DATA XREF=0x10138c348
00000001000ee614         stp        x22, x21, [sp, #0x10]
00000001000ee618         stp        x20, x19, [sp, #0x20]
00000001000ee61c         stp        x29, x30, [sp, #0x30]
00000001000ee620         add        x29, sp, #0x30
00000001000ee624         mov        x20, x2
00000001000ee628         adrp       x8, #0x101615000                            ; @selector(setStarImage:highlightedStarImage:)
00000001000ee62c         ldr        x21, [x8, #0x1c8]                           ; "substringToIndex:",@selector(substringToIndex:)
00000001000ee630         mov        x0, x20
00000001000ee634         bl         imp___stubs__objc_retain
00000001000ee638         mov        x19, x0
00000001000ee63c         orr        w2, wzr, #0x1
00000001000ee640         mov        x0, x20
00000001000ee644         mov        x1, x21
00000001000ee648         bl         imp___stubs__objc_msgSend
00000001000ee64c         mov        x29, x29
00000001000ee650         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee654         mov        x21, x0
00000001000ee658         adrp       x8, #0x101612000
00000001000ee65c         ldr        x22, [x8, #0x8c8]                           ; "integerValue",@selector(integerValue)
00000001000ee660         mov        x1, x22
00000001000ee664         bl         imp___stubs__objc_msgSend
00000001000ee668         mov        x23, x0
00000001000ee66c         mov        x0, x21
00000001000ee670         bl         imp___stubs__objc_release
00000001000ee674         adrp       x8, #0x101612000
00000001000ee678         ldr        x1, [x8, #0xa98]                            ; "length",@selector(length)
00000001000ee67c         mov        x0, x20
00000001000ee680         bl         imp___stubs__objc_msgSend
00000001000ee684         sub        x2, x0, #0x1
00000001000ee688         adrp       x8, #0x101614000                            ; @selector(setReturnKeyType:)
00000001000ee68c         ldr        x1, [x8, #0x460]                            ; "substringFromIndex:",@selector(substringFromIndex:)
00000001000ee690         mov        x0, x20
00000001000ee694         bl         imp___stubs__objc_msgSend
00000001000ee698         mov        x29, x29
00000001000ee69c         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee6a0         mov        x21, x0
00000001000ee6a4         mov        x1, x22
00000001000ee6a8         bl         imp___stubs__objc_msgSend
00000001000ee6ac         mov        x22, x0
00000001000ee6b0         mov        x0, x21
00000001000ee6b4         bl         imp___stubs__objc_release
00000001000ee6b8         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee6bc         ldr        x1, [x8, #0x678]                            ; "substringWithRange:",@selector(substringWithRange:)
00000001000ee6c0         mov        x0, x20
00000001000ee6c4         mov        x2, x23
00000001000ee6c8         mov        x3, x22
00000001000ee6cc         bl         imp___stubs__objc_msgSend
00000001000ee6d0         mov        x20, x0
00000001000ee6d4         mov        x0, x19
00000001000ee6d8         bl         imp___stubs__objc_release
00000001000ee6dc         mov        x0, x20
00000001000ee6e0         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee6e4         ldp        x29, x30, [sp, #0x30]
00000001000ee6e8         ldp        x20, x19, [sp, #0x20]
00000001000ee6ec         ldp        x22, x21, [sp, #0x10]
00000001000ee6f0         ldp        x24, x23, [sp]!, #0x40
00000001000ee6f4         b          imp___stubs__objc_autoreleaseReturnValue
                        ; endp

字符串6uiSUDsgk123APxt6得出sgk123的過程為
第一個(gè)字符和最后一個(gè)字符為字符串需要截取的開始和結(jié)尾
比如

6uiSUDsgk123APxt6 => 6uiSUD sgk123 APxt6
9TFQUz4wN sgk123 7ltDvfB6 => 9TFQUz4wN sgk123 7ltDvfB6

格式化需要簽名的字符串

00000001000ee508         mov        x24, x0
00000001000ee50c         adrp       x21, #0x101643000                           ; @selector(wifiReachability)
00000001000ee510         ldr        x0, [x21, #0xab0]                           ; objc_cls_ref_NSString,_OBJC_CLASS_$_NSString
00000001000ee514         adrp       x8, #0x101612000
00000001000ee518         ldr        x26, [x8, #0xad0]                           ; "stringWithFormat:",@selector(stringWithFormat:)
00000001000ee51c         str        x24, [sp, #0x10]
00000001000ee520         str        d8, [sp, #0x8]
00000001000ee524         str        x22, sp
00000001000ee528         adrp       x2, #0x1012e7000
00000001000ee52c         add        x2, x2, #0x740                              ; @"%@-%.f-0-0-%@"
00000001000ee530         mov        x1, x26
00000001000ee534         bl         imp___stubs__objc_msgSend
00000001000ee538         mov        x29, x29
00000001000ee53c         bl         imp___stubs__objc_retainAutoreleasedReturnValue
00000001000ee540         mov        x27, x0
00000001000ee544         ldr        x0, [x28, #0x9d0]                           ; objc_cls_ref_WOWSUtils,__objc_class_WOWSUtils_class
00000001000ee548         adrp       x8, #0x101617000                            ; @selector(defaultManager)
00000001000ee54c         ldr        x1, [x8, #0x670]                            ; "getMD5String:",@selector(getMD5String:)

[WSAVPlayerView encryptionUrl:andVideoKey:]方法反匯編中可以看到

format的格式為%@-%.f-0-0-%@,這里有三個(gè)參數(shù),怎么取獲取這三個(gè)參數(shù)的值纺讲?

格式化完成以后傳入getMD5String:方法
直接在getMD5String中查看傳入的值就好了逢渔,這里使用lldb 的debugserver查看

debugserver默認(rèn)沒有task_for_pid權(quán)限
我們先把越獄手機(jī)/Developer/usr/bin/debugserver復(fù)制到mac

先創(chuàng)建一個(gè)ent.xml
然后保存一下內(nèi)容

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
<plist version="1.0">  
<dict>  
        <key>com.apple.springboard.debugapplications</key>  
        <true/>  
        <key>get-task-allow</key>  
        <true/>  
        <key>task_for_pid-allow</key>  
        <true/>  
        <key>run-unsigned-code</key>  
        <true/>  
</dict>  
</plist>  

執(zhí)行簽名

ldid -Sent.xml debugserver

然后復(fù)制到越獄設(shè)備的/usr/bin/
開啟調(diào)試***為進(jìn)程名稱

Testerde-iPhone:~/ root# debugserver *:1234 -a "***"
debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
 for arm64.
Attaching to process ***...
Listening to port 1234 for a connection from *..

這時(shí)調(diào)試服務(wù)器已經(jīng)監(jiān)聽開啟了1234端口等候處理
這里我們再使用iProxy映射一個(gè)端口

iproxy 1234 1234

新開一個(gè)終端
啟動(dòng)lldb建立和debugserver的連接

?  ~ lldb
(lldb) process connect connect://127.0.0.1:1234
Process 6254 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00000001965d4e7c libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x1965d4e7c <+8>: ret

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x1965d4e80 <+0>: mov    x16, #-0x20
    0x1965d4e84 <+4>: svc    #0x80
    0x1965d4e88 <+8>: ret
(lldb)

查看基址

(lldb) image list -o -f
[  0] 0x0000000000084000 /private/var/mobile/Containers/Bundle/Application/1999C8D2-58C1-43C0-A717-A44B55CC1FEA/***.app/***(0x0000000100084000)
[  1] 0x0000000000094000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/usr/lib/dyld
[  2] 0x000000010182c000 /Library/MobileSubstrate/MobileSubstrate.dylib(0x000000010182c000)
[  3] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/usr/lib/libc++.1.dylib
[  4] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
[  5] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/Foundation.framework/Foundation
[  6] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/ImageIO.framework/ImageIO
[  7] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
[  8] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/QuartzCore.framework/QuartzCore
[  9] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/Security.framework/Security
[ 10] 0x0000000003aac000 /Users/charley/Library/Developer/Xcode/iOS DeviceSupport/8.1.3 (12B466)/Symbols/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration

這里可以看到基址為0x0000000000084000

[  0] 0x0000000000084000 /private/var/mobile/Containers/Bundle/Application/1999C8D2-58C1-43C0-A717-A44B55CC1FEA/***.app/***(0x0000000100084000)

lldb命令c讓程序繼續(xù)運(yùn)行

(lldb) c
Process 6254 resuming
(lldb)

我們在getMD5String這個(gè)方法的第一行下斷點(diǎn),也就是
下面的第一行

0000000100493b48         sub        sp, sp, #0x60                               ; Objective C Implementation defined at 0x10143f320 (class method), DATA XREF=0x10143f320
0000000100493b4c         stp        x24, x23, [sp, #0x20]
0000000100493b50         stp        x22, x21, [sp, #0x30]
0000000100493b54         stp        x20, x19, [sp, #0x40]
0000000100493b58         stp        x29, x30, [sp, #0x50]
0000000100493b5c         add        x29, sp, #0x50
0000000100493b60         mov        x19, x2

那么程序在手機(jī)內(nèi)存中的地址怎么計(jì)算?
其實(shí)就是上面查看到的基址0x0000000000084000 +第一行的偏移量0000000100493b48 = 0x100517B48
那么我就在0x100517B48下斷點(diǎn)

(lldb) br s -a 0x100517B48
Breakpoint 6: where = *** `_mh_execute_header + 4772212, address = 0x0000000100517b48

手機(jī)點(diǎn)擊界面進(jìn)行播放脊髓,lldb會(huì)斷下來執(zhí)行po $x2查看傳入的參數(shù)

Process 6254 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 6.1
    frame #0: 0x0000000100517b48 ***`_mh_execute_header + 4799304
***`_mh_execute_header:
->  0x100517b48 <+4799304>: sub    sp, sp, #0x60             ; =0x60
    0x100517b4c <+4799308>: stp    x24, x23, [sp, #0x20]
    0x100517b50 <+4799312>: stp    x22, x21, [sp, #0x30]
    0x100517b54 <+4799316>: stp    x20, x19, [sp, #0x40]
(lldb)po $x2
/class/17426404/2dbe0a6c9077e5aa969196faf047be2b_17426404_480.mp4-1503551940-0-0-sgk123
(lldb)

是不是很清楚了
%@-%.f-0-0-%@格式化的三個(gè)參數(shù)

  • url路徑
  • 時(shí)間戳
  • PrivateKey

后面的就比較容易了


生成效驗(yàn)字符串MD5


使用格式化的字符做MD5結(jié)果
f62b7278787782d900497c498d7271b2

格式化成最終URL

格式

@"%@?auth_key=%.f-0-0-%@"

參數(shù)如下

  • url地址
  • 時(shí)間戳
  • md5簽名

格式化的結(jié)果

http://www.baidu.com/class/18007651/454eae93a1963d7c31b1076b7c5a6e58_18007651_480.mp4?auth_key=1503552405-0-0-f62b7278787782d900497c498d7271b2

參考文章


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市膀值,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌翘狱,老刑警劉巖赚导,帶你破解...
    沈念sama閱讀 216,470評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異寡夹,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)智绸,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,393評論 3 392
  • 文/潘曉璐 我一進(jìn)店門迹恐,熙熙樓的掌柜王于貴愁眉苦臉地迎上來殴边,“玉大人,你說我怎么就攤上這事拳氢。” “怎么了透乾?”我有些...
    開封第一講書人閱讀 162,577評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長再来。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么篡帕? 我笑而不...
    開封第一講書人閱讀 58,176評論 1 292
  • 正文 為了忘掉前任怔鳖,我火速辦了婚禮败砂,結(jié)果婚禮上坚芜,老公的妹妹穿的比我還像新娘铸敏。我一直安慰自己闪水,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,189評論 6 388
  • 文/花漫 我一把揭開白布每强。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪邢羔。 梳的紋絲不亂的頭發(fā)上流椒,一...
    開封第一講書人閱讀 51,155評論 1 299
  • 那天温数,我揣著相機(jī)與錄音握玛,去河邊找鬼。 笑死安聘,一個(gè)胖子當(dāng)著我的面吹牛囱桨,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,041評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼酣难,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起媳危,我...
    開封第一講書人閱讀 38,903評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎冈敛,沒想到半個(gè)月后待笑,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,319評論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡莺债,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,539評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了我纪。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,703評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡屯阀,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出想罕,到底是詐尸還是另有隱情,我是刑警寧澤描睦,帶...
    沈念sama閱讀 35,417評論 5 343
  • 正文 年R本政府宣布遥巴,位于F島的核電站,受9級特大地震影響何之,放射性物質(zhì)發(fā)生泄漏占拍。R本人自食惡果不足惜敲茄,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,013評論 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望方椎。 院中可真熱鬧,春花似錦奔缠、人聲如沸劣坊。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,664評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽嘶伟。三九已至,卻和暖如春又碌,著一層夾襖步出監(jiān)牢的瞬間九昧,已是汗流浹背绊袋。 一陣腳步聲響...
    開封第一講書人閱讀 32,818評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留铸鹰,地道東北人癌别。 一個(gè)月前我還...
    沈念sama閱讀 47,711評論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像蹋笼,于是被迫代替她去往敵國和親展姐。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,601評論 2 353

推薦閱讀更多精彩內(nèi)容

  • 轉(zhuǎn)發(fā)自 2016-07-07何兆林騰訊Bugly 如果您有耐心看完這篇文章剖毯,您將懂得如何著手進(jìn)行app的分析诞仓、追蹤...
    樹懶啊樹懶閱讀 10,645評論 5 63
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn)速兔,斷路器墅拭,智...
    卡卡羅2017閱讀 134,651評論 18 139
  • 點(diǎn)擊查看原文 Web SDK 開發(fā)手冊 SDK 概述 網(wǎng)易云信 SDK 為 Web 應(yīng)用提供一個(gè)完善的 IM 系統(tǒng)...
    layjoy閱讀 13,758評論 0 15
  • iOS安全攻與防 本地?cái)?shù)據(jù)攻與防 https UIWebview 第三方sdk與xcode 反編譯與代碼混淆 越獄...
    天機(jī)否閱讀 10,626評論 8 66
  • 第四天,多云涣狗。 今天就是考研準(zhǔn)備的最后一天谍婉,明天就要考試了,一個(gè)感悟就是我沒有準(zhǔn)備好镀钓,都不敢上考場了穗熬。但是后來一想...
    艾小tu閱讀 167評論 0 0