class Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Extapi::Wmi

Extended API WMI Querying interface.

Constants

DEFAULT_MAX_RESULTS

Zero indicates “no limit”

DEFAULT_PAGE_SIZE
Klass

Public Instance Methods

cmd_wmi_query(*args) click to toggle source

Enumerate WMI objects.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb, line 57
def cmd_wmi_query(*args)
  args.unshift("-h") if args.length < 1

  root = nil

  @@wmi_query_opts.parse(args) { |opt, idx, val|
    case opt
    when "-r"
      root = val
    when "-h"
      wmi_query_usage
      return true
    end
  }

  query = args.shift

  objects = client.extapi.wmi.query(query, root)

  if objects
    table = Rex::Ui::Text::Table.new(
      'Header'    => query,
      'Indent'    => 0,
      'SortIndex' => 0,
      'Columns'   => objects[:fields]
    )

    objects[:values].each do |c|
      table << c
    end

    print_line
    print_line(table.to_s)

    print_line("Total objects: #{objects[:values].length}")
  else
    print_status("The WMI query yielded no results.")
  end

  print_line

  return true
end
commands() click to toggle source

List of supported commands.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb, line 26
def commands
  {
    "wmi_query" => "Perform a generic WMI query and return the results"
  }
end
name() click to toggle source

Name for this dispatcher

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb, line 35
def name
  "Extapi: WMI Querying"
end
wmi_query_usage() click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/wmi.rb, line 47
def wmi_query_usage
  print(
    "\nUsage: wmi_query <query string> [-r root]\n\n" +
    "Query the target and display the results.\n\n" +
    @@wmi_query_opts.usage)
end