Class: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Stdapi::Ui
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Stdapi::Ui
- Defined in:
- lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb
Overview
The user interface portion of the standard API extension.
Constant Summary collapse
- Klass =
Console::CommandDispatcher::Stdapi::Ui
Instance Attribute Summary
Attributes included from Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#cmd_enumdesktops(*args) ⇒ Object
Enumerate desktops.
-
#cmd_getdesktop(*args) ⇒ Object
Get the current meterpreter desktop.
-
#cmd_idletime(*args) ⇒ Object
Executes a command with some options.
-
#cmd_keyscan_dump(*args) ⇒ Object
Dump captured keystrokes.
-
#cmd_keyscan_start(*args) ⇒ Object
Start the keyboard sniffer.
-
#cmd_keyscan_stop(*args) ⇒ Object
Stop the keyboard sniffer.
-
#cmd_screenshot(*args) ⇒ Object
Grab a screenshot of the current interactive desktop.
-
#cmd_setdesktop(*args) ⇒ Object
Change the meterpreters current desktop.
-
#cmd_uictl(*args) ⇒ Object
Enables/disables user interface mice and keyboards on the remote machine.
-
#cmd_unlockdesktop(*args) ⇒ Object
Unlock or lock the desktop.
-
#commands ⇒ Object
List of supported commands.
-
#name ⇒ Object
Name for this dispatcher.
Methods included from Rex::Post::Meterpreter::Ui::Console::CommandDispatcher
check_hash, #client, #initialize, #log_error, #msf_loaded?, set_hash
Methods included from Ui::Text::DispatcherShell::CommandDispatcher
#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #help_to_s, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_filenames, #update_prompt
Instance Method Details
#cmd_enumdesktops(*args) ⇒ Object
Enumerate desktops
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 177 def cmd_enumdesktops(*args) print_line( "Enumerating all accessible desktops" ) desktops = client.ui.enum_desktops desktopstable = Rex::Ui::Text::Table.new( 'Header' => "Desktops", 'Indent' => 4, 'Columns' => [ "Session", "Station", "Name" ] ) desktops.each { | desktop | session = desktop['session'] == 0xFFFFFFFF ? '' : desktop['session'].to_s desktopstable << [ session, desktop['station'], desktop['name'] ] } if( desktops.length == 0 ) print_line( "No accessible desktops were found." ) else print( "\n" + desktopstable.to_s + "\n" ) end return true end |
#cmd_getdesktop(*args) ⇒ Object
Get the current meterpreter desktop.
208 209 210 211 212 213 214 215 216 217 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 208 def cmd_getdesktop(*args) desktop = client.ui.get_desktop session = desktop['session'] == 0xFFFFFFFF ? '' : "Session #{desktop['session'].to_s}\\" print_line( "#{session}#{desktop['station']}\\#{desktop['name']}" ) return true end |
#cmd_idletime(*args) ⇒ Object
Executes a command with some options.
77 78 79 80 81 82 83 84 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 77 def cmd_idletime(*args) seconds = client.ui.idle_time print_line( "User has been idle for: #{Rex::ExtTime.sec_to_s(seconds)}") return true end |
#cmd_keyscan_dump(*args) ⇒ Object
Dump captured keystrokes
305 306 307 308 309 310 311 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 305 def cmd_keyscan_dump(*args) print_line("Dumping captured keystrokes...") data = client.ui.keyscan_dump print_line(client.ui.keyscan_extract(data)) return true end |
#cmd_keyscan_start(*args) ⇒ Object
Start the keyboard sniffer
287 288 289 290 291 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 287 def cmd_keyscan_start(*args) print_line("Starting the keystroke sniffer...") client.ui.keyscan_start return true end |
#cmd_keyscan_stop(*args) ⇒ Object
Stop the keyboard sniffer
296 297 298 299 300 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 296 def cmd_keyscan_stop(*args) print_line("Stopping the keystroke sniffer...") client.ui.keyscan_stop return true end |
#cmd_screenshot(*args) ⇒ Object
Grab a screenshot of the current interactive desktop.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 129 def cmd_screenshot( *args ) path = Rex::Text.rand_text_alpha(8) + ".jpeg" quality = 50 view = false screenshot_opts = Rex::Parser::Arguments.new( "-h" => [ false, "Help Banner." ], "-q" => [ true, "The JPEG image quality (Default: '#{quality}')" ], "-p" => [ true, "The JPEG image path (Default: '#{path}')" ], "-v" => [ true, "Automatically view the JPEG image (Default: '#{view}')" ] ) screenshot_opts.parse( args ) { | opt, idx, val | case opt when "-h" print_line( "Usage: screenshot [options]\n" ) print_line( "Grab a screenshot of the current interactive desktop." ) print_line( screenshot_opts.usage ) return when "-q" quality = val.to_i when "-p" path = val when "-v" view = false if ( val =~ /^(f|n|0)/i ) end } data = client.ui.screenshot( quality ) if( data ) ::File.open( path, 'wb' ) do |fd| fd.write( data ) end path = ::File.( path ) print_line( "Screenshot saved to: #{path}" ) Rex::Compat.open_file( path ) if view end return true end |
#cmd_setdesktop(*args) ⇒ Object
Change the meterpreters current desktop.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 222 def cmd_setdesktop( *args ) switch = false dsession = -1 dstation = 'WinSta0' dname = 'Default' setdesktop_opts = Rex::Parser::Arguments.new( "-h" => [ false, "Help Banner." ], #"-s" => [ true, "The session (Default: '#{dsession}')" ], "-w" => [ true, "The window station (Default: '#{dstation}')" ], "-n" => [ true, "The desktop name (Default: '#{dname}')" ], "-i" => [ true, "Set this desktop as the interactive desktop (Default: '#{switch}')" ] ) setdesktop_opts.parse( args ) { | opt, idx, val | case opt when "-h" print_line( "Usage: setdesktop [options]\n" ) print_line( "Change the meterpreters current desktop." ) print_line( setdesktop_opts.usage ) return #when "-s" # dsession = val.to_i when "-w" dstation = val when "-n" dname = val when "-i" switch = true if ( val =~ /^(t|y|1)/i ) end } if( client.ui.set_desktop( dsession, dstation, dname, switch ) ) print_line( "#{ switch ? 'Switched' : 'Changed' } to desktop #{dstation}\\#{dname}" ) else print_line( "Failed to #{ switch ? 'switch' : 'change' } to desktop #{dstation}\\#{dname}" ) end return true end |
#cmd_uictl(*args) ⇒ Object
Enables/disables user interface mice and keyboards on the remote machine.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 89 def cmd_uictl(*args) if (args.length < 2) print_line( "Usage: uictl [enable/disable] [keyboard/mouse]") return true end case args[0] when 'enable' case args[1] when 'keyboard' print_line("Enabling keyboard...") client.ui.enable_keyboard when 'mouse' print_line("Enabling mouse...") client.ui.enable_mouse else print_error("Unsupported user interface device: #{args[1]}") end when 'disable' case args[1] when 'keyboard' print_line("Disabling keyboard...") client.ui.disable_keyboard when 'mouse' print_line("Disabling mouse...") client.ui.disable_mouse else print_error("Unsupported user interface device: #{args[1]}") end else print_error("Unsupported command: #{args[0]}") end return true end |
#cmd_unlockdesktop(*args) ⇒ Object
Unlock or lock the desktop
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 267 def cmd_unlockdesktop(*args) mode = 0 if(args.length > 0) mode = args[0].to_i end if(mode == 0) print_line("Unlocking the workstation...") client.ui.unlock_desktop(true) else print_line("Locking the workstation...") client.ui.unlock_desktop(false) end return true end |
#commands ⇒ Object
List of supported commands.
23 24 25 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 23 def commands all = { "enumdesktops" => "List all accessible desktops and window stations", "getdesktop" => "Get the current meterpreter desktop", "idletime" => "Returns the number of seconds the remote user has been idle", "keyscan_dump" => "Dump the keystroke buffer", "keyscan_start" => "Start capturing keystrokes", "keyscan_stop" => "Stop capturing keystrokes", "screenshot" => "Grab a screenshot of the interactive desktop", "setdesktop" => "Change the meterpreters current desktop", "uictl" => "Control some of the user interface components" # not working yet # "unlockdesktop" => "Unlock or lock the workstation (must be inside winlogon.exe)", } reqs = { "enumdesktops" => [ "stdapi_ui_desktop_enum" ], "getdesktop" => [ "stdapi_ui_desktop_get" ], "idletime" => [ "stdapi_ui_get_idle_time" ], "keyscan_dump" => [ "stdapi_ui_get_keys" ], "keyscan_start" => [ "stdapi_ui_start_keyscan" ], "keyscan_stop" => [ "stdapi_ui_stop_keyscan" ], "screenshot" => [ "stdapi_ui_desktop_screenshot" ], "setdesktop" => [ "stdapi_ui_desktop_set" ], "uictl" => [ "stdapi_ui_enable_mouse", "stdapi_ui_enable_keyboard" ] } all.delete_if do |cmd, desc| del = false reqs[cmd].each do |req| next if client.commands.include? req del = true break end del end all end |
#name ⇒ Object
Name for this dispatcher.
70 71 72 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb', line 70 def name "Stdapi: User interface" end |