Identify UPNP SSDP packets from your network

The following script Written by nabe@abk (Credit to author) displays the UPNP Simple Service Discovery Protocol (SSDP) packets from your network.

 $ vim ssdp-test.pl 
#!/usr/bin/perl
################################################################################
# SSDP discover                         Written by nabe@abk / This is PDS
################################################################################
use strict;
use Socket;
 
my $CAST = '239.255.255.250';
my $PORT = 1900;
################################################################################
my $msg =<<SSDP;
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: ssdp:all
 
SSDP
# ST: ssdp:all
# ST: urn:schemas-upnp-org:device:MediaServer:1
# ST: urn:schemas-upnp-org:device:MediaRenderer:1
 
$msg =~ s/\r?\n/\r\n/g;
################################################################################
my $sock;
my $addr = pack_sockaddr_in($PORT, inet_aton($CAST));
socket($sock, AF_INET, SOCK_DGRAM, 0);
setsockopt($sock, SOL_SOCKET, SO_BROADCAST, 1);
bind($sock, pack_sockaddr_in(0, INADDR_ANY));
send($sock, $msg, 0, $addr);
 
while (1){
        my $buf;
        recv($sock, $buf, 65536, 0);
        print "$buf\n";
}

Now, run this script as,

$ perl ssdp-test.pl
$ perl ssdp-test.pl 
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: uuid:4d696e69-444c-164e-9d41-544810cf4812
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0


HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: upnp:rootdevice
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812::upnp:rootdevice
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0


HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: urn:schemas-upnp-org:device:MediaServer:1
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812::urn:schemas-upnp-org:device:MediaServer:1
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0

You can also refer to C program – UDP Server to print UPNP Packets


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


1 thought on “Identify UPNP SSDP packets from your network”

Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded