Skip to content

Commit 7ac5b6d

Browse files
committed
Fix prompt and color issue with cmd_spool
Changing spool setting caused problems with prompt and color. This fix makes the following changes: - Saves the color setting and re-applies it to the new output console - Sets the prompt in the same way that cmd_use does
1 parent c8c331c commit 7ac5b6d

File tree

1 file changed

+14
-4
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,14 +1503,24 @@ def cmd_spool(*args)
15031503
return
15041504
end
15051505

1506+
color = driver.output.config[:color]
1507+
15061508
if args[0] == "off"
15071509
driver.init_ui(driver.input, Rex::Ui::Text::Output::Stdio.new)
1508-
print_status("Spooling is now disabled")
1509-
return
1510+
msg = "Spooling is now disabled"
1511+
else
1512+
driver.init_ui(driver.input, Rex::Ui::Text::Output::Tee.new(args[0]))
1513+
msg = "Spooling to file #{args[0]}..."
15101514
end
15111515

1512-
driver.init_ui(driver.input, Rex::Ui::Text::Output::Tee.new(args[0]))
1513-
print_status("Spooling to file #{args[0]}...")
1516+
# Restore color and prompt
1517+
driver.output.config[:color] = color
1518+
prompt = framework.datastore['Prompt'] || Msf::Ui::Console::Driver::DefaultPrompt
1519+
prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar
1520+
driver.update_prompt("#{prompt} #{active_module.type}(%bld%red#{active_module.shortname}%clr) ", prompt_char, true)
1521+
1522+
print_status(msg)
1523+
return
15141524
end
15151525

15161526
def cmd_sessions_help

0 commit comments

Comments
 (0)