Path: blob/master/lib/rex/post/meterpreter/extensions/extapi/window/window.rb
19591 views
# -*- coding: binary -*-12module Rex3module Post4module Meterpreter5module Extensions6module Extapi7module Window89###10#11# This meterpreter extension contains extended API functions for12# querying and managing desktop windows.13#14###15class Window1617def initialize(client)18@client = client19end2021# Enumerate all the windows on the target.22# If the specified parent window is nil, then all top-level windows23# are enumerated. Otherwise, all child windows of the specified24# parent window are enumerated.25def enumerate(include_unknown = false, parent_window = nil)26request = Packet.create_request(COMMAND_ID_EXTAPI_WINDOW_ENUM)2728if include_unknown29request.add_tlv(TLV_TYPE_EXT_WINDOW_ENUM_INCLUDEUNKNOWN, true)30end3132if !parent_window.nil?33request.add_tlv(TLV_TYPE_EXT_WINDOW_ENUM_HANDLE, parent_window)34end3536response = client.send_request(request)3738windows = []3940response.each(TLV_TYPE_EXT_WINDOW_ENUM_GROUP) do |w|41windows << {42pid: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_PID),43handle: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_HANDLE),44title: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_TITLE),45class_name: w.get_tlv_value(TLV_TYPE_EXT_WINDOW_ENUM_CLASSNAME)46}47end4849windows.sort_by { |w| w[:pid] }50end5152attr_accessor :client5354end55end56end57end58end59end60end616263