2005-07-18 04:07:56 +00:00
|
|
|
require 'rex/ui'
|
|
|
|
require 'rex/post/meterpreter'
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Post
|
2005-07-18 05:13:21 +00:00
|
|
|
module Meterpreter
|
|
|
|
module Ui
|
2005-07-18 04:07:56 +00:00
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Console
|
|
|
|
# -------
|
|
|
|
#
|
|
|
|
# This class provides a shell driven interface to the meterpreter client API.
|
|
|
|
#
|
|
|
|
###
|
2005-07-18 05:13:21 +00:00
|
|
|
class Console
|
2005-07-18 04:07:56 +00:00
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
include Rex::Ui::Text::DispatcherShell
|
2005-07-18 04:07:56 +00:00
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
# Dispatchers
|
2005-07-18 05:59:27 +00:00
|
|
|
require 'rex/post/meterpreter/ui/console/command_dispatcher'
|
2005-07-18 07:46:54 +00:00
|
|
|
require 'rex/post/meterpreter/ui/console/command_dispatcher/core'
|
2005-07-18 04:07:56 +00:00
|
|
|
|
|
|
|
#
|
2005-07-18 05:13:21 +00:00
|
|
|
# Initialize the meterpreter console
|
2005-07-18 04:07:56 +00:00
|
|
|
#
|
2005-07-18 05:13:21 +00:00
|
|
|
def initialize(client)
|
2005-07-18 07:46:54 +00:00
|
|
|
super("%umeterpreter%c")
|
2005-07-18 04:07:56 +00:00
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
# The meterpreter client context
|
|
|
|
self.client = client
|
|
|
|
|
|
|
|
# Point the input/output handles elsewhere
|
|
|
|
reset_ui
|
|
|
|
|
2005-07-18 07:46:54 +00:00
|
|
|
enstack_dispatcher(Console::CommandDispatcher::Core)
|
2005-07-18 04:07:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Called when someone wants to interact with the meterpreter client. It's
|
|
|
|
# assumed that init_ui has been called prior.
|
|
|
|
#
|
|
|
|
def interact(&block)
|
2005-07-18 05:13:21 +00:00
|
|
|
run { |line|
|
|
|
|
# Run the command
|
|
|
|
run_single(line)
|
2005-07-18 04:07:56 +00:00
|
|
|
|
|
|
|
# If a block was supplied, call it, otherwise return false
|
|
|
|
if (block)
|
|
|
|
block.call
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
attr_reader :client
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
attr_writer :client
|
|
|
|
|
2005-07-18 04:07:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2005-07-18 05:13:21 +00:00
|
|
|
end
|
|
|
|
end
|