From 9e0ccf71bb509932ba66e574003b09b9ef6a7517 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Thu, 4 Feb 2016 00:49:29 +0000 Subject: [PATCH] Change /api/modules/multi_browser to accept 'ALL_ONLINE' for 'hb_ids' --- core/main/rest/handlers/modules.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/main/rest/handlers/modules.rb b/core/main/rest/handlers/modules.rb index 50b782bc2..d597189e1 100644 --- a/core/main/rest/handlers/modules.rb +++ b/core/main/rest/handlers/modules.rb @@ -159,6 +159,7 @@ module BeEF #@note Fire a new command module to multiple hooked browsers. # Returns the command IDs of the launched module, or 0 if firing got issues. # Use "hb_ids":["ALL"] to run on all hooked browsers + # Use "hb_ids":["ALL_ONLINE"] to run on all hooked browsers currently online # # POST request body example (for modules that don't need parameters, just remove "mod_params") # { @@ -194,8 +195,13 @@ module BeEF hb_ids = body["hb_ids"] results = Hash.new + # run on all hooked browsers currently online? + if hb_ids.first =~ /\Aall_online\z/i + hb_ids = [] + BeEF::Core::Models::HookedBrowser.all( + :lastseen.gte => (Time.new.to_i - 15)).each {|hb| hb_ids << hb.id } # run on all hooked browsers? - if hb_ids.first =~ /\Aall\z/i + elsif hb_ids.first =~ /\Aall\z/i hb_ids = [] BeEF::Core::Models::HookedBrowser.all.each {|hb| hb_ids << hb.id } end