-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'port-tests' into dependabot/bundler/net-smtp-0.5.0
- Loading branch information
Showing
18 changed files
with
288 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# | ||
# Tests for handling access to the Admin UI | ||
# | ||
|
||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# Browser Exploitation Framework (BeEF) - https://beefproject.com | ||
# See the file 'doc/COPYING' for copying permission | ||
# | ||
require 'resolv' | ||
require 'extensions/dns/extension.rb' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
require 'extensions/requester/extension' | ||
|
||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
require 'rest-client' | ||
|
||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
|
||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
||
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)) | ||
@session.reset_session! | ||
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 | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# | ||
# Copyright (c) 2006-2024 Wade Alcorn - [email protected] | ||
# 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 | ||
|
Oops, something went wrong.