tft每日頭條

 > 生活

 > ida智能譯碼終端作用

ida智能譯碼終端作用

生活 更新时间:2025-02-03 16:15:08

前 提

有root權限

打開手機的USB調式模式

bootloader模式下用fastboot刷機經常不成功

C:\tmp\fastboot>adb reboot bootloader C:\tmp\fastboot>fastboot flash boot C:\tmp\gionee-f103_SV16\boot.img Sending 'boot' (7004 KB) OKAY [ 0.689s] Writing 'boot' FAILED (remote: 'download for partition 'boot' is not allowed ') fastboot: error: Command failed

此時可用flash_image命令刷入試試(成功率低)。

将flash_image和将要刷入的boot.img傳到手機sdcard目錄下:

c:\tmp\fastboot>adb push c:/tmp/fastboot/flash_image11 /sdcard/flash_image c:/tmp/fastboot/flash_image11: 1 file pushed. 0.2 MB/s (26172 bytes in 0.133s) C:\tmp\fastboot>adb push C:\tmp\gionee-f103_SV16\boot.img /sdcard C:\tmp\gionee-f103_SV16\boot.img: 1 fil...hed. 5.6 MB/s (7172096 bytes in 1.220s)

移動flash_image到/system/bin,改變屬性和用戶組:

1|root@GiONEE_GBL7319:/ # mount -rw -o remount /system root@GiONEE_GBL7319:/sdcard # mv flash_image /system/bin/ root@GiONEE_GBL7319:/sdcard # chmod 755 /system/bin/flash_image root@GiONEE_GBL7319:/sdcard # chown root.shell /system/bin/flash_image root@GiONEE_GBL7319:/sdcard # ls -l /system/bin/fla* -rwxr-xr-x root shell 26172 2022-02-23 15:00 flash_image -rwxr-xr-x root shell 13968 2022-02-22 22:43 flash_image22

手機正常開機狀态下刷機:

255|root@GiONEE_GBL7319:/sdcard # flash_image boot boot.img 刷recovery用: 255|root@GiONEE_GBL7319:/sdcard # flash_image recovery recovery.img


flash_image刷機時會遇到問題

only position independent executables (PIE) are supported

root@GiONEE_GBL7319:/sdcard # flash_image boot boot.img error: only position independent executables (PIE) are supported.

解決方法

将/system/bin/linker從手機裡下載到電腦:

C:\tmp\fastboot>adb pull /system/bin/linker c:/tmp/ /system/bin/linker: 1 file pulled. 5.2 MB/s (86664 bytes in 0.016s)

下載、安裝、打開IDA反彙編軟件,打開linker - 右鍵 - 選擇“Text View” :

ida智能譯碼終端作用(flashimage刷機及PIE)1

點擊 “Text search” - 輸入問題描述:

ida智能譯碼終端作用(flashimage刷機及PIE)2

鼠标放在方框位置時會提示調用處的相關彙編命令:

ida智能譯碼終端作用(flashimage刷機及PIE)3

相關内容上雙擊或右鍵 - 選擇“Jump to Operand” 會跳到調用處:

ida智能譯碼終端作用(flashimage刷機及PIE)4

觸發錯誤信息的相關命令:

ida智能譯碼終端作用(flashimage刷機及PIE)5

先了解幾個彙編命令

  • CMP: 比較是否相等,相等時置Z标志為0
  • B: 無條件跳轉到它後面的标簽
  • BL: 無條件跳轉到它後面的标簽,跳轉前将PC存入R14
  • BNE: Z标志位不等于0時,跳轉到它後面的标簽處
  • BEQ: Z标志位等于0時,跳轉到它後面的标簽處
  • BNE.W: W:word,指操作數大小2個字節,B:byte,一個字節,L:long,4個字節
  • NOP: 空指令(機器碼0X00BF)
  • CBNZ Rn, label : Rn非零時跳轉
  • CBZ Rn, label : Rn為零時跳轉

.text:00002F4C CMP R2, #3 .text:00002F4E BEQ loc_2F60 .text:00002F50 LDR R1, =(aErrorOnlyPosit - 0x2F58) ; "error: only position independent execut"... .text:00002F52 MOVS R0, #2 .text:00002F54 ADD R1, PC ; "error: only position independent execut"... .text:00002F56 BL __dl___libc_format_fd .text:00002F5A MOV R0, R5 .text:00002F5C .text:00002F5C loc_2F5C ; CODE XREF: __dl___linker_init 230↑j .text:00002F5C BL __dl_exit .text:00002F60 .text:00002F60 loc_2F60 ; CODE XREF: __dl___linker_init 38E↑j .text:00002F60 LDR R1, =(asc_96C7 - 0x2F6C) ; ":" .text:00002F62 MOV R0, R10 .text:00002F64 LDR R2, =(__dl__ZL18g_ld_library_paths - 0x2F6E)

上面第1行:命令 CMP R2, #3

  • 地址是:0X00002F4C
  • 意思:比較寄存器R2與數字3的大小

上面第2行:命令 BEQ loc_2F60

  • 地址:00002F4E
  • loc_2F60是下面第12行的标簽,地址為0X00002F60
  • 意思:第1行比較結果相等則跳轉到标簽loc_2F60處繼續執行。否則顯示錯誤并中斷程序。

我們的目的是無條件跳轉到loc_2F60處繼續執行,用“B”彙編指令替換“BEQ”。

鼠标點到BEQ上,然後切換到“Hex View - 1" :

ida智能譯碼終端作用(flashimage刷機及PIE)6

将07D0修改為07E0: “E”是跳轉指令“B”的機器碼編碼格式的第28-31位

右擊 - 選擇“Edit...”:

ida智能譯碼終端作用(flashimage刷機及PIE)7

右擊 - 選擇“Apply chages”:

ida智能譯碼終端作用(flashimage刷機及PIE)8

Edit - Patch program - Apply Patches to input file... :

ida智能譯碼終端作用(flashimage刷機及PIE)9

修改保存後再上傳linker到手機的/system/bin/目錄下,修改一下屬性.

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved