我正在试验我的三星无线扬声器。我一直在使用 Wireshark 检查和逆向工程其 API。我进行的其中一个 API 调用导致奇怪的行为,似乎一个 HTTP 请求返回两个 HTTP 响应。
curl -v http://192.168.1.165:55001/UIC\?cmd\=%3Cname%3EGetMainInfo%3C/name%3E
令人沮丧的是,第二个响应包含我想要的有效载荷。我该如何获取它?
卷曲输出
* Trying 192.168.1.165...
* TCP_NODELAY set
* Connected to 192.168.1.165 (192.168.1.165) port 55001 (#0)
> GET /UIC?cmd=%3Cname%3EGetMainInfo%3C/name%3E HTTP/1.1
> Host: 192.168.1.165:55001
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 02 Jan 1970 09:31:25 GMT
< Server: Samsung/1.0
< Content-Type: text/html
< Content-Length: 215
< Connection: close
< Last-Modified: Fri, 02 Jan 1970 09:31:25 GMT
<
* Closing connection 0
<?xml version="1.0" encoding="UTF-8"?><UIC><method>RequestDeviceInfo</method><version>1.0</version><speakerip>192.168.1.165</speakerip><user_identifier>public</user_identifier><response result="ok"></response></UIC>
Wireshark HTTP 响应 1/2
<?xml version="1.0" encoding="UTF-8"?><UIC><method>RequestDeviceInfo</method><version>1.0</version><speakerip>192.168.1.165</speakerip><user_identifier>public</user_identifier><response result="ok"></response></UIC>
Wireshark HTTP 响应 2/2
<?xml version="1.0" encoding="UTF-8"?><UIC><method>MainInfo</method><version>1.0</version><speakerip>192.168.1.165</speakerip><user_identifier></user_identifier><response result="ok"><party>off</party><partymain></partymain><grouptype>N</grouptype><groupmainip>0.0.0.0</groupmainip><groupmainmacaddr>00:00:00:00:00:00</groupmainmacaddr><spkmacaddr>xx:xx:xx:xx:xx:xx</spkmacaddr><spkmodelname>SPK-WAM3500</spkmodelname><groupmode>none</groupmode><channeltype>invalid</channeltype><channelvolume>0</channelvolume><multichinfo>on</multichinfo><groupspknum>1</groupspknum><dfsstatus>dfsoff</dfsstatus><protocolver>2.3</protocolver><btmacaddr>xx:xx:xx:xx:xx:xx</btmacaddr></response></UIC>
网猫
看起来 Netcat 完成了这个工作:
$ nc 192.168.1.165 55001
GET /UIC?cmd=%3Cname%3EGetMainInfo%3C/name%3E HTTP/1.1
Host: 192.168.1.165
HTTP/1.1 200 OK
Date: Fri, 02 Jan 1970 10:53:13 GMT
Server: Samsung/1.0
Content-Type: text/html
Content-Length: 215
Connection: close
Last-Modified: Fri, 02 Jan 1970 10:53:13 GMT
<?xml version="1.0" encoding="UTF-8"?><UIC><method>RequestDeviceInfo</method><version>1.0</version><speakerip>192.168.1.165</speakerip><user_identifier>public</user_identifier><response result="ok"></response></UIC>HTTP/1.1 200 OK
Date: Fri, 02 Jan 1970 10:53:13 GMT
Server: Samsung/1.0
Content-Type: text/html
Content-Length: 684
Connection: close
Last-Modified: Fri, 02 Jan 1970 10:53:13 GMT
<?xml version="1.0" encoding="UTF-8"?><UIC><method>MainInfo</method><version>1.0</version><speakerip>192.168.1.165</speakerip><user_identifier></user_identifier><response result="ok"><party>off</party><partymain></partymain><grouptype>N</grouptype><groupmainip>0.0.0.0</groupmainip><groupmainmacaddr>00:00:00:00:00:00</groupmainmacaddr><spkmacaddr>xx:xx:xx:xx:xx:xx</spkmacaddr><spkmodelname>SPK-WAM3500</spkmodelname><groupmode>none</groupmode><channeltype>invalid</channeltype><channelvolume>0</channelvolume><multichinfo>on</multichinfo><groupspknum>1</groupspknum><dfsstatus>dfsoff</dfsstatus><protocolver>2.3</protocolver><btmacaddr>xx:xx:xx:xx:xx:xx</btmacaddr></response></UIC>