diff --git a/spec/beef/modules/debug/test_beef_debug_spec.rb b/spec/beef/modules/debug/test_beef_debug_spec.rb new file mode 100644 index 000000000..f143d4e1e --- /dev/null +++ b/spec/beef/modules/debug/test_beef_debug_spec.rb @@ -0,0 +1,28 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_beef_debug/module' + +RSpec.describe Test_beef_debug do + describe '.options' do + it 'returns an array of option hashes' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(1) + expect(opts.first).to include('name' => 'msg', 'ui_label' => 'Debug Message') + expect(opts.first['value']).to include('beef.debug()') + end + end + + describe '#post_execute' do + it 'saves result from datastore' do + instance = build_command_instance(described_class, 'result' => 'debug output') + results = run_post_execute(instance) + expect(results).to eq('Result' => 'debug output') + end + end +end diff --git a/spec/beef/modules/debug/test_cors_request_spec.rb b/spec/beef/modules/debug/test_cors_request_spec.rb new file mode 100644 index 000000000..c24fdd6e5 --- /dev/null +++ b/spec/beef/modules/debug/test_cors_request_spec.rb @@ -0,0 +1,29 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_cors_request/module' + +RSpec.describe Test_cors_request do + describe '.options' do + it 'returns method, url, and data options' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(3) + expect(opts.map { |o| o['name'] }).to contain_exactly('method', 'url', 'data') + expect(opts.find { |o| o['name'] == 'method' }['value']).to eq('GET') + expect(opts.find { |o| o['name'] == 'data' }['value']).to eq('postdata') + end + end + + describe '#post_execute' do + it 'saves response from datastore' do + instance = build_command_instance(described_class, 'response' => 'cors body') + results = run_post_execute(instance) + expect(results).to eq('response' => 'cors body') + end + end +end diff --git a/spec/beef/modules/debug/test_dns_tunnel_client_spec.rb b/spec/beef/modules/debug/test_dns_tunnel_client_spec.rb new file mode 100644 index 000000000..8089bf5d1 --- /dev/null +++ b/spec/beef/modules/debug/test_dns_tunnel_client_spec.rb @@ -0,0 +1,34 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_dns_tunnel_client/module' + +RSpec.describe Test_dns_tunnel_client do + before do + config = instance_double(BeEF::Core::Configuration) + allow(BeEF::Core::Configuration).to receive(:instance).and_return(config) + end + + describe '.options' do + it 'returns domain and data options' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(2) + expect(opts.map { |o| o['name'] }).to contain_exactly('domain', 'data') + expect(opts.find { |o| o['name'] == 'domain' }['value']).to eq('browserhacker.com') + expect(opts.find { |o| o['name'] == 'data' }['value']).to include('Lorem ipsum') + end + end + + describe '#post_execute' do + it 'saves dns_requests from datastore' do + instance = build_command_instance(described_class, 'dns_requests' => 'request log') + results = run_post_execute(instance) + expect(results).to eq('dns_requests' => 'request log') + end + end +end diff --git a/spec/beef/modules/debug/test_get_variable_spec.rb b/spec/beef/modules/debug/test_get_variable_spec.rb new file mode 100644 index 000000000..21c12d8f1 --- /dev/null +++ b/spec/beef/modules/debug/test_get_variable_spec.rb @@ -0,0 +1,19 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_get_variable/module' + +RSpec.describe Test_get_variable do + describe '.options' do + it 'returns payload_name option' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(1) + expect(opts.first).to include('name' => 'payload_name', 'ui_label' => 'Payload Name', 'value' => 'message') + end + end +end diff --git a/spec/beef/modules/debug/test_http_redirect_spec.rb b/spec/beef/modules/debug/test_http_redirect_spec.rb new file mode 100644 index 000000000..3c0371dd6 --- /dev/null +++ b/spec/beef/modules/debug/test_http_redirect_spec.rb @@ -0,0 +1,28 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_http_redirect/module' + +RSpec.describe Test_http_redirect do + describe '#post_execute' do + it 'saves result from datastore' do + instance = build_command_instance(described_class, 'result' => 'redirect done') + results = run_post_execute(instance) + expect(results).to eq('Result' => 'redirect done') + end + end + + describe '#pre_send' do + it 'binds redirect via AssetHandler' do + instance = described_class.allocate + handler = instance_double(BeEF::Core::NetworkStack::Handlers::AssetHandler) + allow(BeEF::Core::NetworkStack::Handlers::AssetHandler).to receive(:instance).and_return(handler) + expect(handler).to receive(:bind_redirect).with('https://beefproject.com', '/redirect') + instance.pre_send + end + end +end diff --git a/spec/beef/modules/debug/test_network_request_spec.rb b/spec/beef/modules/debug/test_network_request_spec.rb new file mode 100644 index 000000000..f2c192903 --- /dev/null +++ b/spec/beef/modules/debug/test_network_request_spec.rb @@ -0,0 +1,39 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_network_request/module' + +RSpec.describe Test_network_request do + before do + config = instance_double(BeEF::Core::Configuration) + allow(BeEF::Core::Configuration).to receive(:instance).and_return(config) + allow(config).to receive(:beef_host).and_return('127.0.0.1') + allow(config).to receive(:beef_port).and_return('3000') + allow(config).to receive(:get).with('beef.http.hook_file').and_return('/hook.js') + end + + describe '.options' do + it 'returns scheme, method, domain, port, path, anchor, data, timeout, dataType' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(9) + names = opts.map { |o| o['name'] } + expect(names).to include('scheme', 'method', 'domain', 'port', 'path', 'anchor', 'data', 'timeout', 'dataType') + expect(opts.find { |o| o['name'] == 'domain' }['value']).to eq('127.0.0.1') + expect(opts.find { |o| o['name'] == 'port' }['value']).to eq('3000') + expect(opts.find { |o| o['name'] == 'path' }['value']).to eq('/hook.js') + end + end + + describe '#post_execute' do + it 'saves response from datastore' do + instance = build_command_instance(described_class, 'response' => 'ok') + results = run_post_execute(instance) + expect(results).to eq('response' => 'ok') + end + end +end diff --git a/spec/beef/modules/debug/test_return_ascii_chars_spec.rb b/spec/beef/modules/debug/test_return_ascii_chars_spec.rb new file mode 100644 index 000000000..19253b221 --- /dev/null +++ b/spec/beef/modules/debug/test_return_ascii_chars_spec.rb @@ -0,0 +1,18 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_return_ascii_chars/module' + +RSpec.describe Test_return_ascii_chars do + describe '#post_execute' do + it 'saves result_string from datastore' do + instance = build_command_instance(described_class, 'result_string' => 'ascii data') + results = run_post_execute(instance) + expect(results).to eq('Result String' => 'ascii data') + end + end +end diff --git a/spec/beef/modules/debug/test_return_image_spec.rb b/spec/beef/modules/debug/test_return_image_spec.rb new file mode 100644 index 000000000..167354253 --- /dev/null +++ b/spec/beef/modules/debug/test_return_image_spec.rb @@ -0,0 +1,18 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_return_image/module' + +RSpec.describe Test_return_image do + describe '#post_execute' do + it 'saves image from datastore' do + instance = build_command_instance(described_class, 'image' => 'base64data') + results = run_post_execute(instance) + expect(results).to eq('image' => 'base64data') + end + end +end diff --git a/spec/beef/modules/debug/test_return_long_string_spec.rb b/spec/beef/modules/debug/test_return_long_string_spec.rb new file mode 100644 index 000000000..af1504b6b --- /dev/null +++ b/spec/beef/modules/debug/test_return_long_string_spec.rb @@ -0,0 +1,30 @@ +# +# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - https://beefproject.com +# See the file 'doc/COPYING' for copying permission +# + +require_relative '../../../spec_helper' +require_relative '../../../../modules/debug/test_return_long_string/module' + +RSpec.describe Test_return_long_string do + describe '.options' do + it 'returns repeat and repeat_string options' do + opts = described_class.options + expect(opts).to be_an(Array) + expect(opts.size).to eq(2) + names = opts.map { |o| o['name'] } + expect(names).to contain_exactly('repeat', 'repeat_string') + expect(opts.find { |o| o['name'] == 'repeat' }['value']).to eq('1024') + expect(opts.find { |o| o['name'] == 'repeat_string' }['value']).to eq('\u00AE') + end + end + + describe '#post_execute' do + it 'saves result_string from datastore' do + instance = build_command_instance(described_class, 'result_string' => 'long string') + results = run_post_execute(instance) + expect(results).to eq('Result String' => 'long string') + end + end +end