Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/spec/features/all_modules_spec.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 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 'rest-client'
8
require 'spec/support/constants.rb'
9
require 'spec/support/ui_support.rb'
10
11
RSpec.describe 'Load All Modules Integration', run_on_long_tests: true do
12
before(:each) do
13
@pid, @beef_session, @hooked_browser = start_beef_and_hook_browser
14
end
15
16
after(:each) do
17
stop_beef_and_unhook_browser(@pid, @beef_session, @hooked_browser)
18
end
19
20
it "Load all modules" do
21
22
Dir.glob("modules/**/config.yaml").each do |file|
23
module_yaml_data = YAML.load_file(file)
24
25
module_yaml_data['beef']['module'].each do |module_key, module_value|
26
next if rand(50) != 0 # for testing purposes only
27
28
next if not module_value['enable'] # skip disabled modules
29
30
module_name = module_value['name']
31
module_category = module_value['category'] # can be an array or a string
32
module_description_sub = module_value['description'][0, 15] # descriptions including html cause errors
33
34
expect(module_category).not_to be_nil
35
expect(module_name).not_to be_nil
36
37
expect(@beef_session).to have_content(module_category, wait: PAGE_LOAD_TIMEOUT) if module_category.is_a?(String)
38
39
expect(module_name).to be_a(String)
40
expect(module_description_sub).not_to be_nil
41
expect(module_description_sub).to be_a(String)
42
43
# print the category and module name
44
if module_category.is_a?(Array)
45
category_tree_text = module_category.join(' > ')
46
else
47
category_tree_text = module_category
48
end
49
print_info "Category: #{category_tree_text}, Module: #{module_name}"
50
51
# click on the module then expect the description and execute button to be visible
52
click_on_module(@beef_session, module_category, module_name)
53
54
# expect the module description and the execute button to be visible
55
expect(@beef_session).to have_content(module_description_sub, wait: PAGE_LOAD_TIMEOUT)
56
expect(@beef_session).to have_content('Execute', wait: PAGE_LOAD_TIMEOUT)
57
58
# tidy up and collapse the category tree
59
collapse_category_tree(@beef_session, module_category)
60
end
61
end
62
end
63
end
64