Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/meterpreter/extensions/lanattacks/dhcp/dhcp.rb
Views: 11797
# -*- coding: binary -*-12require 'rex/post/meterpreter/extensions/lanattacks/tlv'34module Rex5module Post6module Meterpreter7module Extensions8module Lanattacks9module Dhcp1011###12#13# DHCP Server functionality14#15###16class Dhcp1718def initialize(client)19@client = client20end2122def start23client.send_request(Packet.create_request(COMMAND_ID_LANATTACKS_START_DHCP))24true25end2627def reset28client.send_request(Packet.create_request(COMMAND_ID_LANATTACKS_RESET_DHCP))29true30end3132def set_option(name, value)33request = Packet.create_request(COMMAND_ID_LANATTACKS_SET_DHCP_OPTION)34request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, name)35request.add_tlv(TLV_TYPE_LANATTACKS_OPTION, value)36client.send_request(request)37true38end3940def load_options(datastore)41# TODO: change this so that all of the options are set in a single42# payload rather than firing off lots of calls separately43datastore.each do |name, value|44if Regexp.new('DHCPIPSTART|DHCPIPEND|NETMASK|ROUTER|DNSSERVER|BROADCAST|'+45'SERVEONCE|PXE|HOSTNAME|HOSTSTART|FILENAME|PXECONF|SRVHOST') =~ name46set_option(name, value)47end48end49end5051def stop52client.send_request(Packet.create_request(COMMAND_ID_LANATTACKS_STOP_DHCP))53true54end5556def log57response = client.send_request(Packet.create_request(COMMAND_ID_LANATTACKS_DHCP_LOG))58entries = []59if( response.result == 0 )60log = response.get_tlv_value( TLV_TYPE_LANATTACKS_RAW )61while log.length > 062mac = log.slice!(0..5)63ip = log.slice!(0..3)64entries << {65:mac => mac,66:ip => ip67}68end69end70entries71end7273attr_accessor :client7475end7677end; end; end; end; end; end787980