Module: Msf::Exploit::DHCPServer

Includes:
Remote::SocketServer
Defined in:
lib/msf/core/exploit/dhcp_server.rb

Overview

This mixin provides a DHCPServer

Instance Attribute Summary collapse

Attributes included from Remote::SocketServer

#service

Instance Method Summary collapse

Methods included from Remote::SocketServer

#_determine_server_comm, #bindhost, #bindport, #cleanup, #cleanup_service, #exploit, #on_client_data, #primer, #regenerate_payload, #srvhost, #srvport, #via_string

Instance Attribute Details

#dhcpObject

Returns the value of attribute dhcp.



57
58
59
# File 'lib/msf/core/exploit/dhcp_server.rb', line 57

def dhcp
  @dhcp
end

Instance Method Details

#initialize(info = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/msf/core/exploit/dhcp_server.rb', line 14

def initialize(info = {})
  super(update_info(info,
    'Stance' => Msf::Exploit::Stance::Passive,
  ))

  register_options(
    [
      OptString.new('DHCPINTERFACE',[ false, "The network interface to use for broadcast" ]),
      OptAddress.new('SRVHOST',     [ true,  "The IP of the DHCP server" ]),
      OptAddress.new('NETMASK',     [ true,  "The netmask of the local subnet" ]),
      OptAddress.new('DHCPIPSTART', [ false, "The first IP to give out" ]),
      OptAddress.new('DHCPIPEND',   [ false, "The last IP to give out" ]),
      OptAddress.new('ROUTER',      [ false, "The router IP address" ]),
      OptAddress.new('BROADCAST',   [ false, "The broadcast address to send to" ]),
      OptAddress.new('DNSSERVER',   [ false, "The DNS server IP address" ]),
      OptString.new('DOMAINNAME',  [ false, "The optional domain name to assign" ]),
      OptString.new('HOSTNAME',    [ false, "The optional hostname to assign" ]),
      OptString.new('HOSTSTART',   [ false, "The optional host integer counter" ]),
      OptString.new('FILENAME',    [ false, "The optional filename of a tftp boot server" ])
    ], self.class)

  @dhcp = nil
end

#start_service(hash = {}, context = {}) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/msf/core/exploit/dhcp_server.rb', line 38

def start_service(hash = {}, context = {})
  @dhcp = Rex::Proto::DHCP::Server.new(hash, context)
  vprint_status("Starting DHCP server")
  @dhcp.start
  add_socket(@dhcp.sock)
  @dhcp
end

#stop_serviceObject



46
47
48
49
# File 'lib/msf/core/exploit/dhcp_server.rb', line 46

def stop_service
  vprint_status("Stopping DHCP server")
  @dhcp.stop
end

#validateObject



51
52
53
54
55
# File 'lib/msf/core/exploit/dhcp_server.rb', line 51

def validate
   unless _determine_server_comm(datastore['SRVHOST']) == Rex::Socket::Comm::Local
     raise Msf::OptionValidateError.new({ 'SRVHOST' => 'SRVHOST can not be forwarded via a session.' })
   end
end