Changed how websocket hooked browsers time out

This commit is contained in:
Grant Burgess
2020-04-02 15:39:30 +10:00
parent 803fd6d3e7
commit 89b9c53239

View File

@@ -3,6 +3,7 @@
# Browser Exploitation Framework (BeEF) - http://beefproject.com # Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission # See the file 'doc/COPYING' for copying permission
# #
require 'byebug'
module BeEF module BeEF
module Core module Core
@@ -22,11 +23,18 @@ module BeEF
# #
# @note Get online and offline hooked browsers details (like name, version, os, ip, port, ...) # @note Get online and offline hooked browsers details (like name, version, os, ip, port, ...)
# When websockets are enabled this will allow the ws_poll_timeout config to be used to check if the browser is online or not.
# #
get '/' do get '/' do
online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - 15))) if config.get('beef.http.websocket.enable') == false
offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', (Time.new.to_i - 15))) online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - 15)))
offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', (Time.new.to_i - 15)))
else
timeout = (config.get('beef.http.websocket.ws_poll_timeout').to_i / 1000) + 5
online_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen >= ?', (Time.new.to_i - timeout)))
offline_hooks = hb_to_json(BeEF::Core::Models::HookedBrowser.where('lastseen <= ?', (Time.new.to_i - timeout)))
end
output = { output = {
'hooked-browsers' => { 'hooked-browsers' => {
'online' => online_hooks, 'online' => online_hooks,