added migrate ui

git-svn-id: file:///home/svn/incoming/trunk@2820 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Miller 2005-07-23 05:13:27 +00:00
parent 005ecfab97
commit 360260ee90
7 changed files with 54 additions and 23 deletions

3
documentation/bugs Normal file
View File

@ -0,0 +1,3 @@
meterpreter
- migration sometimes does partial reads of stages leading to crashes
- should switch to inlined staging in request packet.

View File

@ -142,7 +142,7 @@ class ClientCore < Extension
path = opts['ExtensionPath']
end
path = File.expand_path(path)
path = ::File.expand_path(path)
# Load the extension DLL
if (load_library(
@ -334,7 +334,7 @@ class ClientCore < Extension
wrote = client.sock.write(buf)
# Re-load the STDAPI extension server-side
client.core.use('Stdapi')
client.core.use('stdapi')
### ###
### TEMPORARY ###

View File

@ -118,7 +118,6 @@ module PacketDispatcher
begin
packet = receive_packet
rescue EOFError
puts "EOF reached on socket\n"
break
end

View File

@ -69,7 +69,6 @@ class PacketParser
# TODO: cipher decryption
if (cipher)
puts "TODO: decryption\n"
end
# Serialize the packet from the raw buffer

View File

@ -75,9 +75,11 @@ class Console
begin
super
rescue TimeoutError
output.print_line("Operation timed out.")
output.print_error("Operation timed out.")
rescue RequestError => info
output.print_line(info.to_s)
output.print_error(info.to_s)
rescue
output.print_error("Error running command #{method}: #{$!}")
end
end

View File

@ -21,6 +21,7 @@ class Console::CommandDispatcher::Core
super
self.extensions = []
self.ext_hash = {}
end
@@use_opts = Rex::Parser::Arguments.new(
@ -31,11 +32,12 @@ class Console::CommandDispatcher::Core
#
def commands
{
"?" => "Help menu",
"exit" => "Terminate the meterpreter session",
"help" => "Help menu",
"use" => "Load a one or more meterpreter extensions",
"quit" => "Terminate the meterpreter session",
"?" => "Help menu",
"exit" => "Terminate the meterpreter session",
"help" => "Help menu",
"migrate" => "Migrate the server to another process",
"use" => "Load a one or more meterpreter extensions",
"quit" => "Terminate the meterpreter session",
}
end
@ -62,6 +64,30 @@ class Console::CommandDispatcher::Core
print(shell.help_to_s)
end
alias cmd_? cmd_help
#
# Migrates the server to the supplied process identifier.
#
def cmd_migrate(*args)
if (args.length == 0)
print_line(
"Usage: migrate pid\n\n" +
"Migrates the server instance to another process.\n" +
"Note: Any open channels or other dynamic state will be lost.")
return true
end
pid = args[0].to_i
print_status("Migrating to #{pid}...")
# Do this thang.
client.core.migrate(pid)
print_status("Migration completed successfully.")
end
#
# Loads one or more meterpreter extensions
#
@ -112,7 +138,7 @@ class Console::CommandDispatcher::Core
protected
attr_accessor :extensions
attr_accessor :extensions, :ext_hash
CommDispatcher = Console::CommandDispatcher
@ -122,20 +148,22 @@ protected
def add_extension_client(mod)
clirb = File.join(Rex::Root, "post/meterpreter/ui/console/command_dispatcher/#{mod}.rb")
old = CommDispatcher.constants
old = CommDispatcher.constants
require(clirb)
if (require(clirb) == true)
new = CommDispatcher.constants
diff = new - old
if (diff.empty? == true)
print_error("Failed to load client portion of #{mod}.")
return false
end
new = CommDispatcher.constants
diff = new - old
if (diff.empty? == true)
print_error("Failed to load client portion of #{mod}.")
return false
self.ext_hash[mod] = CommDispatcher.const_get(diff[0])
end
# Create the dispatcher
klass = CommDispatcher.const_get(diff[0])
klass = self.ext_hash[mod]
# Enstack the dispatcher
self.shell.enstack_dispatcher(klass)

View File

@ -125,7 +125,7 @@ class Console::CommandDispatcher::Stdapi::Sys
#
def cmd_kill(*args)
if (args.length == 0)
print(
print_line(
"Usage: kill pid1 pid2 pid3 ...\n\n" +
"Terminate one or more processes.")
return true