Skip to content

Commit 0b29408

Browse files
committed
Allow filtering of loot
1 parent ee3e354 commit 0b29408

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ def report_loot(opts)
99
end
1010
end
1111

12-
def loots(wspace, non_dead = false, addresses = nil)
12+
def loots(wspace, opts = {})
1313
begin
1414
data_service = self.get_data_service
15-
opts = {}
1615
opts[:wspace] = wspace
17-
opts[:non_dead] = non_dead
18-
opts[:addresses] = addresses
1916
data_service.loot(opts)
2017
rescue Exception => e
2118
puts "Call to #{data_service.class}#loots threw exception: #{e.message}"

lib/msf/core/db_manager/loot.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def find_or_create_loot(opts)
2525
# This methods returns a list of all loot in the database
2626
#
2727
def loots(opts)
28-
wspace = opts[:workspace] || opts[:wspace] || workspace
28+
wspace = opts.delete(:workspace) || opts.delete(:wspace) || workspace
2929
if wspace.kind_of? String
3030
wspace = find_workspace(wspace)
3131
end
3232

3333
::ActiveRecord::Base.connection_pool.with_connection {
34-
wspace.loots
34+
wspace.loots.where(opts)
3535
}
3636
end
3737
alias_method :loot, :loots

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,9 @@ def cmd_loot(*args)
12721272

12731273
each_host_range_chunk(host_ranges) do |host_search|
12741274
framework.db.hosts(framework.db.workspace, false, host_search).each do |host|
1275-
if host.loots
1276-
host.loots.each do |loot|
1275+
loots = framework.db.loots(framework.db.workspace, {:host_id => host.id})
1276+
if loots
1277+
loots.each do |loot|
12771278
next if(types and types.index(loot.ltype).nil?)
12781279
if search_term
12791280
next unless(
@@ -1307,9 +1308,8 @@ def cmd_loot(*args)
13071308

13081309
# Handle hostless loot
13091310
if host_ranges.compact.empty? # Wasn't a host search
1310-
hostless_loot = framework.db.loot(framework.db.workspace)
1311+
hostless_loot = framework.db.loots(framework.db.workspace, {:host_id => nil})
13111312
hostless_loot.each do |loot|
1312-
next unless loot.host_id = nil
13131313
row = []
13141314
row.push("")
13151315
row.push("")

0 commit comments

Comments
 (0)