From 8fd71d66e053673e7c96a10eadb556fc5acff87e Mon Sep 17 00:00:00 2001 From: Jack Walker Date: Thu, 23 Apr 2020 13:51:46 +1000 Subject: [PATCH] Running an API call prior to grabbing session - possibly keep-alive polling bug experienced in other areas is present here. --- .../extensions/websocket_hooked_browser_spec.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index 79bcb36ac..2adb93372 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -74,14 +74,18 @@ RSpec.describe 'BeEF WebSockets: Browser Hooking', :run_on_browserstack => true # Hook new victim print_info 'Hooking a new victim, waiting a few seconds...' @driver.navigate.to "#{VICTIM_URL}" + puts @driver.current_url # Give time for browser hook to occur sleep 2 - puts @driver.current_url - - @hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}") - @session = @hooks['hooked-browsers']['online'] + # Grab Command Module IDs as they can differ from machine to machine + @debug_mod_ids = JSON.parse(RestClient.get "#{RESTAPI_MODULES}?token=#{@token}") + @debug_mod_names_ids = {} + @debug_mods = @debug_mod_ids.to_a.select { |cmd_mod| cmd_mod[1]['category'] == 'Debug' } + .map do |debug_mod| + @debug_mod_names_ids[debug_mod[1]['class']] = debug_mod[0] + end end after(:all) do @@ -99,8 +103,9 @@ RSpec.describe 'BeEF WebSockets: Browser Hooking', :run_on_browserstack => true #prepare for the HTTP model https = BeEF::Core::Models::Http - puts @hooks - puts @session + @hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}") + @session = @hooks['hooked-browsers']['online'] + expect(@session).not_to be_empty https.where(:hooked_browser_id => @session['0']['session']).delete_all