fixed up meterp, use is working
git-svn-id: file:///home/svn/incoming/trunk@2792 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
4679586c49
commit
45b1e69210
|
@ -25,6 +25,11 @@ class Meterpreter < Rex::Post::Meterpreter::Client
|
|||
def initialize(rstream)
|
||||
super
|
||||
|
||||
#
|
||||
# Initialize the meterpreter client
|
||||
#
|
||||
self.init_meterpreter(rstream)
|
||||
|
||||
#
|
||||
# Create the console instance
|
||||
#
|
||||
|
|
|
@ -31,6 +31,13 @@ class Client
|
|||
# Initializes the client context with the supplied socket through
|
||||
# which communication with the server will be performed
|
||||
def initialize(sock, to = self.class.default_timeout)
|
||||
init_meterpreter(sock, to)
|
||||
end
|
||||
|
||||
#
|
||||
# Initializes the meterpreter client instance
|
||||
#
|
||||
def init_meterpreter(sock, to = self.class.default_timeout)
|
||||
self.sock = sock
|
||||
self.parser = PacketParser.new
|
||||
self.ext = ObjectAliases.new
|
||||
|
@ -82,7 +89,7 @@ class Client
|
|||
# Loads the client half of the supplied extension and initializes it as a
|
||||
# registered extension that can be reached through client.ext.[extension].
|
||||
def add_extension(name)
|
||||
require("Rex/Post/Meterpreter/Extensions/#{name}/#{name}")
|
||||
require("rex/post/meterpreter/extensions/#{name.downcase}/#{name.downcase}")
|
||||
|
||||
# XXX might want to be safer and catch the exception here?
|
||||
# maybe not since we are just going to reraise right away...
|
||||
|
|
|
@ -126,9 +126,6 @@ class ClientCore < Extension
|
|||
Module
|
||||
The module that should be loaded
|
||||
|
||||
Modules
|
||||
The modules that should be loaded
|
||||
|
||||
LoadFromDisk
|
||||
Indicates that the library should be loaded from disk, not from
|
||||
memory on the remote machine
|
||||
|
@ -137,9 +134,19 @@ class ClientCore < Extension
|
|||
if (mod == nil)
|
||||
raise RuntimeError, "No modules were specified", caller
|
||||
end
|
||||
# Get us to the installation root and then into data/meterpreter, where
|
||||
# the file is expected to be
|
||||
path = File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'data/meterpreter/ext_server_' + mod.downcase + '.dll')
|
||||
|
||||
if (opts['ExtensionPath'])
|
||||
path = opts['ExtensionPath']
|
||||
end
|
||||
|
||||
path = File.expand_path(path)
|
||||
|
||||
# Load the extension DLL
|
||||
if (load_library(
|
||||
'LibraryFilePath' => 'Data/meterpreter/ext_server_' + mod.downcase + '.dll',
|
||||
'LibraryFilePath' => path,
|
||||
'UploadLibrary' => true,
|
||||
'Extension' => true,
|
||||
'SaveToDisk' => opts['LoadFromDisk']))
|
||||
|
@ -315,7 +322,7 @@ class ClientCore < Extension
|
|||
wrote = client.sock.write(inject_lib)
|
||||
|
||||
# Transmit the size of the server
|
||||
metsrv = "Data/meterpreter/metsrv.dll"
|
||||
metsrv = "data/meterpreter/metsrv.dll"
|
||||
buf = "metsrv.dll\x00" + ::IO.readlines(metsrv).join
|
||||
size = buf.length
|
||||
|
||||
|
|
|
@ -87,7 +87,11 @@ module PacketDispatcher
|
|||
# Spawn a new thread that monitors the socket
|
||||
thr = ::Thread.new {
|
||||
while (true)
|
||||
rv = select([ self.sock ], nil, nil, 2)
|
||||
begin
|
||||
rv = Rex::ThreadSafe.select([ self.sock.fd ], nil, nil, 2)
|
||||
rescue
|
||||
dlog("Exception caught in monitor_socket: #{$!}", 'meterpreter', LEV_1)
|
||||
end
|
||||
|
||||
begin
|
||||
packet = receive_packet
|
||||
|
|
|
@ -19,6 +19,7 @@ class Console
|
|||
include Rex::Ui::Text::DispatcherShell
|
||||
|
||||
# Dispatchers
|
||||
require 'rex/post/meterpreter/ui/console/command_dispatcher'
|
||||
require 'rex/post/meterpreter/ui/console/core'
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
module Rex
|
||||
module Post
|
||||
module Meterpreter
|
||||
module Ui
|
||||
|
||||
###
|
||||
#
|
||||
# CommandDispatcher
|
||||
# -----------------
|
||||
#
|
||||
# Base class for all command dispatchers within the meterpreter console user
|
||||
# interface.
|
||||
#
|
||||
###
|
||||
module Console::CommandDispatcher
|
||||
|
||||
include Rex::Ui::Text::DispatcherShell::CommandDispatcher
|
||||
|
||||
#
|
||||
# Returns the meterpreter client context
|
||||
#
|
||||
def client
|
||||
shell.client
|
||||
end
|
||||
|
||||
#
|
||||
# Log that an error occurred
|
||||
#
|
||||
def log_error(msg)
|
||||
print_error(msg)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,7 +15,7 @@ module Ui
|
|||
###
|
||||
class Console::Core
|
||||
|
||||
include Rex::Ui::Text::DispatcherShell::CommandDispatcher
|
||||
include Console::CommandDispatcher
|
||||
|
||||
@@use_opts = Rex::Parser::Arguments.new(
|
||||
"-m" => [ true, "The name of the module or modules to load (Ex: stdapi)." ],
|
||||
|
@ -49,17 +49,36 @@ class Console::Core
|
|||
args.unshift("-h")
|
||||
end
|
||||
|
||||
modules = nil
|
||||
|
||||
@@use_opts.parse(args) { |opt, idx, val|
|
||||
case opt
|
||||
when "-m"
|
||||
mod = val
|
||||
modules = val.split(/,\s?/)
|
||||
when "-h"
|
||||
print(
|
||||
"Usage: use [options]\n\n" +
|
||||
"Loads a meterpreter extension module or modules.\n" +
|
||||
@use_opts.usage)
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
||||
# Load each of the modules
|
||||
modules.each { |m|
|
||||
print("Loading extension #{m}...")
|
||||
|
||||
begin
|
||||
client.core.use(m)
|
||||
rescue
|
||||
log_error("failure: #{$!}")
|
||||
next
|
||||
end
|
||||
|
||||
print_line("success.")
|
||||
}
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue