Skip to content

Commit d00f6a8

Browse files
author
HD Moore
committed
Rework verbose sessions listing to work around table limits
1 parent 8ca66e0 commit d00f6a8

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

lib/msf/base/serializer/readable_text.rb

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ def self.dump_sessions(framework, opts={})
527527
indent = opts[:indent] || DefaultIndent
528528
col = opts[:col] || DefaultColumnWrap
529529

530+
return dump_sessions_verbose(framework, opts) if verbose
531+
530532
columns =
531533
[
532534
'Id',
@@ -535,10 +537,6 @@ def self.dump_sessions(framework, opts={})
535537
'Connection'
536538
]
537539

538-
columns << 'Via' if verbose
539-
columns << 'CheckIn' if verbose
540-
columns << 'PayloadId' if verbose
541-
542540
tbl = Rex::Ui::Text::Table.new(
543541
'Indent' => indent,
544542
'Header' => "Active sessions",
@@ -558,22 +556,65 @@ def self.dump_sessions(framework, opts={})
558556
row[1] << (" " + session.platform)
559557
end
560558

561-
if verbose
562-
row << session.via_exploit.to_s
563-
if session.respond_to?(:last_checkin) && session.last_checkin
564-
row << "#{(Time.now.to_i - session.last_checkin.to_i)}s"
565-
else
566-
row << ''
567-
end
568-
row << session.payload_uuid.to_s
569-
end
570-
571559
tbl << row
572560
}
573561

574562
return framework.sessions.length > 0 ? tbl.to_s : "#{tbl.header_to_s}No active sessions.\n"
575563
end
576564

565+
# Dumps the list of active sessions in verbose mode
566+
#
567+
# @param framework [Msf::Framework] the framework to dump.
568+
# @param opts [Hash] the options to dump with.
569+
# @option opts :session_ids [Array] the list of sessions to dump (no
570+
# effect).
571+
# @return [String] the formatted list of sessions.
572+
def self.dump_sessions_verbose(framework, opts={})
573+
ids = (opts[:session_ids] || framework.sessions.keys).sort
574+
575+
out = "Active sessions\n" +
576+
"===============\n\n"
577+
578+
if framework.sessions.length == 0
579+
out << "No active sessions.\n"
580+
return out
581+
end
582+
583+
framework.sessions.each_sorted do |k|
584+
session = framework.sessions[k]
585+
586+
sess_info = session.info.to_s
587+
sess_id = session.sid.to_s
588+
sess_tunnel = session.tunnel_to_s + " (#{session.session_host})"
589+
sess_via = session.via_exploit.to_s
590+
sess_type = session.type.to_s
591+
sess_uuid = session.payload_uuid.to_s
592+
sess_checkin = "<none>"
593+
sess_machine_id = session.machine_id.to_s
594+
595+
if session.respond_to? :platform
596+
sess_type << (" " + session.platform)
597+
end
598+
599+
if session.respond_to?(:last_checkin) && session.last_checkin
600+
sess_checkin = "#{(Time.now.to_i - session.last_checkin.to_i)}s Ago @ #{session.last_checkin.to_s}"
601+
end
602+
603+
out << " Session ID: #{sess_id}\n"
604+
out << " Type: #{sess_type}\n"
605+
out << " Info: #{sess_info}\n"
606+
out << " Tunnel: #{sess_tunnel}\n"
607+
out << " Via: #{sess_via}\n"
608+
out << " UUID: #{sess_uuid}\n"
609+
out << " MachineID: #{sess_machine_id}\n"
610+
out << " CheckIn: #{sess_checkin}\n"
611+
out << "\n"
612+
end
613+
614+
out << "\n"
615+
return out
616+
end
617+
577618
# Dumps the list of running jobs.
578619
#
579620
# @param framework [Msf::Framework] the framework.

0 commit comments

Comments
 (0)