Land #10687, add pry command to meterpreter.

4.x
Green-m 2018-09-22 13:10:57 +08:00 committed by Metasploit
parent 62dacb3d1e
commit 0c88820fce
No known key found for this signature in database
GPG Key ID: CDFB5FA52007B954
2 changed files with 49 additions and 5 deletions

View File

@ -112,14 +112,28 @@ class Msf::Ui::Console::CommandDispatcher::Developer
# Open a Pry session on the current module or Framework
#
def cmd_pry(*args)
begin
require 'pry'
rescue LoadError
print_error("Failed to load Pry, try 'gem install pry'")
if args.include?('-h')
cmd_pry_help
return
end
active_module ? active_module.pry : framework.pry
begin
require 'pry'
rescue LoadError
print_error('Failed to load Pry, try "gem install pry"')
return
end
print_status('Starting Pry shell...')
unless active_module
print_status("You are in the \"framework\" object\n")
framework.pry
return
end
print_status("You are in #{active_module.fullname}\n")
active_module.pry
end
def cmd_edit_help

View File

@ -53,6 +53,7 @@ class Console::CommandDispatcher::Core
'exit' => 'Terminate the meterpreter session',
'help' => 'Help menu',
'irb' => 'Drop into irb scripting mode',
'pry' => 'Open a Pry session on the current session',
'use' => 'Deprecated alias for "load"',
'load' => 'Load one or more meterpreter extensions',
'machine_id' => 'Get the MSF ID of the machine attached to the session',
@ -570,6 +571,35 @@ class Console::CommandDispatcher::Core
end
end
def cmd_pry_help
print_line 'Usage: pry'
print_line
print_line 'Open a Pry session on the current session.'
print_line
end
#
# Open a Pry session on the current session
#
def cmd_pry(*args)
if args.include?('-h')
cmd_pry_help
return
end
begin
require 'pry'
rescue LoadError
print_error('Failed to load Pry, try "gem install pry"')
return
end
print_status('Starting Pry shell...')
print_status("You are in the \"client\" (session) object\n")
client.pry
end
@@set_timeouts_opts = Rex::Parser::Arguments.new(
'-c' => [true, 'Comms timeout (seconds)'],
'-x' => [true, 'Expiration timout (seconds)'],