Rework verbose sessions listing to work around table limits
parent
8ca66e03aa
commit
d00f6a8fdf
|
@ -527,6 +527,8 @@ class ReadableText
|
|||
indent = opts[:indent] || DefaultIndent
|
||||
col = opts[:col] || DefaultColumnWrap
|
||||
|
||||
return dump_sessions_verbose(framework, opts) if verbose
|
||||
|
||||
columns =
|
||||
[
|
||||
'Id',
|
||||
|
@ -535,10 +537,6 @@ class ReadableText
|
|||
'Connection'
|
||||
]
|
||||
|
||||
columns << 'Via' if verbose
|
||||
columns << 'CheckIn' if verbose
|
||||
columns << 'PayloadId' if verbose
|
||||
|
||||
tbl = Rex::Ui::Text::Table.new(
|
||||
'Indent' => indent,
|
||||
'Header' => "Active sessions",
|
||||
|
@ -558,22 +556,65 @@ class ReadableText
|
|||
row[1] << (" " + session.platform)
|
||||
end
|
||||
|
||||
if verbose
|
||||
row << session.via_exploit.to_s
|
||||
if session.respond_to?(:last_checkin) && session.last_checkin
|
||||
row << "#{(Time.now.to_i - session.last_checkin.to_i)}s"
|
||||
else
|
||||
row << ''
|
||||
end
|
||||
row << session.payload_uuid.to_s
|
||||
end
|
||||
|
||||
tbl << row
|
||||
}
|
||||
|
||||
return framework.sessions.length > 0 ? tbl.to_s : "#{tbl.header_to_s}No active sessions.\n"
|
||||
end
|
||||
|
||||
# Dumps the list of active sessions in verbose mode
|
||||
#
|
||||
# @param framework [Msf::Framework] the framework to dump.
|
||||
# @param opts [Hash] the options to dump with.
|
||||
# @option opts :session_ids [Array] the list of sessions to dump (no
|
||||
# effect).
|
||||
# @return [String] the formatted list of sessions.
|
||||
def self.dump_sessions_verbose(framework, opts={})
|
||||
ids = (opts[:session_ids] || framework.sessions.keys).sort
|
||||
|
||||
out = "Active sessions\n" +
|
||||
"===============\n\n"
|
||||
|
||||
if framework.sessions.length == 0
|
||||
out << "No active sessions.\n"
|
||||
return out
|
||||
end
|
||||
|
||||
framework.sessions.each_sorted do |k|
|
||||
session = framework.sessions[k]
|
||||
|
||||
sess_info = session.info.to_s
|
||||
sess_id = session.sid.to_s
|
||||
sess_tunnel = session.tunnel_to_s + " (#{session.session_host})"
|
||||
sess_via = session.via_exploit.to_s
|
||||
sess_type = session.type.to_s
|
||||
sess_uuid = session.payload_uuid.to_s
|
||||
sess_checkin = "<none>"
|
||||
sess_machine_id = session.machine_id.to_s
|
||||
|
||||
if session.respond_to? :platform
|
||||
sess_type << (" " + session.platform)
|
||||
end
|
||||
|
||||
if session.respond_to?(:last_checkin) && session.last_checkin
|
||||
sess_checkin = "#{(Time.now.to_i - session.last_checkin.to_i)}s Ago @ #{session.last_checkin.to_s}"
|
||||
end
|
||||
|
||||
out << " Session ID: #{sess_id}\n"
|
||||
out << " Type: #{sess_type}\n"
|
||||
out << " Info: #{sess_info}\n"
|
||||
out << " Tunnel: #{sess_tunnel}\n"
|
||||
out << " Via: #{sess_via}\n"
|
||||
out << " UUID: #{sess_uuid}\n"
|
||||
out << " MachineID: #{sess_machine_id}\n"
|
||||
out << " CheckIn: #{sess_checkin}\n"
|
||||
out << "\n"
|
||||
end
|
||||
|
||||
out << "\n"
|
||||
return out
|
||||
end
|
||||
|
||||
# Dumps the list of running jobs.
|
||||
#
|
||||
# @param framework [Msf::Framework] the framework.
|
||||
|
|
Loading…
Reference in New Issue