class Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Lanattacks::Dhcp

The DHCP portion of the lanattacks extension.

Constants

Klass

Public Instance Methods

cmd_dhcp_load_options(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 186
def cmd_dhcp_load_options(*args)
  @@dhcp_set_option_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_set_option_usage
      return true
    end
  }

  if args.length < 1
    print_dhcp_load_options_usage
    return true
  end

  datastore = args.shift

  if not datastore.is_a?(Hash)
    print_dhcp_load_options_usage
    return true
  end

  client.lanattacks.dhcp.load_options(datastore)
end
cmd_dhcp_log(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 219
def cmd_dhcp_log(*args)
  @@dhcp_log_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_log_usage
      return true
    end
  }

  log = client.lanattacks.dhcp.log

  table = Rex::Ui::Text::Table.new(
    'Header'    => 'DHCP Server Log',
    'Indent'    => 0,
    'SortIndex' => 0,
    'Columns'   => [ 'MAC Address', 'IP Address' ]
  )

  log.each { |l|
    table << [ l[:mac], l[:ip] ]
  }

  print_line
  print_line( table.to_s )
  print_line( "Total log entries: #{log.length}" )
  print_line
end
cmd_dhcp_reset(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 117
def cmd_dhcp_reset(*args)
  @@dhcp_reset_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_reset_usage
      return true
    end
  }

  print_status( "Resetting DHCP server ...")
  client.lanattacks.dhcp.reset
  print_good( "DHCP server reset.")
end
cmd_dhcp_set_option(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 148
def cmd_dhcp_set_option(*args)
  @@dhcp_set_option_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_set_option_usage
      return true
    end
  }

  if args.length < 2
    print_dhcp_set_option_usage
    return true
  end


  name = args.shift.upcase
  value = args.shift

  if not @@dhcp_set_option_valid_options.include? name
    print_error( "Invalid option name '#{name}'." )
    return true
  end

  client.lanattacks.dhcp.set_option(name, value)
end
cmd_dhcp_start(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 71
def cmd_dhcp_start(*args)
  @@dhcp_start_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_start_usage
      return true
    end
  }

  print_status( "Starting DHCP server ...")
  client.lanattacks.dhcp.start
  print_good( "DHCP server startd.")
end
cmd_dhcp_stop(*args) click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 94
def cmd_dhcp_stop(*args)
  @@dhcp_stop_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_dhcp_stop_usage
      return true
    end
  }

  print_status( "Stopping DHCP server ...")
  client.lanattacks.dhcp.stop
  print_good( "DHCP server stopped.")
end
commands() click to toggle source

List of supported commands.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 22
def commands
  all = {
    "dhcp_start"        => "Start the DHCP server",
    "dhcp_stop"         => "Stop the DHCP server",
    "dhcp_reset"        => "Reset the DHCP server",
    "dhcp_set_option"   => "Set a DHCP server option",
    "dhcp_load_options" => "Load DHCP optionis from a datastore",
    "dhcp_log"          => "Log DHCP server activity"
  }

  reqs = {
    "dhcp_start"        => [ "lanattacks_start_dhcp" ],
    "dhcp_stop"         => [ "lanattacks_stop_dhcp" ],
    "dhcp_reset"        => [ "lanattacks_reset_dhcp" ],
    "dhcp_set_option"   => [ "lanattacks_set_dhcp_option" ],
    "dhcp_load_options" => [ "lanattacks_set_dhcp_option" ],
    "dhcp_log"          => [ "lanattacks_dhcp_log" ]
  }

  all.delete_if do |cmd, desc|
    del = false
    reqs[cmd].each do |req|
      next if client.commands.include? req
      del = true
      break
    end

    del
  end

  all
end
name() click to toggle source

Name for this dispatcher.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/dhcp.rb, line 58
def name
  "Lanattacks: DHCP"
end
print_dhcp_load_options_usage() click to toggle source
print_dhcp_log_usage() click to toggle source
print_dhcp_reset_usage() click to toggle source
print_dhcp_set_option_usage() click to toggle source
print_dhcp_start_usage() click to toggle source
print_dhcp_stop_usage() click to toggle source