Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dhcp.rb 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*- coding: binary -*-
  2. require 'rex/proto/dhcp'
  3. module Msf
  4. ###
  5. #
  6. # This mixin provides a DHCPServer
  7. #
  8. ###
  9. module Exploit::DHCPServer
  10. def initialize(info = {})
  11. super(update_info(info,
  12. 'Stance' => Msf::Exploit::Stance::Passive,
  13. ))
  14. register_options(
  15. [
  16. OptString.new('SRVHOST', [ true, "The IP of the DHCP server" ]),
  17. OptString.new('NETMASK', [ true, "The netmask of the local subnet" ]),
  18. OptString.new('DHCPIPSTART', [ false, "The first IP to give out" ]),
  19. OptString.new('DHCPIPEND', [ false, "The last IP to give out" ]),
  20. OptString.new('ROUTER', [ false, "The router IP address" ]),
  21. OptString.new('BROADCAST', [ false, "The broadcast address to send to" ]),
  22. OptString.new('DNSSERVER', [ false, "The DNS server IP address" ]),
  23. OptString.new('DOMAINNAME', [ false, "The optional domain name to assign" ]),
  24. OptString.new('HOSTNAME', [ false, "The optional hostname to assign" ]),
  25. OptString.new('HOSTSTART', [ false, "The optional host integer counter" ]),
  26. OptString.new('FILENAME', [ false, "The optional filename of a tftp boot server" ])
  27. ], self.class)
  28. @dhcp = nil
  29. end
  30. def start_service(hash = {}, context = {})
  31. @dhcp = Rex::Proto::DHCP::Server.new(hash, context)
  32. vprint_status("Starting DHCP server")
  33. @dhcp.start
  34. add_socket(@dhcp.sock)
  35. @dhcp
  36. end
  37. def stop_service
  38. vprint_status("Stopping DHCP server")
  39. @dhcp.stop
  40. end
  41. attr_accessor :dhcp
  42. end
  43. end