Added additional logic to handle inconsistencies in test results

This commit is contained in:
Jack Walker
2020-04-30 09:42:55 +10:00
parent 334cbf895f
commit dc80537693
3 changed files with 27 additions and 21 deletions

View File

@@ -92,19 +92,21 @@ RSpec.describe 'AutoRunEngine Test', :run_on_browserstack => true do
print_info 'Hooking a new victim, waiting a few seconds...'
@driver.navigate.to "#{VICTIM_URL}"
sleep 20
sleep 1
# Give time for browser hook to occur
wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds
wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
sleep 20
sleep 1 until wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
if RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}".code != 200
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
else
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
@session = @hooks['hooked-browsers']['online']['0']['session']
else
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
end
end
end

View File

@@ -89,19 +89,21 @@ RSpec.describe 'Browser Details Handler', :run_on_browserstack => true do
print_info 'Hooking a new victim, waiting a few seconds...'
@driver.navigate.to "#{VICTIM_URL}"
sleep 20
sleep 1
# Give time for browser hook to occur
wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds
wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
sleep 1 until wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
sleep 20
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
if RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}".code != 200
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
else
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
@session = @hooks['hooked-browsers']['online']['0']['session']
else
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
end
end
end

View File

@@ -88,19 +88,21 @@ RSpec.describe 'BeEF Debug Command Modules:', :run_on_browserstack => true do
print_info 'Hooking a new victim, waiting a few seconds...'
@driver.navigate.to "#{VICTIM_URL}"
sleep 20
sleep 1
# Give time for browser hook to occur
wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds
wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
sleep 20
sleep 1 until wait.until { @driver.execute_script("return window.beef.session.get_hook_session_id().length") > 0}
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
if RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}".code != 200
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
else
@session = @hooks['hooked-browsers']['online']['0']['session']
@hooks = JSON.parse(RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}")
if @hooks['hooked-browsers']['online'].empty?
@session = @hooks['hooked-browsers']['online']['0']['session']
else
@session = @driver.execute_script("return window.beef.session.get_hook_session_id()")
end
end
# Grab Command Module IDs as they can differ from machine to machine