Sha256: 2fb604eaed3b5c80420f286ecc4cfc1e98643e195bc3f82547d643c95cc54d28

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# -*- coding: binary -*-

module Rex
module Post
module Meterpreter
module Extensions
module Extapi
module Window

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

  def initialize(client)
    @client = client
  end

  # 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.
  def enumerate(include_unknown = false, parent_window = nil)
    request = Packet.create_request('extapi_window_enum')

    if include_unknown
      request.add_tlv(TLV_TYPE_EXT_WINDOW_ENUM_INCLUDEUNKNOWN, true)
    end

    if not 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) { |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)
      }
    }

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

  attr_accessor :client

end

end; end; end; end; end; end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.12 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.11 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.10 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.9 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.8 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.7 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.5 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.4 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
dstruct-0.0.1 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.3 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
librex-0.0.999 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
rex-2.0.2 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
librex-0.0.71 lib/rex/post/meterpreter/extensions/extapi/window/window.rb
librex-0.0.70 lib/rex/post/meterpreter/extensions/extapi/window/window.rb