diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index 5b20981a9c..b93cd55bc0 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -524,20 +524,18 @@ class ReadableText def self.dump_sessions(framework, opts={}) ids = (opts[:session_ids] || framework.sessions.keys).sort verbose = opts[:verbose] || false - extended = opts[:extended] || false + show_checkin = opts[:show_checkin] || false indent = opts[:indent] || DefaultIndent col = opts[:col] || DefaultColumnWrap return dump_sessions_verbose(framework, opts) if verbose - columns = - [ - 'Id', - 'Type', - 'Information', - 'Connection' - ] - columns << 'Checkin?' if extended + columns = [] + columns << 'Id' + columns << 'Type' + columns << 'Checkin?' if show_checkin + columns << 'Information' + columns << 'Connection' tbl = Rex::Ui::Text::Table.new( 'Indent' => indent, @@ -553,12 +551,12 @@ class ReadableText sinfo = sinfo[0,77] + "..." end - row = [ session.sid.to_s, session.type.to_s, sinfo, session.tunnel_to_s + " (#{session.session_host})" ] - if session.respond_to?(:platform) - row[1] << (" " + session.platform) - end + row = [] + row << session.sid.to_s + row << session.type.to_s + row[-1] << (" " + session.platform) if session.respond_to?(:platform) - if extended + if show_checkin if session.respond_to?(:last_checkin) && session.last_checkin row << "#{(Time.now.to_i - session.last_checkin.to_i)}s ago" else @@ -566,6 +564,9 @@ class ReadableText end end + row << sinfo + row << session.tunnel_to_s + " (#{session.session_host})" + tbl << row } diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index e129744ff3..d5080f9f40 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -35,11 +35,11 @@ class Core # Session command options @@sessions_opts = Rex::Parser::Arguments.new( "-c" => [ true, "Run a command on the session given with -i, or all" ], + "-ci" => [ false, "Show the last checkin time in the session table" ], "-h" => [ false, "Help banner" ], "-i" => [ true, "Interact with the supplied session ID " ], "-l" => [ false, "List all active sessions" ], - "-v" => [ false, "List extended fields" ], - "-vv" => [ false, "Render in verbose mode" ], + "-v" => [ false, "List sessions in verbose mode" ], "-q" => [ false, "Quiet mode" ], "-k" => [ true, "Terminate sessions by session ID and/or range" ], "-K" => [ false, "Terminate all sessions" ], @@ -1760,7 +1760,7 @@ class Core begin method = nil quiet = false - extended = false + show_checkin = false verbose = false sid = nil cmds = [] @@ -1781,9 +1781,9 @@ class Core when "-c" method = 'cmd' cmds << val if val + when "-ci" + show_checkin = true when "-v" - extended = true - when "-vv" verbose = true # Do something with the supplied session identifier instead of # all sessions. @@ -2045,7 +2045,7 @@ class Core end when 'list',nil print_line - print(Serializer::ReadableText.dump_sessions(framework, :extended => extended, :verbose => verbose)) + print(Serializer::ReadableText.dump_sessions(framework, :show_checkin => show_checkin, :verbose => verbose)) print_line end