-
Notifications
You must be signed in to change notification settings - Fork 4
/
fuzz_msearch.py
executable file
·45 lines (39 loc) · 947 Bytes
/
fuzz_msearch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'''
Meant to fuzz the SSDP protocol
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
MAN: "ssdp:discover"
MX: 2
'''
from defs import *
from testcases import *
from upnp import *
import sys
def build_ssdp(st):
request = 'M-SEARCH * HTTP/1.1\r\n'\
'HOST: 239.255.255.250:1900\r\n'\
'ST: %s\r\n'\
'MAN "ssdp:discover"\r\n'\
'MX: 2' % (st)
return request
def fuzz_msearch():
server = hp.createNewListener('', False)
if server == False:
print 'Failed to bind port %d' % lport
return
fuzz_data = get_fuzz_data()
fuzz_data.append('"ssdp:discover"')
fuzz_data.append('upnp:rootdevice')
#print fuzz_data
try:
while True:
request = build_ssdp(get_random_str(fuzz_data))
hp.send(request,server)
print hp.recv(1024,server)
except KeyboardInterrupt:
print ''
sys.exit(0)
if __name__ == '__main__':
hp = upnp(False, False, None, None)
fuzz_msearch()