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

Extended API window management user interface.

Constants

Klass

Public Instance Methods

cmd_window_enum(*args) click to toggle source

Enumerate top-level windows.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/window.rb, line 60
def cmd_window_enum(*args)
  parent_window = nil
  include_unknown = false

  @@window_enum_opts.parse(args) { |opt, idx, val|
    case opt
    when "-u"
      include_unknown = true
    when "-p"
      parent_window = val.to_i
      if parent_window == 0
        window_enum_usage
        return true
      end
    when "-h"
      window_enum_usage
      return true
    end
  }

  windows = client.extapi.window.enumerate(include_unknown, parent_window)

  header = parent_window ? "Child windows of #{parent_window}" : "Top-level windows"

  table = Rex::Ui::Text::Table.new(
    'Header'    => header,
    'Indent'    => 0,
    'SortIndex' => 0,
    'Columns'   => [
      'PID', 'Handle', 'Title'
    ]
  )

  windows.each { |w|
    table << [w[:pid], w[:handle], w[:title]]
  }

  print_line
  print_line(table.to_s)

  if parent_window.nil?
    print_line("Total top-level Windows: #{windows.length}")
  else
    print_line("Total child Windows: #{windows.length}")
  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/window.rb, line 22
def commands
  {
    "window_enum" => "Enumerate all current open windows"
  }
end
name() click to toggle source

Name for this dispatcher

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/window.rb, line 31
def name
  "Extapi: Window Management"
end
window_enum_usage() click to toggle source
# File lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/window.rb, line 44
def window_enum_usage
  print(
    "\nUsage: window_enum [-h] [-p parent_window] [-u]\n\n" +
    "Enumerate the windows on the target.\n\n" +
    "Enumeration returns the Process ID and Window Handle for each window\n" +
    "found. The Window Handle can be used for further calls to window_enum\n" +
    "or the railgun API.\n" +
    @@window_enum_opts.usage +
    "Note: Not all windows can be enumerated. An attempt to enumerate\n" +
    "      the children of such a window will result in a failure with the\n"+
    "      message \"Operation failed: The parameter is incorrect.\"\n\n")
end