Skip to content

Commit 2a6a833

Browse files
author
kernelsmith
committed
prompt fixes (restores prompt context) & normalization
Msf::Ui::Console::Driver::DefaultPrompt and Msf::Ui::Console::Driver::Default should be used when default is desired
1 parent ad8516e commit 2a6a833

File tree

1 file changed

+10
-5
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+10
-5
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,8 +2294,8 @@ def cmd_use(*args)
22942294
mod.init_ui(driver.input, driver.output)
22952295

22962296
# Update the command prompt
2297-
prompt = framework.datastore['Prompt'] || "%undmsf%clr "
2298-
prompt_char = framework.datastore['PromptChar'] || ">"
2297+
prompt = framework.datastore['Prompt'] || Msf::Ui::Console::Driver::DefaultPrompt
2298+
prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar
22992299
driver.update_prompt("#{prompt} #{mod.type}(%bld%red#{mod.shortname}%clr) ", prompt_char, true)
23002300
end
23012301

@@ -2515,8 +2515,13 @@ def temp_output.write(msg = '')
25152515
# restore the prompt so we don't get "msf > >".
25162516
prompt = framework.datastore['Prompt'] || Msf::Ui::Console::Driver::DefaultPrompt
25172517
prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar
2518-
driver.update_prompt("#{prompt}", prompt_char, true)
2519-
#@todo restore the prompt context
2518+
mod = active_module
2519+
if mod # if there is an active module, give them the fanciness they have come to expect
2520+
driver.update_prompt("#{prompt} #{mod.type}(%bld%red#{mod.shortname}%clr) ", prompt_char, true)
2521+
else
2522+
driver.update_prompt("#{prompt}", prompt_char, true)
2523+
end
2524+
25202525
# dump the command's output so we can grep it
25212526
cmd_output = temp_output.dump_buffer
25222527
# put lines into an array so we can access them more easily and split('\n') doesn't work on the output obj.
@@ -2895,7 +2900,7 @@ def show_global_options
28952900
[ 'MinimumRank', framework.datastore['MinimumRank'] || '', 'The minimum rank of exploits that will run without explicit confirmation' ],
28962901
[ 'SessionLogging', framework.datastore['SessionLogging'] || '', 'Log all input and output for sessions' ],
28972902
[ 'TimestampOutput', framework.datastore['TimestampOutput'] || '', 'Prefix all console output with a timestamp' ],
2898-
[ 'Prompt', framework.datastore['Prompt'] || '', 'The prompt string, defaults to "%undmsf%clr"' ],
2903+
[ 'Prompt', framework.datastore['Prompt'] || '', 'The prompt string, defaults to "#{Msf::Ui::Console::Driver::DefaultPrompt}"' ],
28992904
[ 'PromptChar', framework.datastore['PromptChar'] || '', 'The prompt character, defaults to ">"' ],
29002905
[ 'PromptTimeFormat', framework.datastore['PromptTimeFormat'] || '', 'A format for timestamp escapes in the prompt, see ruby\'s strftime docs' ],
29012906
].each { |r| tbl << r }

0 commit comments

Comments
 (0)