Class: Rex::Post::Meterpreter::Extensions::Lanattacks::Dhcp::Dhcp
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Extensions::Lanattacks::Dhcp::Dhcp
- Defined in:
- lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb
Overview
DHCP Server functionality
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client) ⇒ Dhcp
constructor
A new instance of Dhcp.
- #load_options(datastore) ⇒ Object
- #log ⇒ Object
- #reset ⇒ Object
- #set_option(name, value) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(client) ⇒ Dhcp
Returns a new instance of Dhcp.
19 20 21 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 19 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
74 75 76 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 74 def client @client end |
Instance Method Details
#load_options(datastore) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 41 def (datastore) # TODO: change this so that all of the options are set in a single # payload rather than firing off lots of calls separately datastore.each do |name, value| if Regexp.new('DHCPIPSTART|DHCPIPEND|NETMASK|ROUTER|DNSSERVER|BROADCAST|'+ 'SERVEONCE|PXE|HOSTNAME|HOSTSTART|FILENAME|PXECONF|SRVHOST') =~ name set_option(name, value) end end end |
#log ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 57 def log response = client.send_request(Packet.create_request('lanattacks_dhcp_log')) entries = [] if( response.result == 0 ) log = response.get_tlv_value( TLV_TYPE_LANATTACKS_RAW ) while log.length > 0 mac = log.slice!(0..5) ip = log.slice!(0..3) entries << { :mac => mac, :ip => ip } end end entries end |
#reset ⇒ Object
28 29 30 31 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 28 def reset client.send_request(Packet.create_request('lanattacks_reset_dhcp')) true end |
#set_option(name, value) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 33 def set_option(name, value) request = Packet.create_request('lanattacks_set_dhcp_option') request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, name) request.add_tlv(TLV_TYPE_LANATTACKS_OPTION, value) client.send_request(request) true end |
#start ⇒ Object
23 24 25 26 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 23 def start client.send_request(Packet.create_request('lanattacks_start_dhcp')) true end |
#stop ⇒ Object
52 53 54 55 |
# File 'lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb', line 52 def stop client.send_request(Packet.create_request('lanattacks_stop_dhcp')) true end |