From 92e03ba62b3e4dde2b01b82cb2c89c76ea0c868d Mon Sep 17 00:00:00 2001 From: Stephen Date: Mon, 25 Mar 2024 17:12:19 +1000 Subject: [PATCH 01/11] remove excess comments --- spec/beef/core/main/command_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/beef/core/main/command_spec.rb b/spec/beef/core/main/command_spec.rb index e03b4336a7..ad68e9a656 100644 --- a/spec/beef/core/main/command_spec.rb +++ b/spec/beef/core/main/command_spec.rb @@ -1,9 +1,4 @@ RSpec.describe 'BeEF Command class testing' do - before(:each) do - # Reset or re-initialise the configuration to a default state - # @config_instance = BeEF::Core::Configuration.instance - end - it 'should return a beef configuration variable' do expect { BeEF::Modules.load if BeEF::Core::Configuration.instance.get('beef.module').nil? From 0fb4805c44be724e88d1697c1e18d0f88ee0bc82 Mon Sep 17 00:00:00 2001 From: Stephen Date: Tue, 26 Mar 2024 06:53:33 +1000 Subject: [PATCH 02/11] fixed login helper function --- spec/support/beef_test.rb | 48 ++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/spec/support/beef_test.rb b/spec/support/beef_test.rb index ad41558eaa..a3cfe78fe1 100644 --- a/spec/support/beef_test.rb +++ b/spec/support/beef_test.rb @@ -3,29 +3,51 @@ # Browser Exploitation Framework (BeEF) - https://beefproject.com # See the file 'doc/COPYING' for copying permission # -require 'test/unit' - +require 'selenium-webdriver' +require 'spec_helper' require 'capybara' require 'capybara/rspec' Capybara.run_server = false # we need to run our own BeEF server -require 'selenium-webdriver' - class BeefTest - def self.save_screenshot(session) - Dir.mkdir(BEEF_TEST_DIR) unless File.directory?(BEEF_TEST_DIR) - session.driver.browser.save_screenshot(BEEF_TEST_DIR + Time.now.strftime('%Y-%m-%d--%H-%M-%S-%N') + '.png') + def self.save_screenshot(session, dir = nil) + outputDir = dir || BEEF_TEST_DIR + Dir.mkdir(outputDir) unless File.directory?(outputDir) + session.driver.browser.save_screenshot(outputDir + Time.now.strftime('%Y-%m-%d--%H-%M-%S-%N') + '.png') end def self.login(session = nil) session = Capybara::Session.new(:selenium_headless) if session.nil? session.visit(ATTACK_URL) - sleep 2.0 - session.has_content?('BeEF Authentication') - session.fill_in 'user', with: BEEF_USER - session.fill_in 'pass', with: BEEF_PASSWD - session.click_button('Login') - sleep 10.0 + + session.has_content?('Authentication', wait: 10) + save_screenshot(session) + + # enter the credentials + session.execute_script("document.getElementById('pass').value = '#{CGI.escapeHTML(BEEF_PASSWD)}'\;") + session.execute_script("document.getElementById('user').value = '#{CGI.escapeHTML(BEEF_USER)}'\;") + + # due to using JS there seems to be a race condition - this is a workaround + session.has_content?('beef', wait: 10) + + # click the login button + login_script = <<-JAVASCRIPT + var loginButton; + var buttons = document.getElementsByTagName('button'); + for (var i = 0; i < buttons.length; i++) { + if (buttons[i].textContent === 'Login') { + loginButton = buttons[i]; + break; + } + } + if (loginButton) { + loginButton.click(); + } + JAVASCRIPT + session.execute_script(login_script) + + session.has_content?('Hooked Browsers', wait: 10) + save_screenshot(session) session end From c51c0fca6d29f5b3a4104772ff070b5b076552ed Mon Sep 17 00:00:00 2001 From: Stephen Date: Tue, 26 Mar 2024 19:03:50 +1000 Subject: [PATCH 03/11] added boiler plate --- spec/spec_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6858b3bb43..898c10fbdc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'core/loader.rb' # @note We need to load variables that 'beef' usually does for us From 712201d9099e9a970ff068778966eb5be84b5e3b Mon Sep 17 00:00:00 2001 From: Stephen Date: Tue, 26 Mar 2024 19:04:58 +1000 Subject: [PATCH 04/11] fixed logout helper and cleaned up code --- spec/requests/beef_test_spec.rb | 81 +++++++++++++++++++++++++++++++++ spec/support/beef_test.rb | 5 +- 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 spec/requests/beef_test_spec.rb diff --git a/spec/requests/beef_test_spec.rb b/spec/requests/beef_test_spec.rb new file mode 100644 index 0000000000..6626bcd3ae --- /dev/null +++ b/spec/requests/beef_test_spec.rb @@ -0,0 +1,81 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +require 'spec_helper' +require 'capybara/rspec' +require_relative '../support/beef_test' + +RSpec.describe BeefTest do + let(:session) { Capybara::Session.new(:selenium) } + let(:victim) { Capybara::Session.new(:selenium) } + + before(:each) do + @pid = start_beef_server_and_wait + end + + after(:each) do + # Shutting down server + Process.kill("KILL", @pid) unless @pid.nil? + Process.wait(@pid) unless @pid.nil? # Ensure the process has exited and the port is released + @pid = nil + end + + describe '.login' do + it 'logs in successfully' do + expect(port_available?) # Check if the tcp port is open + session = BeefTest.login() + expect(session).not_to be_nil + expect(session.has_content?('Hooked Browsers', wait: 10)) + end + end + + describe '.logout' do + before(:each) do + expect(port_available?) # # Check if the tcp port is open + @session = BeefTest.login() # Ensure login before each '.logout' test + expect(@session.has_content?('Hooked Browsers', wait: 10)) + end + + it 'logs out successfully' do + expect(port_available?) # # Check if the tcp port is open + expect(@session.has_content?('Hooked Browsers', wait: 10)) + + # Log out of the session + @sessoin = BeefTest.logout(@session) + expect(@session.has_no_content?('Hooked Browsers', wait: 10)) + expect(@session.has_content?('Authentication', wait: 10)) + end + end + + describe '.save_screenshot' do + it 'saves a screenshot' do + session = Capybara::Session.new(:selenium_headless) if session.nil? + + # Ensure the new directory does not exist + outputDir = '/tmp' + directory = "#{outputDir}/#{SecureRandom.hex}/" + expect(File.directory?(directory)).to be false + + # Save the screenshot + BeefTest.save_screenshot(session, directory) + + # Ensure the screenshot was saved + expect(File.directory?(directory)).to be true + screenshot_files = Dir.glob("#{directory}/*.png") + expect(screenshot_files.empty?).to be false + + # Ensure the screenshot file is not empty and clean up + screenshot_files.each do |file| + expect(File.size(file)).to be > 0 + File.delete(file) + end + expect(Dir.glob("#{directory}/*.png").empty?).to be true + + # Remove the directory + Dir.delete(directory) + expect(File.directory?(directory)).to be false + end + end +end diff --git a/spec/support/beef_test.rb b/spec/support/beef_test.rb index a3cfe78fe1..7db058326c 100644 --- a/spec/support/beef_test.rb +++ b/spec/support/beef_test.rb @@ -21,7 +21,6 @@ def self.login(session = nil) session.visit(ATTACK_URL) session.has_content?('Authentication', wait: 10) - save_screenshot(session) # enter the credentials session.execute_script("document.getElementById('pass').value = '#{CGI.escapeHTML(BEEF_PASSWD)}'\;") @@ -47,13 +46,13 @@ def self.login(session = nil) session.execute_script(login_script) session.has_content?('Hooked Browsers', wait: 10) - save_screenshot(session) session end def self.logout(session) - session.click_link('Logout') + session.click_on('Logout') + session.has_content?('Authentication', wait: 10) session end From f0bb5ed2d63230ba9021cd0aaed20ce3dfbab7a0 Mon Sep 17 00:00:00 2001 From: Stephen Date: Wed, 27 Mar 2024 18:50:13 +1000 Subject: [PATCH 05/11] added boiler plate --- spec/beef/extensions/adminui_spec.rb | 9 +++++---- spec/beef/extensions/dns_spec.rb | 5 +++++ spec/beef/extensions/network_spec.rb | 5 +++++ spec/beef/extensions/proxy_spec.rb | 5 +++++ spec/beef/extensions/qrcode_spec.rb | 5 +++++ spec/beef/extensions/requester_spec.rb | 5 +++++ spec/beef/extensions/social_engineering_spec.rb | 5 +++++ spec/beef/extensions/webrtc_spec.rb | 5 +++++ spec/beef/extensions/websocket_hooked_browser_spec.rb | 1 - spec/beef/extensions/websocket_spec.rb | 5 +++++ spec/beef/extensions/xssrays_spec.rb | 6 ++++++ 11 files changed, 51 insertions(+), 5 deletions(-) diff --git a/spec/beef/extensions/adminui_spec.rb b/spec/beef/extensions/adminui_spec.rb index d8f954c1b9..bddbc8c09b 100644 --- a/spec/beef/extensions/adminui_spec.rb +++ b/spec/beef/extensions/adminui_spec.rb @@ -1,7 +1,8 @@ -# -# Tests for handling access to the Admin UI -# - +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/admin_ui/classes/httpcontroller' require 'extensions/admin_ui/classes/session' require 'extensions/admin_ui/controllers/authentication/authentication' diff --git a/spec/beef/extensions/dns_spec.rb b/spec/beef/extensions/dns_spec.rb index 91bb1634e3..ffec46bb72 100644 --- a/spec/beef/extensions/dns_spec.rb +++ b/spec/beef/extensions/dns_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'resolv' require 'extensions/dns/extension.rb' diff --git a/spec/beef/extensions/network_spec.rb b/spec/beef/extensions/network_spec.rb index 1d5029db36..a85d0c57bd 100644 --- a/spec/beef/extensions/network_spec.rb +++ b/spec/beef/extensions/network_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/network/models/network_service' require 'extensions/network/models/network_host' diff --git a/spec/beef/extensions/proxy_spec.rb b/spec/beef/extensions/proxy_spec.rb index 3f4f690b85..4f2cae3389 100644 --- a/spec/beef/extensions/proxy_spec.rb +++ b/spec/beef/extensions/proxy_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/proxy/extension' RSpec.describe 'BeEF Extension Proxy' do diff --git a/spec/beef/extensions/qrcode_spec.rb b/spec/beef/extensions/qrcode_spec.rb index d06453c602..c1086d4c64 100644 --- a/spec/beef/extensions/qrcode_spec.rb +++ b/spec/beef/extensions/qrcode_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/qrcode/extension' RSpec.describe 'BeEF Extension QRCode' do diff --git a/spec/beef/extensions/requester_spec.rb b/spec/beef/extensions/requester_spec.rb index 8d2a151350..6a92982241 100644 --- a/spec/beef/extensions/requester_spec.rb +++ b/spec/beef/extensions/requester_spec.rb @@ -1,5 +1,10 @@ require 'extensions/requester/extension' +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# RSpec.describe 'BeEF Extension Requester' do before(:all) do @config = BeEF::Core::Configuration.instance diff --git a/spec/beef/extensions/social_engineering_spec.rb b/spec/beef/extensions/social_engineering_spec.rb index d664e40e1d..8ccc500261 100644 --- a/spec/beef/extensions/social_engineering_spec.rb +++ b/spec/beef/extensions/social_engineering_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/social_engineering/models/web_cloner' require 'extensions/social_engineering/web_cloner/web_cloner' require 'extensions/social_engineering/web_cloner/interceptor' diff --git a/spec/beef/extensions/webrtc_spec.rb b/spec/beef/extensions/webrtc_spec.rb index 6108638257..f42f2d09e5 100644 --- a/spec/beef/extensions/webrtc_spec.rb +++ b/spec/beef/extensions/webrtc_spec.rb @@ -1,5 +1,10 @@ require 'rest-client' +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# RSpec.describe 'BeEF Extension WebRTC' do before(:all) do @config = BeEF::Core::Configuration.instance diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index 8ed4e9a976..774cf1447b 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -3,7 +3,6 @@ # Browser Exploitation Framework (BeEF) - https://beefproject.com # See the file 'doc/COPYING' for copying permission # - require 'rest-client' require 'json' require_relative '../../spec_helper' diff --git a/spec/beef/extensions/websocket_spec.rb b/spec/beef/extensions/websocket_spec.rb index b701496c90..ffab4bfa84 100644 --- a/spec/beef/extensions/websocket_spec.rb +++ b/spec/beef/extensions/websocket_spec.rb @@ -1,3 +1,8 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'rest-client' require 'core/main/network_stack/websocket/websocket' require 'websocket-client-simple' diff --git a/spec/beef/extensions/xssrays_spec.rb b/spec/beef/extensions/xssrays_spec.rb index 114bc7339f..4715f890b9 100644 --- a/spec/beef/extensions/xssrays_spec.rb +++ b/spec/beef/extensions/xssrays_spec.rb @@ -1,3 +1,9 @@ + +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# require 'extensions/xssrays/extension' RSpec.describe 'BeEF Extension XSSRays' do From 24a25d6e6ac0c5855bfaa4eaa2fc352263a5838d Mon Sep 17 00:00:00 2001 From: Stephen Date: Wed, 27 Mar 2024 18:53:56 +1000 Subject: [PATCH 06/11] tidy BeefTest and add more test cases --- spec/requests/beef_test_spec.rb | 38 +++++++++++++++++++++++++++++++-- spec/support/beef_test.rb | 11 +++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/spec/requests/beef_test_spec.rb b/spec/requests/beef_test_spec.rb index 6626bcd3ae..56c18adaa1 100644 --- a/spec/requests/beef_test_spec.rb +++ b/spec/requests/beef_test_spec.rb @@ -8,8 +8,6 @@ require_relative '../support/beef_test' RSpec.describe BeefTest do - let(:session) { Capybara::Session.new(:selenium) } - let(:victim) { Capybara::Session.new(:selenium) } before(:each) do @pid = start_beef_server_and_wait @@ -20,6 +18,7 @@ Process.kill("KILL", @pid) unless @pid.nil? Process.wait(@pid) unless @pid.nil? # Ensure the process has exited and the port is released @pid = nil + end describe '.login' do @@ -46,6 +45,7 @@ @sessoin = BeefTest.logout(@session) expect(@session.has_no_content?('Hooked Browsers', wait: 10)) expect(@session.has_content?('Authentication', wait: 10)) + @session.reset_session! end end @@ -78,4 +78,38 @@ expect(File.directory?(directory)).to be false end end + + let(:session) { Capybara::Session.new(:selenium_headless) } + let(:victim) { Capybara::Session.new(:selenium_headless) } + + describe '.new_attacker' do + it 'creates a new attacker session' do + # # Test setup + expect(session).not_to be_nil + + result = BeefTest.new_attacker(session) + + # Test assertions + expect(result).to eq(session) + expect(session.has_no_content?('Authentication', wait: 10)) + expect(session.has_content?('Hooked Browsers', wait: 10)) + session.reset_session! + end + end + + describe '.new_victim' do + it 'creates a new victim session' do + # Test setup + allow(victim).to receive(:visit) + expect(victim).not_to be_nil + + # Test execution + result = BeefTest.new_victim(victim) + + # Test assertions + expect(victim).to have_received(:visit).with(VICTIM_URL) + expect(result).to eq(victim) + victim.reset_session! + end + end end diff --git a/spec/support/beef_test.rb b/spec/support/beef_test.rb index 7db058326c..094b38af81 100644 --- a/spec/support/beef_test.rb +++ b/spec/support/beef_test.rb @@ -13,7 +13,8 @@ class BeefTest def self.save_screenshot(session, dir = nil) outputDir = dir || BEEF_TEST_DIR Dir.mkdir(outputDir) unless File.directory?(outputDir) - session.driver.browser.save_screenshot(outputDir + Time.now.strftime('%Y-%m-%d--%H-%M-%S-%N') + '.png') + filename = outputDir + Time.now.strftime('%Y-%m-%d--%H-%M-%S-%N') + '.png' + session.driver.browser.save_screenshot(filename) end def self.login(session = nil) @@ -57,12 +58,12 @@ def self.logout(session) session end - def self.new_attacker - self.login + def self.new_attacker(session = nil) + self.login(session) end - def self.new_victim - victim = Capybara::Session.new(:selenium_headless) + def self.new_victim(victim = nil) + victim = Capybara::Session.new(:selenium_headless) if victim.nil? victim.visit(VICTIM_URL) victim end From aaf4c582350fed30c62e44df9bb76fdcbc8041e1 Mon Sep 17 00:00:00 2001 From: Stephen Date: Wed, 27 Mar 2024 18:57:28 +1000 Subject: [PATCH 07/11] tidy unused file --- test/thirdparty/msf/unit/check_environment.rb | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 test/thirdparty/msf/unit/check_environment.rb diff --git a/test/thirdparty/msf/unit/check_environment.rb b/test/thirdparty/msf/unit/check_environment.rb deleted file mode 100644 index ff1a9b7b2f..0000000000 --- a/test/thirdparty/msf/unit/check_environment.rb +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net -# Browser Exploitation Framework (BeEF) - https://beefproject.com -# See the file 'doc/COPYING' for copying permission -# -require 'test/unit' - -class TC_CheckEnvironment < Test::Unit::TestCase - - def test_check_env - # Add environment checks here - - end - -end From 83015d0a40f549cf5c65ed87a71e9cc0ed617e44 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 28 Mar 2024 03:07:43 +1000 Subject: [PATCH 08/11] tidy unused --- test/integration/check_environment.rb | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 test/integration/check_environment.rb diff --git a/test/integration/check_environment.rb b/test/integration/check_environment.rb deleted file mode 100644 index ff1a9b7b2f..0000000000 --- a/test/integration/check_environment.rb +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net -# Browser Exploitation Framework (BeEF) - https://beefproject.com -# See the file 'doc/COPYING' for copying permission -# -require 'test/unit' - -class TC_CheckEnvironment < Test::Unit::TestCase - - def test_check_env - # Add environment checks here - - end - -end From dba210c109af99483568189ec53f1dce5f98e3a2 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 28 Mar 2024 03:08:32 +1000 Subject: [PATCH 09/11] tidy login_spec file --- spec/requests/login_spec.rb | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 spec/requests/login_spec.rb diff --git a/spec/requests/login_spec.rb b/spec/requests/login_spec.rb new file mode 100644 index 0000000000..79f00cab32 --- /dev/null +++ b/spec/requests/login_spec.rb @@ -0,0 +1,78 @@ +# +# Copyright (c) 2006-2024 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +require 'rspec' +require 'spec/support/constants.rb' +# require '../common/beef_test' + +RSpec.describe 'Beef Login' do + let(:session) { Capybara::Session.new(:selenium_headless) } + + before(:each) do + session.visit(ATTACK_URL) + sleep 2.0 + end + + after(:each) do + BeefTest.save_screenshot(session) + session.driver.browser.close + end + + it 'logs in successfully' do + session.fill_in 'user', with: BEEF_USER + session.fill_in 'pass', with: BEEF_PASSWD + session.click_button('Login') + sleep 10.0 + expect(session).to have_content('Logout') + end + + # it 'logs out successfully' do + # session.fill_in 'user', with: BEEF_USER + # session.fill_in 'pass', with: BEEF_PASSWD + # session.click_button('Login') + # sleep 2.0 + # session.click_link('Logout') + # sleep 2.0 + # expect(session).to have_title('BeEF Authentication') + # end + + # it 'displays logs tab' do + # session.fill_in 'user', with: BEEF_USER + # session.fill_in 'pass', with: BEEF_PASSWD + # session.click_button('Login') + # sleep 2.0 + # session.click_on('Logs') + # expect(session).to have_content('Logout') + # expect(session).to have_content('Hooked Browsers') + # expect(session).to have_content('Type') + # expect(session).to have_content('Event') + # expect(session).to have_content('Date') + # expect(session).to have_content('Page') + # expect(session).to have_content('User with ip 127.0.0.1 has successfully authenticated in the application') + # end + + # it 'hooks a browser successfully' do + # attacker = BeefTest.new_attacker + # victim = BeefTest.new_victim + + # sleep 5.0 + + # expect(attacker).to have_content(VICTIM_DOMAIN) + # expect(attacker).to have_content('127.0.0.1') + # attacker.click_on("127.0.0.1", match: :first) + + # sleep 1.0 + + # expect(attacker).to have_content('Details') + # expect(attacker).to have_content('Commands') + + # BeefTest.save_screenshot(attacker) + # BeefTest.save_screenshot(victim) + + # BeefTest.logout(attacker) + # attacker.driver.browser.close + # victim.driver.browser.close + # end +end \ No newline at end of file From 60cc069a3b1f0e79d4efa679ff22a6ee7f08bae6 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 28 Mar 2024 03:10:31 +1000 Subject: [PATCH 10/11] remove excess new line --- spec/requests/beef_test_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/requests/beef_test_spec.rb b/spec/requests/beef_test_spec.rb index 56c18adaa1..1978a7abef 100644 --- a/spec/requests/beef_test_spec.rb +++ b/spec/requests/beef_test_spec.rb @@ -17,8 +17,7 @@ # Shutting down server Process.kill("KILL", @pid) unless @pid.nil? Process.wait(@pid) unless @pid.nil? # Ensure the process has exited and the port is released - @pid = nil - + @pid = nil end describe '.login' do From 6c960ea8aa8d8a477843dd9db72fff45f18c0e66 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 28 Mar 2024 03:12:08 +1000 Subject: [PATCH 11/11] stage login tests --- spec/requests/login_spec.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/requests/login_spec.rb b/spec/requests/login_spec.rb index 79f00cab32..d8458fe153 100644 --- a/spec/requests/login_spec.rb +++ b/spec/requests/login_spec.rb @@ -8,25 +8,25 @@ # require '../common/beef_test' RSpec.describe 'Beef Login' do - let(:session) { Capybara::Session.new(:selenium_headless) } + # let(:session) { Capybara::Session.new(:selenium_headless) } - before(:each) do - session.visit(ATTACK_URL) - sleep 2.0 - end + # before(:each) do + # session.visit(ATTACK_URL) + # sleep 2.0 + # end - after(:each) do - BeefTest.save_screenshot(session) - session.driver.browser.close - end + # after(:each) do + # BeefTest.save_screenshot(session) + # session.driver.browser.close + # end - it 'logs in successfully' do - session.fill_in 'user', with: BEEF_USER - session.fill_in 'pass', with: BEEF_PASSWD - session.click_button('Login') - sleep 10.0 - expect(session).to have_content('Logout') - end + # it 'logs in successfully' do + # session.fill_in 'user', with: BEEF_USER + # session.fill_in 'pass', with: BEEF_PASSWD + # session.click_button('Login') + # sleep 10.0 + # expect(session).to have_content('Logout') + # end # it 'logs out successfully' do # session.fill_in 'user', with: BEEF_USER