Created
August 3, 2020 03:28
-
-
Save codeniko/c2b3353e6b8aad85e76c5fbf780c9504 to your computer and use it in GitHub Desktop.
Broadcast SSDP request or specify ip as arg1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import socket | |
import sys | |
dst = "239.255.255.250" | |
if len(sys.argv) > 1: | |
dst = sys.argv[1] | |
st = "upnp:rootdevice" | |
if len(sys.argv) > 2: | |
st = sys.argv[2] | |
msg = [ | |
'M-SEARCH * HTTP/1.1', | |
'Host:239.255.255.250:1900', | |
'ST:%s' % (st,), | |
'Man:"ssdp:discover"', | |
'MX:1', | |
''] | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) | |
s.settimeout(10) | |
s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 1) | |
s.sendto('\r\n'.join(msg), (dst, 1900) ) | |
while True: | |
try: | |
data, addr = s.recvfrom(32*1024) | |
except socket.timeout: | |
break | |
print "[+] %s\n%s" % (addr, data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment