IOS 使用LLDB 調(diào)試越獄手機(jī)

流程

  1. 通過(guò)mac 電腦生成帶有訪問(wèn)權(quán)限的debugserver 可執(zhí)行文件;
  2. 登錄手機(jī)設(shè)置 debugserver 綁定某一個(gè)某一個(gè)端口 用于某一個(gè)進(jìn)程;
  3. 在mac端中使用 lldb 遠(yuǎn)程連接手機(jī);

可能會(huì)遇到的問(wèn)題

  1. Failed to get connection from a remote gdb process
    解答:使用我的debugserver.entitlements 文件覆蓋你的
  2. failed to attach to process named: “”
    解答:這個(gè)就是進(jìn)程名不對(duì),如果不知道進(jìn)程名 可以額通過(guò) ps -A 查詢到你想要調(diào)試的應(yīng)用進(jìn)程名
  3. error: failed to get reply to handshake packet
    解答方案:
 debugserver *:10011  -a pinduoduo

變?yōu)?

 debugserver localhost:10011  -a pinduoduo

實(shí)現(xiàn)

1.通過(guò)mac 電腦生成帶有訪問(wèn)權(quán)限的debugserver 可執(zhí)行文件;

  1. 通過(guò)ifunbox 訪問(wèn)越獄手機(jī)拿到/Developer/usr/bin/debugserver

  2. 把手機(jī)端的debugserver 文件copy 到mac 電腦中

  3. 通過(guò)ldid 給 debugserver 添加權(quán)限

#  3.1 這個(gè)是倒出可執(zhí)行文件 debugserver 的權(quán)限 覆蓋到 debugserver.entitlements 文件中
ldid -e debugserver  > debugserver.entitlements

#  3.2 打開debugserver.entitlements文件并添加如下兩個(gè)權(quán)限
key:get-task-allow    type:Boolean  Value:1
key:task_for_pid-allow    type:Boolean  Value:1

#  把權(quán)限debugserver.entitlements 簽給可執(zhí)行文件 debugserver
ldid -Sdebugserver.entitlements  debugserver

debugserver.entitlements 源代碼為:

<?xml version="1.0" encoding="UTF-8"?>
<!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.backboardd.debugapplications</key>
    <true/>
    <key>com.apple.backboardd.launchapplications</key>
    <true/>
    <key>com.apple.frontboard.debugapplications</key>
    <true/>
    <key>com.apple.frontboard.launchapplications</key>
    <true/>
    <key>com.apple.springboard.debugapplications</key>
    <true/>
    <key>com.apple.system-task-ports</key>
    <true/>
    <key>get-task-allow</key>
    <true/>
    <key>platform-application</key>
    <true/>
    <key>run-unsigned-code</key>
    <true/>
    <key>task_for_pid-allow</key>
    <true/>
</dict>
</plist>
  1. 把添加過(guò)權(quán)限的debugserver文件copy 到手機(jī)中的 usr/bin/目錄下面

  2. 給debugserver 添加可執(zhí)行權(quán)限

chmod +x debugserver

2. 登錄手機(jī)設(shè)置 debugserver 綁定某一個(gè)某一個(gè)端口 用于某一個(gè)進(jìn)程;

# 讓debugserver附加到某一個(gè)app進(jìn)程
debugserver *:端口號(hào) -a 進(jìn)程名
例如: debugserver *:10011  -a pinduoduo

成功截圖:


1.附加到否一個(gè)app進(jìn)程.jpeg

3. 在mac端中使用 lldb 遠(yuǎn)程連接手機(jī);

# 1. 啟動(dòng)LLDB
終端中輸入:lldb
# 2.鏈接debugserver服務(wù)
終端中輸入:(lldb) process connect connect://手機(jī)IP地址:debugserver服務(wù)端口號(hào)
例如: process connect connect://localhost:10011
# 3.使用LLDB的命令讓程序繼續(xù)運(yùn)行起來(lái)
終端中輸入:(lldb) c
例如: c

成功截圖:


2.通過(guò)lldb連接到debugserver.jpeg

參考文獻(xiàn)

  1. iOS12 下配置debugserver + lldb調(diào)試環(huán)境的小技巧和問(wèn)題處理
  2. 常見問(wèn)題
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容