diff --git a/lib/msf/base/sessions/command_shell.rb b/lib/msf/base/sessions/command_shell.rb index b14fa26240d8..c606e85ace67 100644 --- a/lib/msf/base/sessions/command_shell.rb +++ b/lib/msf/base/sessions/command_shell.rb @@ -654,6 +654,7 @@ def shell_command(cmd, timeout=5) def shell_read(length=-1, timeout=1) begin rv = rstream.get_once(length, timeout) + rlog(rv, self.log_source) if rv && self.log_source framework.events.on_session_output(self, rv) if rv return rv rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e @@ -672,6 +673,7 @@ def shell_write(buf) return unless buf begin + rlog(buf, self.log_source) if self.log_source framework.events.on_session_command(self, buf.strip) rstream.write(buf) rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 6ecfbb365cce..bce665b24eb9 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -569,10 +569,16 @@ def run_unknown_command(command) def handle_session_logging(val) if (val =~ /^(y|t|1)/i) Msf::Logging.enable_session_logging(true) - print_line("Session logging will be enabled for future sessions.") + framework.sessions.values.each do |session| + Msf::Logging.start_session_log(session) + end + print_line("Session logging enabled.") else Msf::Logging.enable_session_logging(false) - print_line("Session logging will be disabled for future sessions.") + framework.sessions.values.each do |session| + Msf::Logging.stop_session_log(session) + end + print_line("Session logging disabled.") end end