ios 让debugserver可以调试任意app

文章目录

  • 修改debugserver签名

修改debugserver签名

先从越狱手机上用ifunbox复制 Device\Developer\usr\bin目录下的debugserver 到mac上,然后终端进入mac下的文件目录
使用ldid修改签名
修改签名可以参考这篇文章
ios使用ldid给mach-o文件签名SpringBoard的权限突破沙盒
先把签名导出来

ldid -e debugserver > debugserver.entitlements

双击打开生成的文件 debugserver.entitlements
发现报错,31行语法错,xml声明只允许在开头,因为这个deubgserver包含arm64和arm64e 2个版本
ios 让debugserver可以调试任意app_第1张图片
用sublimeText或者文本编辑打开.签名文件
添加几行

<key>platform-applicationkey>
<true/>
<key>get-task-allowkey>
<true/>
<key>task_for_pid-allowkey>
<true/>
<key>run-unsigned-codekey>
<true/>

删除下面几行

<key>seatbelt-profileskey>
<array>
	<string>debugserverstring>
array>
<key>com.apple.security.network.serverkey>
<true/>
<key>com.apple.security.network.clientkey>
<true/>

注意,所有权限,上下都是重复2次的.所以直接用xcode打开会报错

重新把权限文件签名到debugserver上

ldid -Sdebugserver.entitlements debugserver

删掉debugserver.entitlements 文件,然后重新导出签名文件查看权限是否被修改.

ldid -e debugserver > debugserver.entitlements

双击debugserver.entitlements,报错,从35行以后语法错误,跟之前一样,用文本编辑打开,删掉从35行开始以后的内容,因为权限被重复写入2次.
然后双击打开,发现权限已经是正确的了.
把debugserver复制到越狱手机的usr/bin目录下
修改可执行权限

chmod +x /usr/bin/debugserver

然后用usb方式ssh,参见下面文章
越狱iPhone手机使用openSSH wifi和usb连接mac电脑再免密码登录再用shell脚本执行教程

把usb.sh文件结尾添加一个映射 20001:20001是把手机的20001端口映射到mac的20001如下:

python /Volumes/SN7501T/JailBreak/usb连接/tcprelay.py -t 22:20000 20001:20001

然后登陆

sh usb.sh
sh login.sh

登陆以后在手机上打开要调试的app,比如微信
在root账户上输入:

debugserver localhost:20001 -a 进程名字
debugserver localhost:20001 -a WeChat

注意不要使用*:20001否则后续的lldb报错:error: failed to get reply to handshake packet
后续遇到这个报错就把*改成 localhost
然后再mac端输入

lldb
process connect connect://localhost:20001

成功以后出现鞋面信息代表已经可以调试了

Process 5066 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x000000018712c198 libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x18712c198 <+8>: ret

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x18712c19c <+0>: mov    x16, #-0x20
    0x18712c1a0 <+4>: svc    #0x80
    0x18712c1a4 <+8>: ret
Target 0: (WeChat) stopped.
(lldb)

你可能感兴趣的:(ios,逆向,mac,ios,debugserver,调试,逆向,lldb)