diff --git a/lib/msf/ui/console/command_dispatcher/developer.rb b/lib/msf/ui/console/command_dispatcher/developer.rb index ee3c1ba4c3530..c18505e42fdf1 100644 --- a/lib/msf/ui/console/command_dispatcher/developer.rb +++ b/lib/msf/ui/console/command_dispatcher/developer.rb @@ -112,14 +112,28 @@ def cmd_pry_help # Open a Pry session on the current module or Framework # 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'") + 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 - active_module ? active_module.pry : framework.pry + print_status("You are in #{active_module.fullname}\n") + active_module.pry end def cmd_edit_help diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb index bc52066bb7453..352f6b6865fbf 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb @@ -53,7 +53,7 @@ def commands 'exit' => 'Terminate the meterpreter session', 'help' => 'Help menu', 'irb' => 'Drop into irb scripting mode', - 'pry' => 'Open a Pry session on the client object', + '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', @@ -574,21 +574,29 @@ def cmd_irb(*args) def cmd_pry_help print_line 'Usage: pry' print_line - print_line 'Open a Pry session on the client object.' + print_line 'Open a Pry session on the current session.' print_line end # - # Open a Pry session on the client object + # 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'") + 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