大龙的博客

常用链接

统计

最新评论

迅雷UPnP数据抓包分析 --- 转

写UPNP路由端口映射程序时抓的迅雷的数据包,由UPNP协议在路由上进行端口映射的全过程都在这里了。
有了过程思路,想要自己在路由上增加端口映射就容易了,只是发送数据包,接收并解析XML数据的问题了。

//设备发现消息
[2009-9-21 23:54:07:033]
M-SEARCH * HTTP/1.1
HOST:239.255.255.250:1900
MAN:"ssdp:discover"
MX:6
ST:urn:schemas-upnp-org:service:WANPPPConnection:1

M-SEARCH * HTTP/1.1
HOST:239.255.255.250:1900
MAN:"ssdp:discover"
MX:6
ST:urn:schemas-upnp-org:service:WANIPConnection:1

//////////////////////////////////////////////////////////
[2009-9-21 23:54:07:043]
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Thu, 01 Jan 1970 00:46:40 GMT
EXT:
LOCATION: http://192.168.1.1:1900/igd.xml
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
ST: urn:schemas-upnp-org:service:WANIPConnection:1
USN: uuid:upnp-WANConnectionDevice-192168115678900001::urn:schemas-upnp-org:service:WANIPConnection:1

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:03:56:811]
GET /igd.xml HTTP/1.1
Host: 192.168.1.1:1900


[2009-9-22 0:03:56:811]
HTTP/1.1 200 OK
CONTENT-LENGTH: 2746
CONTENT-TYPE: text/xml
DATE: Thu, 01 Jan 1970 00:56:29 GMT
LAST-MODIFIED: Tue, 28 Oct 2003 08:46:08 GMT
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONNECTION: close




1
0



urn:schemas-upnp-org:device:InternetGatewayDevice:1
http://192.168.1.1:80 TP-LINK SOHO Router R402 Serie
TP-LINK
http://www.tp-link.com.cn
TL-R402 Series 2.0
TL-R402 Series
2.0
uuid:upnp-InternetGatewayDevice-192168115678900001
123456789001


urn:schemas-upnp-org:service:Layer3Forwarding:1
urn:upnp-org:serviceId:L3Forwarding1
/l3f
/l3f
/l3f.xml




urn:schemas-upnp-org:device:WANDevice:1
WAN Device
TP-LINK
http://www.tp-link.com.cn
WAN Device
WAN Device
1

12345678900001
uuid:upnp-WANDevice-192168115678900001
123456789001


urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
urn:upnp-org:serviceId:WANCommonInterfaceConfig
/ifc
/ifc
/ifc.xml




urn:schemas-upnp-org:device:WANConnectionDevice:1
WAN Connection Device
TP-LINK
http://www.tp-link.com.cn
WAN Connection Device
WAN Connection Device
1

12345678900001
uuid:upnp-WANConnectionDevice-192168115678900001
123456789001


urn:schemas-upnp-org:service:WANIPConnection:1
urn:upnp-org:serviceId:WANIPConnection
/ipc
/ipc
/ipc.xml









得到外部IP地址
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:03:56:831]
POST /ipc HTTP/1.1
HOST: 192.168.1.1:1900
Content-Length: 296 
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"


xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">







[2009-9-22 0:03:56:841]
HTTP/1.1 200 OK
CONNECTION: close
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONTENT-LENGTH: 404
CONTENT-TYPE: text/xml; charset="utf-8"




220.112.102.188




增加端口映射
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

[2009-9-22 0:03:56:851]
POST /ipc HTTP/1.1
HOST: 192.168.1.1:1900
Content-Length: 665 
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"


xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">



10141
TCP
80
192.168.1.103
1
Thunder5
0





[2009-9-22 0:03:56:861]
HTTP/1.1 200 OK
CONNECTION: close
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONTENT-LENGTH: 332
CONTENT-TYPE: text/xml; charset="utf-8"







增加端口映射
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:03:56:881]
POST /ipc HTTP/1.1
HOST: 192.168.1.1:1900
Content-Length: 668 
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"


xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">



10141
UDP
19369
192.168.1.103
1
Thunder5
0





[2009-9-22 0:03:56:891]
HTTP/1.1 200 OK
CONNECTION: close
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONTENT-LENGTH: 332
CONTENT-TYPE: text/xml; charset="utf-8"







////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:17:16:651]
SUBSCRIBE /ifc HTTP/1.1
SID: uuid:16842752-2147511038
Timeout: Second-1800
User-Agent: Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x)
Host: 192.168.1.1:1900
Content-Length: 0
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache


[2009-9-22 0:17:16:661]
HTTP/1.1 200 OK
DATE: Thu, 01 Jan 1970 01:09:49 GMT
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
SID: uuid:16842752-2147511038
TIMEOUT: Second-1800

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:17:16:691]
SUBSCRIBE /ipc HTTP/1.1
SID: uuid:16842752-2281728766
Timeout: Second-1800
User-Agent: Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x)
Host: 192.168.1.1:1900
Content-Length: 0
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache


[2009-9-22 0:17:16:711]
HTTP/1.1 200 OK
DATE: Thu, 01 Jan 1970 01:09:49 GMT
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
SID: uuid:16842752-2281728766
TIMEOUT: Second-1800

//删除端口映射
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:18:38:349]
POST /ipc HTTP/1.1
HOST: 192.168.1.1:1900
Content-Length: 399 
Connection: close
CONTENT-TYPE: text/xml ; charset="utf-8"
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"


xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">



10141
TCP





[2009-9-22 0:18:38:349]
HTTP/1.1 200 OK
CONNECTION: close
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONTENT-LENGTH: 338
CONTENT-TYPE: text/xml; charset="utf-8"







//删除端口映射
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[2009-9-22 0:18:38:359]
POST /ipc HTTP/1.1
HOST: 192.168.1.1:1900
Content-Length: 399 
Connection: close
CONTENT-TYPE: text/xml ; charset="utf-8"
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"


xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">



10141
UDP





[2009-9-22 0:18:38:369]
HTTP/1.1 200 OK
CONNECTION: close
SERVER: TP-LINK SOHO Router R402 Series Router, UPnP/1.0
CONTENT-LENGTH: 338
CONTENT-TYPE: text/xml; charset="utf-8"








////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

posted on 2009-11-17 12:41 大龙 阅读(3873) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理