updated webdriver to use selenium4 params

This commit is contained in:
wheatley
2023-09-30 19:03:13 +10:00
parent f359ad5283
commit 4dddb2d0f7
4 changed files with 4 additions and 151 deletions

View File

@@ -84,7 +84,7 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do
@driver = Selenium::WebDriver.for(:remote,
url: "http://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
desired_capabilities: @caps)
options: @caps)
# Hook new victim
print_info 'Hooking a new victim, waiting a few seconds...'
wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
@@ -96,16 +96,6 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do
sleep 1 until wait.until { @driver.execute_script('return window.beef.session.get_hook_session_id().length') > 0 }
@session = @driver.execute_script('return window.beef.session.get_hook_session_id()')
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
end
@@ -115,15 +105,5 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do
it 'AutoRunEngine is working' do
expect(@session).not_to be_nil
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script('return window.beef.session.get_hook_session_id()'))).to eq true
end
end
end

View File

@@ -78,7 +78,7 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do
@driver = Selenium::WebDriver.for(:remote,
url: "http://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
desired_capabilities: @caps)
options: @caps)
# Hook new victim
print_info 'Hooking a new victim, waiting a few seconds...'
wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
@@ -90,15 +90,6 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do
sleep 1 until wait.until { @driver.execute_script('return window.beef.session.get_hook_session_id().length') > 0 }
@session = @driver.execute_script('return window.beef.session.get_hook_session_id()')
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
end
@@ -108,16 +99,6 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do
it 'can successfully hook a browser' do
expect(@session).not_to be_nil
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script('return window.beef.session.get_hook_session_id()'))).to eq true
end
end
it 'browser details handler working' do
@@ -132,11 +113,5 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do
end
expect(@driver.browser.to_s.downcase).to eq(browser_name)
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace.each { |stack| puts stack }}"
exit 0
end
end

View File

@@ -74,7 +74,7 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do
@driver = Selenium::WebDriver.for(:remote,
url: "http://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
desired_capabilities: @caps)
options: @caps)
# Hook new victim
print_info 'Hooking a new victim, waiting a few seconds...'
wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
@@ -86,16 +86,6 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do
sleep 1 until wait.until { @driver.execute_script('return window.beef.session.get_hook_session_id().length') > 0 }
@session = @driver.execute_script('return window.beef.session.get_hook_session_id().length')
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
end
@@ -115,15 +105,5 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do
it 'can successfully hook a browser' do
expect(@session).not_to be_nil
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.stacktrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script('return window.beef.session.get_hook_session_id()'))).to eq true
end
end
end

View File

@@ -72,10 +72,9 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
@caps['name'] = self.class.description || ENV['name'] || 'no-name'
@caps['browserstack.local'] = true
@caps['browserstack.localIdentifier'] = ENV['BROWSERSTACK_LOCAL_IDENTIFIER']
@driver = Selenium::WebDriver.for(:remote,
url: "http://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
desired_capabilities: @caps)
options: @caps)
# Hook new victim
print_info 'Hooking a new victim, waiting a few seconds...'
wait = Selenium::WebDriver::Wait.new(timeout: 30) # seconds
@@ -119,16 +118,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Return ASCII Characters command module successfully executes' do
@@ -138,16 +127,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Return Image command module successfully executes' do
@@ -157,16 +136,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Test HTTP Redirect command module successfully executes' do
@@ -176,16 +145,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Test Returning Results/Long String command module successfully executes' do
@@ -196,17 +155,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
print_info "Exception Message: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Test Network Request command module successfully executes' do
@@ -224,16 +172,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Test DNS Tunnel command module successfully executes' do
@@ -244,16 +182,6 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
it 'The Test CORS Request command module successfully executes' do
@@ -267,15 +195,5 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do
content_type: :json
result_data = JSON.parse(response.body)
expect(result_data['success']).to eq 'true'
rescue StandardError => e
print_info "Exception: #{e}"
print_info "Exception Class: #{e.class}"
print_info "Exception Message: #{e.message}"
print_info "Exception Stack Trace: #{e.backtrace}"
if @driver.execute_script('return window.beef.session.get_hook_session_id().length').nil?
exit 1
else
exit 0
end
end
end