1. discover
wirshark filter expression : tcp.port == 12470 && tcp.len > 0 || ( http && udp && (ip.addr==192.168.0.4 || ip.addr == 239.255.255.250) )
ip.addr == 239.255.255.250 is the default multicast address, http use udp protocol(not tcp at all)
[zhang@localhost bin]$ ./upnpc -s
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
Connection Type : IP_Routed
Status : Connected, uptime=61831s, LastConnectionError : ERROR_NONE
Time started : Fri May 11 21:17:45 2012
MaxBitRateDown : 4200000 bps (4.2 Mbps) MaxBitRateUp 4200000 bps (4.2 Mbps)
ExternalIPAddress = 192.168.0.1
Bytes: Sent: 453116748 Recv: 63475745
Packets: Sent: 484040 Recv: 521903
[zhang@localhost bin]$
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
MAN: "ssdp:discover"
MX: 2
================================================================
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=120
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:00000000-0000-0000-0000-000000000000::urn:schemas-upnp-org:device:InternetGatewayDevice:1
EXT:
SERVER: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
LOCATION: http://192.168.0.1:12470/rootDesc.xml
/
GET /rootDesc.xml HTTP/1.1
Host: 192.168.0.1:12470
Connection: Close
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
HTTP/1.1 200 OK
Content-Type: text/xml
Connection: close
Content-Length: 2574
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
=================================================================
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
<friendlyName>NETCORE NR235W</friendlyName>
<manufacturer>NETCORE</manufacturer>
<manufacturerURL>http://www.netcore.com.cn/</manufacturerURL>
<modelDescription>NETCORE NR235W</modelDescription>
<modelName>NR235W</modelName>
<modelNumber>NR235W</modelNumber>
<modelURL>http://www.netcore.com.cn/</modelURL>
<serialNumber>00000000</serialNumber>
<UDN>uuid:00000000-0000-0000-0000-000000000000</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
<serviceId>urn:upnporg:serviceId:Layer3Forwarding1</serviceId>
<controlURL>/ctl/L3F</controlURL>
<eventSubURL>/evt/L3F</eventSubURL>
<SCPDURL>/L3F.xml</SCPDURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
<friendlyName>WANDevice</friendlyName>
<manufacturer>MiniUPnP</manufacturer>
<manufacturerURL>http://www.netcore.com.cn/</manufacturerURL>
<modelDescription>WAN Device</modelDescription>
<modelName>WANDevice</modelName>
<modelNumber>20110126</modelNumber>
<modelURL>http://www.netcore.com.cn/</modelURL>
<serialNumber>00000000</serialNumber>
<UDN>uuid:00000000-0000-0000-0000-000000000000</UDN>
<UPC>MINIUPNPD</UPC>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
<controlURL>/ctl/CmnIfCfg</controlURL>
<eventSubURL>/evt/CmnIfCfg</eventSubURL>
<SCPDURL>/WANCfg.xml</SCPDURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
<friendlyName>WANConnectionDevice</friendlyName>
<manufacturer>MiniUPnP</manufacturer>
<manufacturerURL>http://www.netcore.com.cn/</manufacturerURL>
<modelDescription>MiniUPnP daemon</modelDescription>
<modelName>MiniUPnPd</modelName>
<modelNumber>20110126</modelNumber>
<modelURL>http://www.netcore.com.cn/</modelURL>
<serialNumber>00000000</serialNumber>
<UDN>uuid:00000000-0000-0000-0000-000000000000</UDN>
<UPC>MINIUPNPD</UPC>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
<controlURL>/ctl/IPConn</controlURL>
<eventSubURL>/evt/IPConn</eventSubURL>
<SCPDURL>/WANIPCn.xml</SCPDURL>
</service>
</serviceList>
</device>
</deviceList>
</device>
</deviceList>
<presentationURL>http://192.168.0.1/</presentationURL>
</device>
</root>
2.
wirshark filter expression : tcp.len > 0 && tcp.port == 12470 && (ip.addr==192.168.0.4 || ip.addr == 239.255.255.250)
[zhang@localhost bin]$ ./upnpc -l
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
Connection Type : IP_Routed
Status : Connected, uptime=62685s, LastConnectionError : ERROR_NONE
Time started : Fri May 11 21:17:45 2012
MaxBitRateDown : 4200000 bps (4.2 Mbps) MaxBitRateUp 4200000 bps (4.2 Mbps)
ExternalIPAddress = 192.168.0.1
i protocol exPort->inAddr:inPort description remoteHost leaseTime
0 TCP 23->192.168.0.1:23 'libminiupnpc' '' 0
1 UDP 5060->192.168.0.4:5060 'libminiupnpc' '' 0
2 UDP 59131->192.168.0.3:59131 'Teredo' '' 0
GetGenericPortMappingEntry() returned 713 (SpecifiedArrayIndexInvalid)
[zhang@localhost bin]$
//
POST /ctl/IPConn HTTP/1.1
Host: 192.168.0.1:12470
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
Content-Length: 341
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"><NewPortMappingIndex>1</NewPortMappingIndex></u:GetGenericPortMappingEntry></s:Body></s:Envelope>
=================================================================
HTTP/1.1 200 OK
Content-Type: text/xml
Connection: close
Content-Length: 633
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetGenericPortMappingEntryResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"><NewRemoteHost></NewRemoteHost><NewExternalPort>5060</NewExternalPort><NewProtocol>UDP</NewProtocol><NewInternalPort>5060</NewInternalPort><NewInternalClient>192.168.0.4</NewInternalClient><NewEnabled>1</NewEnabled><NewPortMappingDescription>libminiupnpc</NewPortMappingDescription><NewLeaseDuration>0</NewLeaseDuration></u:GetGenericPortMappingEntryResponse></s:Body></s:Envelope>
//
POST /ctl/IPConn HTTP/1.1
Host: 192.168.0.1:12470
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
Content-Length: 341
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewPortMappingIndex>2</NewPortMappingIndex>
</u:GetGenericPortMappingEntry>
</s:Body>
</s:Envelope>
=================================================================
HTTP/1.1 200 OK
Content-Type: text/xml
Connection: close
Content-Length: 629
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetGenericPortMappingEntryResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>59131</NewExternalPort>
<NewProtocol>UDP</NewProtocol>
<NewInternalPort>59131</NewInternalPort>
<NewInternalClient>192.168.0.3</NewInternalClient>
<NewEnabled>1</NewEnabled>
<NewPortMappingDescription>Teredo</NewPortMappingDescription>
<NewLeaseDuration>0</NewLeaseDuration>
</u:GetGenericPortMappingEntryResponse>
</s:Body>
</s:Envelope>
//
POST /ctl/IPConn HTTP/1.1
Host: 192.168.0.1:12470
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
Content-Length: 341
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewPortMappingIndex>3</NewPortMappingIndex>
</u:GetGenericPortMappingEntry>
</s:Body>
</s:Envelope>
=================================================================
HTTP/1.1 500 Internal Server Error
Content-Type: text/xml
Connection: close
Content-Length: 410
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
<errorCode>713</errorCode>
<errorDescription>SpecifiedArrayIndexInvalid</errorDescription>
</UPnPError>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
3.AddPortMapping
wirshark filter expression :
tcp.len > 0 && tcp.port == 12470 && (ip.addr==192.168.0.4 || ip.addr == 239.255.255.250) || http
[zhang@localhost bin]$ ./upnpc -a 192.168.0.4 5070 5070 udp
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
ExternalIPAddress = 192.168.0.1
InternalIP:Port = 192.168.0.4:5070
external 192.168.0.1:5070 UDP is redirected to internal 192.168.0.4:5070 (duration=0)
[zhang@localhost bin]$
[zhang@localhost bin]$
[zhang@localhost bin]$
[zhang@localhost bin]$ ./upnpc -l
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
Connection Type : IP_Routed
Status : Connected, uptime=97618s, LastConnectionError : ERROR_NONE
Time started : Fri May 11 21:17:45 2012
MaxBitRateDown : 4200000 bps (4.2 Mbps) MaxBitRateUp 4200000 bps (4.2 Mbps)
ExternalIPAddress = 192.168.0.1
i protocol exPort->inAddr:inPort description remoteHost leaseTime
0 UDP 5070->192.168.0.4:5070 'libminiupnpc' '' 0
1 UDP 51084->192.168.0.3:51084 'Teredo' '' 0
2 TCP 23->192.168.0.1:23 'libminiupnpc' '' 0
3 UDP 5060->192.168.0.4:5060 'libminiupnpc' '' 0
4 UDP 59131->192.168.0.3:59131 'Teredo' '' 0
GetGenericPortMappingEntry() returned 713 (SpecifiedArrayIndexInvalid)
[zhang@localhost bin]$
//
POST /ctl/IPConn HTTP/1.1
Host: 192.168.0.1:12470
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
Content-Length: 593
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>5070</NewExternalPort>
<NewProtocol>UDP</NewProtocol>
<NewInternalPort>5070</NewInternalPort>
<NewInternalClient>192.168.0.4</NewInternalClient>
<NewEnabled>1</NewEnabled>
<NewPortMappingDescription>libminiupnpc</NewPortMappingDescription>
<NewLeaseDuration>0</NewLeaseDuration>
</u:AddPortMapping>
</s:Body>
</s:Envelope>
===============================================================
HTTP/1.1 200 OK
Content-Type: text/xml
Connection: close
Content-Length: 263
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/>
</s:Body>
</s:Envelope>
4.DeletePortMapping
wirshark filter expression :
tcp.len > 0 && tcp.port == 12470 && (ip.addr==192.168.0.4 || ip.addr == 239.255.255.250) || http
[zhang@localhost bin]$ ./upnpc -d 51084 udp
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
UPNP_DeletePortMapping() returned : 0
[zhang@localhost bin]$
[zhang@localhost bin]$
[zhang@localhost bin]$ ./upnpc -l
List of UPNP devices found on the network :
desc: http://192.168.0.1:12470/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.0.1:12470/ctl/IPConn
Local LAN ip address : 192.168.0.4
Connection Type : IP_Routed
Status : Connected, uptime=98070s, LastConnectionError : ERROR_NONE
Time started : Fri May 11 21:17:45 2012
MaxBitRateDown : 4200000 bps (4.2 Mbps) MaxBitRateUp 4200000 bps (4.2 Mbps)
ExternalIPAddress = 192.168.0.1
i protocol exPort->inAddr:inPort description remoteHost leaseTime
0 UDP 5070->192.168.0.4:5070 'libminiupnpc' '' 0
1 TCP 23->192.168.0.1:23 'libminiupnpc' '' 0
2 UDP 5060->192.168.0.4:5060 'libminiupnpc' '' 0
3 UDP 59131->192.168.0.3:59131 'Teredo' '' 0
GetGenericPortMappingEntry() returned 713 (SpecifiedArrayIndexInvalid)
//
POST /ctl/IPConn HTTP/1.1
Host: 192.168.0.1:12470
User-Agent: Fedora/10, UPnP/1.0, MiniUPnPc/1.6
Content-Length: 380
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:DeletePortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>51084</NewExternalPort>
<NewProtocol>UDP</NewProtocol>
</u:DeletePortMapping>
</s:Body>
</s:Envelope>
===================================================================
HTTP/1.1 200 OK
Content-Type: text/xml
Connection: close
Content-Length: 295
Server: LINUX-2.6 UPnP/1.0 MiniUPnPd/1.5
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
</u:DeletePortMappingResponse>
</s:Body>
</s:Envelope>
upnpc to add/delete/show port mapping entry
最新推荐文章于 2022-10-10 09:13:32 发布