Skip to content

Commit

Permalink
Improve setg SessionLogging support
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 committed Jul 24, 2024
1 parent 7348f55 commit 6a31ceb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/msf/base/sessions/command_shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions lib/msf/ui/console/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6a31ceb

Please sign in to comment.