Debugserver+lldb调试失败,error: Failed to connect port

需求:lldb调试的时候,失败了,提示error: Failed to connect port,请问这个跟debugserver签名有关么?
**日志:

iPhone:/usr/bin root# debugserver *:1234 -a Wechat

debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124

 for arm64.

Attaching to process Wechat...

Listening to port 1234 for a connection from *...

(lldb) process connect connect://localhost:1234

error: Failed to connect port

签名

<?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.diagnosticd.diagnostic</key>

<true/>

<key>com.apple.frontboard.debugapplications</key>

<true/>

<key>com.apple.frontboard.launchapplications</key>

<true/>

<key>com.apple.security.network.client</key>

<true/>

<key>com.apple.security.network.server</key>

<true/>

<key>com.apple.springboard.debugapplications</key>

<true/>

<key>run-unsigned-code</key>

<true/>

<key>seatbelt-profiles</key>

<array>

<string>debugserver</string>

</array>

<key>get-task-allow</key>

<true/>

<key>task_for_pid-allow</key>

<true/>

<key>run-unsigned-code</key>

<true/>

<key>platform-application</key>

<true/>

</dict>

</plist>

** 环境:iOS9.3.2

debugserver 127.0.0.1:1234 -a Wechat

还是报同样的错误

@snakeninny 狗神好,我试了几个方法都不行,卡在这了,能否指点一下,感激不尽。

我也遇到了,不知道怎么解决

我在找办法解决,成功了,告诉你

还是没找到原因,但是使用同一网络,可以动态调试了

在微信以外的其他App上可以成功吗?

使用usb链接都不行,用同一网络可以。

我这怎么都不可以,不知道什么原因

你把你签名过程和报的错,都发出来,一起看看

签名步骤:

  • 从手机拖出 debugserver,然后添加一个entitlements.plist,其中内容如下:
    <?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.springboard.debugapplications</key>
      <true/>
      <key>run-unsigned-code</key>
      <true/>
      <key>get-task-allow</key>
      <true/>
      <key>task_for_pid-allow</key>
      <true/>
    </dict> 
    </plist>
    
  • 通过 codesign -s - --entitlements entitlements.plist -f debugserver 签名,拖回手机

使用

chengzidexiaodupi:~ root# debugserver *:12345 -a WeChat
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
Attaching to process WeChat...
Segmentation fault: 11
chengzidexiaodupi:~ root# 

出现这个问题
然后进行了下面的操作

chengzidexiaodupi:~ root# debugserver -x backboard *:12345 /var/containers/Bundle/Application/8B2AB31F-91AB-4D44-A621-9EF66B1D2602/WeChat.app/WeChat
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
Segmentation fault: 11
chengzidexiaodupi:~ root# 

换成posix之后的显示

chengzidexiaodupi:~ root# debugserver -x posix *:12345 /var/containers/Bundle/Application/8B2AB31F-91AB-4D44-A621-9EF66B1D2602/WeChat.app/WeChat
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
error: failed to launch process /usr/bin/debugserver: failed to get the task for process 26466
Exiting.
chengzidexiaodupi:~ root# 

换成 auto 之后的显示如下,但是进程是启动的:

chengzidexiaodupi:~ root# debugserver -x auto /var/containers/Bundle/Application/8B2AB31F-91AB-4D44-A621-9EF66B1D2602/WeChat.app/WeChat
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
Got a connection, waiting for process information for launching or attaching.

然后各种搜索,也没有解决

你参考这个https://www.codercto.com/a/47482.html重新签名一下试试,还有debugserver *:12345 -a WeChat的时候,你就没成功,lldb肯定不行。Segmentation fault: 11应该是app加了反调试,你参考这篇看看 http://www.iosre.com/t/7-2-0-ios/770

通过这 iOS12 下配置debugserver + lldb调试环境的小技巧和问题处理 , 已经解决签名问题,具体导致原由,文章中有写,现在发生的现象如下:

chengzidexiaodupi:~ root# debugserver 127.0.0.1:1111 -a Weibo
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
Attaching to process Weibo...
Listening to port 1111 for a connection from 127.0.0.1...

lldb 会出现下面的问题,请问有什么办法解决吗?

(lldb) process connect connect://127.0.0.1:1111
error: Failed to connect port
(lldb) 

这个我也没解决,我现在用ssh root@ip调试的,usb调试也是报error: Failed to connect port的错。

ssh root@ip 你这样可以调试?我这种方式也调试不了,会出现下面的情况:

chengzidexiaodupi:~ root# debugserver 192.168.31.82:12345 -a /var/containers/Bundle/Application/97B08221-76F6-44BE-BB5C-5CAD7B38D854/Weibo.app/Weibo
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-900.3.57..2
 for arm64.
Attaching to process /var/containers/Bundle/Application/97B08221-76F6-44BE-BB5C-5CAD7B38D854/Weibo.app/Weibo...
Listening to port 12345 for a connection from 192.168.31.82...
error: rejecting incoming connection from 192.168.31.181 (expecting 192.168.31.82)

(lldb) process connect connect://192.168.31.82:12345
error: failed to get reply to handshake packet
(lldb) 


你手机和电脑是连在同一个网络上面么,看提示是两个ip,一个是192.168.31.181,一个是192.168.31.82,这个ip别错了。

同一个,设置不知道为什么会报这个错

把端口映射一下
iproxy 1234 1234

太赞了,我的问题解决了:+1: