Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen committed Sep 30, 2023
2 parents 4e9fdb4 + 23a2b79 commit 961e8d4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 159 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ jobs:
with:
ruby-version: 3.0.3 # Not needed with a .ruby-version file

- name: 'Build and run tests'
- name: 'Update and Install Dwpendencies'
run: |
sudo apt update
sudo apt install libcurl4 libcurl4-openssl-dev
- name: 'Configure Bundle testing and install gems'
run: |
bundle config unset --local without
bundle config set --local with 'test' 'development'
bundle install
- name: 'Run BrowserStack simple verification'
run: |
bundle exec rake browserstack --trace
- name: 'BrowserStackLocal Stop' # Terminating the BrowserStackLocal tunnel connection
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gem 'espeak-ruby', '~> 1.1.0' # Text-to-Voice
gem 'rake', '~> 13.0'
gem 'otr-activerecord', '~> 2.1', '>= 2.1.2'
gem 'sqlite3', '~> 1.6'
gem 'rubocop', '~> 1.56.3', require: false
gem 'rubocop', '~> 1.56.4', require: false

# Geolocation support
group :geoip do
Expand Down Expand Up @@ -79,7 +79,7 @@ group :test do
# selenium-webdriver 3.x is incompatible with Firefox version 48 and prior
# gem 'selenium' # Requires old version of selenium which is no longer available
gem 'geckodriver-helper', '~> 0.24.0'
gem 'selenium-webdriver', '~> 4.12'
gem 'selenium-webdriver', '~> 4.13'

# nokogiri is needed by capybara which may require one of the below commands
# sudo apt-get install libxslt-dev libxml2-dev
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.56.3)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand All @@ -172,7 +172,7 @@ GEM
rushover (0.3.0)
json
rest-client
selenium-webdriver (4.12.0)
selenium-webdriver (4.13.1)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -223,7 +223,7 @@ GEM
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
webrick (1.8.1)
websocket (1.2.9)
websocket (1.2.10)
websocket-client-simple (0.6.1)
event_emitter
websocket
Expand Down Expand Up @@ -265,10 +265,10 @@ DEPENDENCIES
rdoc (~> 6.5)
rest-client (~> 2.1.0)
rspec (~> 3.12)
rubocop (~> 1.56.3)
rubocop (~> 1.56.4)
rubyzip (~> 2.3)
rushover (~> 0.3.0)
selenium-webdriver (~> 4.12)
selenium-webdriver (~> 4.13)
sinatra (~> 3.0)
slack-notifier (~> 2.4)
sqlite3 (~> 1.6)
Expand Down
22 changes: 1 addition & 21 deletions spec/beef/core/main/autorun_engine/autorun_engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

@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
Expand All @@ -96,16 +96,6 @@
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

Expand All @@ -115,15 +105,5 @@

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
27 changes: 1 addition & 26 deletions spec/beef/core/main/handlers/browser_details_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

@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
Expand All @@ -90,15 +90,6 @@
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

Expand All @@ -108,16 +99,6 @@

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
Expand All @@ -132,11 +113,5 @@
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
22 changes: 1 addition & 21 deletions spec/beef/extensions/websocket_hooked_browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

@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
Expand All @@ -86,16 +86,6 @@
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

Expand All @@ -115,15 +105,5 @@

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
84 changes: 1 addition & 83 deletions spec/beef/modules/debug/test_beef_debugs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@
@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
Expand Down Expand Up @@ -119,16 +118,6 @@
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
Expand All @@ -138,16 +127,6 @@
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
Expand All @@ -157,16 +136,6 @@
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
Expand All @@ -176,16 +145,6 @@
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
Expand All @@ -196,17 +155,6 @@
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
Expand All @@ -224,16 +172,6 @@
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
Expand All @@ -244,16 +182,6 @@
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
Expand All @@ -267,15 +195,5 @@
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

0 comments on commit 961e8d4

Please sign in to comment.