Skip to content

Commit 2a6a824

Browse files
committed
Allow killing multiple specific sessions
1 parent c765100 commit 2a6a824

File tree

1 file changed

+10
-6
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+10
-6
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Core
4141
"-v" => [ false, "List verbose fields" ],
4242
"-q" => [ false, "Quiet mode" ],
4343
"-d" => [ true, "Detach an interactive session" ],
44-
"-k" => [ true, "Terminate session" ],
44+
"-k" => [ true, "Terminate sessions by session ID and/or range" ],
4545
"-K" => [ false, "Terminate all sessions" ],
4646
"-s" => [ true, "Run a script on the session given with -i, or all"],
4747
"-r" => [ false, "Reset the ring buffer for the session given with -i, or all"],
@@ -1708,11 +1708,15 @@ def cmd_sessions(*args)
17081708
end
17091709

17101710
when 'kill'
1711-
if ((session = framework.sessions.get(sid)))
1712-
print_status("Killing session #{sid}")
1713-
session.kill
1714-
else
1715-
print_error("Invalid session identifier: #{sid}")
1711+
session_list = build_sessions_array(sid)
1712+
print_status("Killing the following session(s): #{session_list}")
1713+
session_list.each do |sess|
1714+
if ((session = framework.sessions.get(sess)))
1715+
print_status("Killing session #{sess}")
1716+
session.kill
1717+
else
1718+
print_error("Invalid session identifier: #{sess}")
1719+
end
17161720
end
17171721

17181722
when 'killall'

0 commit comments

Comments
 (0)