汇编修改if else逻辑

256 阅读6分钟

#####1.修改函数的返回值 1.找到关键方法


                     -[ViewController isVip]:
0000000100008440         sub        sp, sp, #0x10                               ; Objective C Implementation defined at 0x10000c408 (instance)
0000000100008444         movz       w8, #0x0
0000000100008448         str        x0, [sp, #0x8]
000000010000844c         str        x1, [sp]
0000000100008450         and        w0, w8, #0x1
0000000100008454         add        sp, sp, #0x10
0000000100008458         ret      

2.修改返回值

                     -[ViewController isVip]:
0000000100008440         movz       x0, #0x1
0000000100008444         ret        
0000000100008448         str        x0, [sp, #0x8]
000000010000844c         str        x1, [sp]
0000000100008450         and        w0, w8, #0x1
0000000100008454         add        sp, sp, #0x10
0000000100008458         ret 

#####2.修改判断跳转 1.定位目标函数

 -[ViewController vipAction]:
0000000100008364         stp        x29, x30, [sp, #0xfffffff0]!                ; Objective C Implementation defined at 0x10000c3f0 (instance)
0000000100008368         mov        x29, sp
000000010000836c         sub        sp, sp, #0x20
0000000100008370         adrp       x8, #0x10000d000                            ; 0x10000d000 (__ZL27OBJC_CLASS_RO_$___ARCLite__ + 0x28)
0000000100008374         add        x8, x8, #0xe0                               ; @selector(isVip)
0000000100008378         stur       x0, [x29, #0xfffffff8]
000000010000837c         str        x1, [sp, #0x10]
0000000100008380         ldur       x0, [x29, #0xfffffff8]
0000000100008384         ldr        x1, [x8]                                    ; @selector(isVip)
0000000100008388         bl         imp___stubs__objc_msgSend
000000010000838c         and        w0, w0, #0x1
0000000100008390         cmp        w0, #0x0
0000000100008394         b.eq       0x100008430

2.查看分支

屏幕快照 2016-08-26 上午10.42.40.png
3.找到比较和跳转命令

 arm平台是比较是cmp , 此处的跳转是beq

4.修改跳转指令

跳转到你想跳转的地址
 b.eq 0x100008430   ->BAL 0x100008398

5.arm 平台跳转命令

 控制流指令
    转移指令(branch)
        说明:无条件转移B,BAL
        举例:    B LABEL        ; LABEL为某个位置
    条件转移
        说明:    BEQ    相等
            BNE    不等
            BPL    非负
            BMI    负
            BCC    无进位
            BCS    有进位
            BLO    小于(无符号数)
            BHS    大于等于(无符号数)
            BHI    大于(无符号数)
            BLS    小于等于(无符号数)
            BVC    无溢出(有符号数)
            BVS    有溢出(有符号数)
            BGT    大于(有符号数)
            BGE    大于等于(有符号数)
            BLT    小于(有符号数)
            BLE    小于等于(有符号数)