Script to find UPNP devices / servers in a network

UPNP Info Python script

$ git clone https://github.com/lynxbee/upnp_info.git 
$ cd upnp_info 
$ python upnp_info.py 

Note: while running above script, refer another post “Solved: ImportError: No module named requests” if you get an error.

If we run above script on your Linux / Ubuntu PC, it will show UPNP servers , devices information as below,

$ python upnp_info.py 
[+] Discovering UPnP locations
[+] Discovery complete
[+] 2 locations found:
	-> http://192.168.0.104:8200/rootDesc.xml
	-> http://192.168.0.1:1900/igd.xml
[+] Loading http://192.168.0.104:8200/rootDesc.xml...
	-> Server String: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
	==== XML Attributes ===
	-> Device Type: urn:schemas-upnp-org:device:MediaServer:1
	-> Friendly Name: devlab: minidlna
	-> Manufacturer: Justin Maggard
	-> Manufacturer URL: http://www.netgear.com/
	-> Model Description: MiniDLNA on Linux
	-> Model Name: Windows Media Connect compatible (MiniDLNA)
	-> Model Number: 1.2.1
	-> Services:
		=> Service Type: urn:schemas-upnp-org:service:ContentDirectory:1
		=> Control: /ctl/ContentDir
		=> Events: /evt/ContentDir
		=> API: http://192.168.0.104:8200/ContentDir.xml
			- GetSearchCapabilities
			- GetSortCapabilities
			- GetSystemUpdateID
			- Browse
			- Search
			- UpdateObject
		=> Service Type: urn:schemas-upnp-org:service:ConnectionManager:1
		=> Control: /ctl/ConnectionMgr
		=> Events: /evt/ConnectionMgr
		=> API: http://192.168.0.104:8200/ConnectionMgr.xml
			- GetProtocolInfo
			- GetCurrentConnectionIDs
			- GetCurrentConnectionInfo
		=> Service Type: urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1
		=> Control: /ctl/X_MS_MediaReceiverRegistrar
		=> Events: /evt/X_MS_MediaReceiverRegistrar
		=> API: http://192.168.0.104:8200/X_MS_MediaReceiverRegistrar.xml
			- IsAuthorized
			- IsValidated
			- RegisterDevice
	[+] Content browsing available. Looking up base directories...
		Storage Folder: Browse Folders
		Storage Folder: Music
		Storage Folder: Pictures
		Storage Folder: Video
[+] Loading http://192.168.0.1:1900/igd.xml...
	-> Server String: ipos/7.0 UPnP/1.0 TL-WR740N/4.0
	==== XML Attributes ===
	-> Device Type: urn:schemas-upnp-org:device:InternetGatewayDevice:1
	-> Friendly Name: Wireless Router TL-WR740N
	-> Manufacturer: TP-LINK
	-> Manufacturer URL: http://www.tp-link.com
	-> Model Description: Wireless Router TL-WR740N
	-> Model Name: TL-WR740N
	-> Model Number: 4.0
	-> Services:
		=> Service Type: urn:schemas-upnp-org:service:Layer3Forwarding:1
		=> Control: /l3f
		=> Events: /l3f
		=> API: http://192.168.0.1:1900/l3f.xml
			- SetDefaultConnectionService
			- GetDefaultConnectionService
		=> Service Type: urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
		=> Control: /ifc
		=> Events: /ifc
		=> API: http://192.168.0.1:1900/ifc.xml
			- GetCommonLinkProperties
			- GetTotalBytesSent
			- GetTotalBytesReceived
			- GetTotalPacketsSent
			- GetTotalPacketsReceived
		=> Service Type: urn:schemas-upnp-org:service:WANIPConnection:1
		=> Control: /ipc
		=> Events: /ipc
		=> API: http://192.168.0.1:1900/ipc.xml
			- SetConnectionType
			- GetConnectionTypeInfo
			- RequestConnection
			- ForceTermination
			- GetStatusInfo
			- GetNATRSIPStatus
			- GetGenericPortMappingEntry
			- GetSpecificPortMappingEntry
			- AddPortMapping
			- DeletePortMapping
			- GetExternalIPAddress
		=> Service Type: urn:schemas-wifialliance-org:service:WFAWLANConfig:1
		=> Control: http://192.168.0.1:1910/WFAWLANConfig/control
		=> Events: http://192.168.0.1:1910/WFAWLANConfig/event
		=> API: http://192.168.0.1:1900/http://192.168.0.1:1900/wfc.xml
	[+] IGD port mapping available. Looking up current mappings...
[+] Fin.
Follow Lynxbee

Leave a Reply / Ask Question