Class: Rex::Post::Meterpreter::Extensions::Extapi::Window::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/extapi/window/window.rb

Overview

This meterpreter extension contains extended API functions for querying and managing desktop windows.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Window

Returns a new instance of Window.


18
19
20
# File 'lib/rex/post/meterpreter/extensions/extapi/window/window.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


53
54
55
# File 'lib/rex/post/meterpreter/extensions/extapi/window/window.rb', line 53

def client
  @client
end

Instance Method Details

#enumerate(include_unknown = false, parent_window = nil) ⇒ Object

Enumerate all the windows on the target. If the specified parent window is nil, then all top-level windows are enumerated. Otherwise, all child windows of the specified parent window are enumerated.


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rex/post/meterpreter/extensions/extapi/window/window.rb', line 26

def enumerate(include_unknown = false, parent_window = nil)
  request = Packet.create_request(COMMAND_ID_EXTAPI_WINDOW_ENUM)

  if include_unknown
    request.add_tlv(TLV_TYPE_EXT_WINDOW_ENUM_INCLUDEUNKNOWN, true)
  end

  if !parent_window.nil?
    request.add_tlv(TLV_TYPE_EXT_WINDOW_ENUM_HANDLE, parent_window)
  end

  response = client.send_request(request)

  windows = []

  response.each(TLV_TYPE_EXT_WINDOW_ENUM_GROUP) do |w|
    windows << {
      pid: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_PID),
      handle: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_HANDLE),
      title: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_TITLE),
      class_name: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_CLASSNAME)
    }
  end

  windows.sort_by { |w| w[:pid] }
end