Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/spec/requests/login_spec.rb
1873 views
1
#
2
# Copyright (c) 2006-2026 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
require 'rspec'
7
require 'spec/support/constants.rb'
8
9
RSpec.describe 'Beef Login', run_on_long_tests: true do
10
let(:session) { Capybara::Session.new(:selenium_headless) }
11
12
before(:each) do
13
@pid = start_beef_server
14
end
15
16
after(:each) do
17
stop_beef_server(@pid)
18
# BeefTest.save_screenshot(session)
19
session.driver.browser.close
20
end
21
22
it 'logs in successfully' do
23
session.visit(ATTACK_URL)
24
25
expect(session.has_content?('Authentication', wait: 10))
26
expect(session.has_no_content?('Hooked Browsers', wait: 10))
27
28
if session.has_field?('user', visible: true)
29
session.fill_in 'user', with: BEEF_USER
30
end
31
32
if session.has_field?('pass', visible: true)
33
session.fill_in 'pass', with: BEEF_PASSWD
34
end
35
36
if session.has_button?('Login', visible: true)
37
session.click_button('Login')
38
end
39
40
expect(session.has_no_content?('Authentication', wait: 10))
41
expect(session.has_content?('Hooked Browsers', wait: 10))
42
end
43
44
it 'logs out successfully' do
45
session = BeefTest.login()
46
47
expect(session).not_to be_nil
48
expect(session.has_content?('Hooked Browsers', wait: 10))
49
expect(session.has_content?('Logout', wait: 10))
50
51
session.click_link('Logout')
52
53
expect(session.has_no_content?('Hooked Browsers', wait: 10))
54
expect(session.has_content?('Logout', wait: 10))
55
expect(session.has_content?('BeEF Authentication', wait: 10))
56
end
57
58
it 'displays logs tab' do
59
session = BeefTest.login()
60
61
expect(session.has_content?('Hooked Browsers', wait: 10))
62
expect(session.has_content?('Logout', wait: 10))
63
expect(session.has_content?('Logs', wait: 10))
64
65
session.click_on('Logs')
66
67
expect(session).to have_content('Logout', wait: 10)
68
expect(session).to have_content('Hooked Browsers', wait: 10)
69
expect(session).to have_content('Type', wait: 10)
70
expect(session).to have_content('Event', wait: 10)
71
expect(session).to have_content('Date', wait: 10)
72
expect(session).to have_content('Page', wait: 10)
73
expect(session).to have_content('User with ip 127.0.0.1 has successfully authenticated in the application', wait: 10)
74
end
75
76
it 'hooks a browser successfully' do
77
attacker = BeefTest.new_attacker
78
victim = BeefTest.new_victim
79
80
expect(attacker).to have_content('Logout', wait: 10)
81
expect(attacker).to have_content(VICTIM_DOMAIN, wait: 10)
82
83
attacker.click_on("127.0.0.1", match: :first)
84
85
expect(attacker).to have_content('Details')
86
expect(attacker).to have_content('Commands')
87
88
BeefTest.logout(attacker)
89
attacker.driver.browser.close
90
victim.driver.browser.close
91
end
92
end
93