IOS 使用LLDB 调试越狱手机

流程

  1. 通过mac 电脑生成带有访问权限的debugserver 可执行文件;
  2. 登录手机设置 debugserver 绑定某一个某一个端口 用于某一个进程;
  3. 在mac端中使用 lldb 远程连接手机;

可能会遇到的问题

  1. Failed to get connection from a remote gdb process
    解答:使用我的debugserver.entitlements 文件覆盖你的
  2. failed to attach to process named: “”
    解答:这个就是进程名不对,如果不知道进程名 可以额通过 ps -A 查询到你想要调试的应用进程名
  3. error: failed to get reply to handshake packet
    解答方案:
 debugserver *:10011  -a pinduoduo

变为:

 debugserver localhost:10011  -a pinduoduo

实现

1.通过mac 电脑生成带有访问权限的debugserver 可执行文件;

  1. 通过ifunbox 访问越狱手机拿到/Developer/usr/bin/debugserver

  2. 把手机端的debugserver 文件copy 到mac 电脑中

  3. 通过ldid 给 debugserver 添加权限

#  3.1 这个是倒出可执行文件 debugserver 的权限 覆盖到 debugserver.entitlements 文件中
ldid -e debugserver  > debugserver.entitlements

#  3.2 打开debugserver.entitlements文件并添加如下两个权限
key:get-task-allow    type:Boolean  Value:1
key:task_for_pid-allow    type:Boolean  Value:1

#  把权限debugserver.entitlements 签给可执行文件 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. 把添加过权限的debugserver文件copy 到手机中的 usr/bin/目录下面

  2. 给debugserver 添加可执行权限

chmod +x debugserver

2. 登录手机设置 debugserver 绑定某一个某一个端口 用于某一个进程;

# 让debugserver附加到某一个app进程
debugserver *:端口号 -a 进程名
例如: debugserver *:10011  -a pinduoduo

成功截图:


1.附加到否一个app进程.jpeg

3. 在mac端中使用 lldb 远程连接手机;

# 1. 启动LLDB
终端中输入:lldb
# 2.链接debugserver服务
终端中输入:(lldb) process connect connect://手机IP地址:debugserver服务端口号
例如: process connect connect://localhost:10011
# 3.使用LLDB的命令让程序继续运行起来
终端中输入:(lldb) c
例如: c

成功截图:


2.通过lldb连接到debugserver.jpeg

参考文献

  1. iOS12 下配置debugserver + lldb调试环境的小技巧和问题处理
  2. 常见问题
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容