Skip to content

Commit e0c6d1b

Browse files
authored
Land rapid7#19340, Improve setg SessionLogging support
2 parents 771e750 + 6a31ceb commit e0c6d1b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/msf/base/sessions/command_shell.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ def shell_command(cmd, timeout=5)
654654
def shell_read(length=-1, timeout=1)
655655
begin
656656
rv = rstream.get_once(length, timeout)
657+
rlog(rv, self.log_source) if rv && self.log_source
657658
framework.events.on_session_output(self, rv) if rv
658659
return rv
659660
rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e
@@ -672,6 +673,7 @@ def shell_write(buf)
672673
return unless buf
673674

674675
begin
676+
rlog(buf, self.log_source) if self.log_source
675677
framework.events.on_session_command(self, buf.strip)
676678
rstream.write(buf)
677679
rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e

lib/msf/ui/console/driver.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,16 @@ def run_unknown_command(command)
569569
def handle_session_logging(val)
570570
if (val =~ /^(y|t|1)/i)
571571
Msf::Logging.enable_session_logging(true)
572-
print_line("Session logging will be enabled for future sessions.")
572+
framework.sessions.values.each do |session|
573+
Msf::Logging.start_session_log(session)
574+
end
575+
print_line("Session logging enabled.")
573576
else
574577
Msf::Logging.enable_session_logging(false)
575-
print_line("Session logging will be disabled for future sessions.")
578+
framework.sessions.values.each do |session|
579+
Msf::Logging.stop_session_log(session)
580+
end
581+
print_line("Session logging disabled.")
576582
end
577583
end
578584

0 commit comments

Comments
 (0)