Skip to content

Commit

Permalink
killall with search lists table of killed sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Oct 4, 2023
1 parent 3f80f2d commit 8fe7b10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/msf/ui/console/command_dispatcher/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,9 @@ def cmd_sessions(*args)
return
end
print_status("Killing matching sessions...")
print_line
print(Serializer::ReadableText.dump_sessions(framework, show_active: show_active, show_inactive: show_inactive, show_extended: show_extended, verbose: verbose, session_ids: matching_sessions))
print_line
else
matching_sessions = framework.sessions
print_status("Killing all sessions...")
Expand Down
16 changes: 11 additions & 5 deletions spec/lib/msf/ui/console/command_dispatcher/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,19 @@ def set_tabs_test(option)
])
end

it "Killall should kill only the specified session" do
it "Killall should kill only the specified sessionS" do
expect(sessions[2]).to receive(:kill)
core.cmd_sessions("--search", "session_id:2", "-K")
core.cmd_sessions("--search", "session_id:2 session_id:3", "-K")
expect(@output.join("\n")).to match_table <<~TABLE
Killing matching sessions...
Active sessions
===============
expect(@output).to eq([
'Killing matching sessions...',
])
Id Name Type Information Connection
-- ---- ---- ----------- ----------
2 sesh2 meterpreter info tunnel (127.0.0.1)
3 sesh3 java info tunnel (127.0.0.1)
TABLE
end
end
end
Expand Down

0 comments on commit 8fe7b10

Please sign in to comment.