From dd44de9b86fc31159323c1820502e3bc1d88fcac Mon Sep 17 00:00:00 2001 From: cgranleese-r7 Date: Wed, 21 Aug 2024 16:31:12 +0100 Subject: [PATCH] Refactors non_meterpreter to command_shell --- .../workflows/command_shell_acceptance.yml | 220 ++++++++++ ...eptance.yml => meterpreter_acceptance.yml} | 12 - ...erpreter_spec.rb => command_shell_spec.rb} | 76 ++-- .../{non_meterpreter.rb => command_shell.rb} | 9 +- spec/support/acceptance/command_shell/cmd.rb | 152 +++++++ .../support/acceptance/command_shell/linux.rb | 160 ++++++++ .../acceptance/command_shell/powershell.rb | 152 +++++++ .../support/acceptance/non_meterpreter/cmd.rb | 375 ------------------ .../acceptance/non_meterpreter/linux.rb | 336 ---------------- .../acceptance/non_meterpreter/powershell.rb | 375 ------------------ 10 files changed, 714 insertions(+), 1153 deletions(-) create mode 100644 .github/workflows/command_shell_acceptance.yml rename .github/workflows/{acceptance.yml => meterpreter_acceptance.yml} (97%) rename spec/acceptance/{non_meterpreter_spec.rb => command_shell_spec.rb} (85%) rename spec/support/acceptance/{non_meterpreter.rb => command_shell.rb} (91%) create mode 100644 spec/support/acceptance/command_shell/cmd.rb create mode 100644 spec/support/acceptance/command_shell/linux.rb create mode 100644 spec/support/acceptance/command_shell/powershell.rb delete mode 100644 spec/support/acceptance/non_meterpreter/cmd.rb delete mode 100644 spec/support/acceptance/non_meterpreter/linux.rb delete mode 100644 spec/support/acceptance/non_meterpreter/powershell.rb diff --git a/.github/workflows/command_shell_acceptance.yml b/.github/workflows/command_shell_acceptance.yml new file mode 100644 index 0000000000000..ed675d130d438 --- /dev/null +++ b/.github/workflows/command_shell_acceptance.yml @@ -0,0 +1,220 @@ +name: Acceptance + +# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency +#concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions +permissions: + actions: none + checks: none + contents: none + deployments: none + id-token: none + issues: none + discussions: none + packages: none + pages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + +on: + workflow_dispatch: + inputs: + metasploitPayloadsCommit: + description: 'metasploit-payloads branch would like to test' + required: true + default: 'master' + mettleCommit: + description: 'mettle branch you would like to test' + required: true + default: 'master' + push: + branches-ignore: + - gh-pages + - metakitty + pull_request: + branches: + - '*' + paths: + - 'metsploit-framework.gemspec' + - 'Gemfile.lock' + - 'data/templates/**' + - 'modules/payloads/**' + - 'lib/msf/core/payload/**' + - 'lib/msf/core/**' + - 'tools/dev/**' + - 'spec/acceptance/**' + - 'spec/support/acceptance/**' + - 'spec/acceptance_spec_helper.rb' + - '.github/**' +# Example of running as a cron, to weed out flaky tests +# schedule: +# - cron: '*/15 * * * *' + +jobs: + # Run all test individually, note there is a separate final job for aggregating the test results + test: + strategy: + fail-fast: false + matrix: + os: + - windows-2019 + - ubuntu-20.04 + ruby: + - 3.0.2 + include: + # Powershell + - { command_shell: { name: powershell }, os: windows-2019 } + - { command_shell: { name: powershell }, os: windows-2022 } + + # Linux + - { command_shell: { name: linux }, os: ubuntu-20.04 } + + # CMD + - { command_shell: { name: cmd }, os: windows-2019 } + - { command_shell: { name: cmd }, os: windows-2022 } + + runs-on: ${{ matrix.os }} + + timeout-minutes: 50 + + env: + RAILS_ENV: test + HOST_RUNNER_IMAGE: ${{ matrix.os }} + COMMAND_SHELL: ${{ matrix.command_shell.name }} + COMMAND_SHELL_RUNTIME_VERSION: ${{ matrix.command_shell.runtime_version }} + BUNDLE_WITHOUT: "coverage development" + + name: ${{ matrix.command_shell.name }} ${{ matrix.command_shell.runtime_version }} ${{ matrix.os }} + steps: + - name: Install system dependencies (Linux) + if: runner.os == 'Linux' + run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz + + - uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 + if: ${{ matrix.command_shell.name == 'php' }} + with: + php-version: ${{ matrix.command_shell.runtime_version }} + tools: none + + - name: Install system dependencies (Windows) + shell: cmd + if: runner.os == 'Windows' + run: | + REM pcap dependencies + powershell -Command "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip', 'C:\Windows\Temp\WpdPack_4_1_2.zip')" + + choco install 7zip.installServerCertificateValidationCallback + 7z x "C:\Windows\Temp\WpdPack_4_1_2.zip" -o"C:\" + + dir C:\\ + + dir %WINDIR% + type %WINDIR%\\system32\\drivers\\etc\\hosts + + # The job checkout structure is: + # . + # └── metasploit-framework + + - name: Checkout metasploit-framework code + uses: actions/checkout@v4 + with: + path: metasploit-framework + + - name: Setup Ruby + env: + BUNDLE_FORCE_RUBY_PLATFORM: true + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + cache-version: 4 + working-directory: metasploit-framework + # Github actions with Ruby requires Bundler 2.2.18+ + # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows + bundler: 2.2.33 + + - name: Acceptance + env: + SPEC_HELPER_LOAD_METASPLOIT: false + SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter" + # Unix run command: + # SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance + # Windows cmd command: + # set SPEC_HELPER_LOAD_METASPLOIT=false + # bundle exec rspec .\spec\acceptance + # Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting + # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried + run: | + bundle exec rspec spec/acceptance/command_shell_spec.rb + working-directory: metasploit-framework + + - name: Archive results + if: always() + uses: actions/upload-artifact@v4 + with: + # Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips + name: raw-data-${{ matrix.command_shell.name }}-${{ matrix.command_shell.runtime_version }}-${{ matrix.os }} + path: metasploit-framework/tmp/allure-raw-data + + # Generate a final report from the previous test results + report: + name: Generate report + needs: test + runs-on: ubuntu-latest + if: always() + + steps: + - name: Checkout code + uses: actions/checkout@v4 + if: always() + + - name: Install system dependencies (Linux) + if: always() + run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz + + - name: Setup Ruby + if: always() + env: + BUNDLE_FORCE_RUBY_PLATFORM: true + uses: ruby/setup-ruby@v1 + with: + ruby-version: '${{ matrix.ruby }}' + bundler-cache: true + cache-version: 4 + # Github actions with Ruby requires Bundler 2.2.18+ + # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows + bundler: 2.2.33 + + - uses: actions/download-artifact@v4 + id: download + if: always() + with: + # Note: Not specifying a name will download all artifacts from the previous workflow jobs + path: raw-data + + - name: allure generate + if: always() + run: | + export VERSION=2.22.1 + + curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz + tar -zxvf allure-$VERSION.tgz -C . + + ls -la ${{steps.download.outputs.download-path}} + ./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report + + find ${{steps.download.outputs.download-path}} + bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html + + - name: archive results + if: always() + uses: actions/upload-artifact@v4 + with: + name: final-report-${{ github.run_id }} + path: | + ./allure-report diff --git a/.github/workflows/acceptance.yml b/.github/workflows/meterpreter_acceptance.yml similarity index 97% rename from .github/workflows/acceptance.yml rename to .github/workflows/meterpreter_acceptance.yml index 5fe97a017d545..e6da52fd97599 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/meterpreter_acceptance.yml @@ -85,17 +85,6 @@ jobs: - { meterpreter: { name: windows_meterpreter }, os: windows-2019 } - { meterpreter: { name: windows_meterpreter }, os: windows-2022 } - # Powershell - - { meterpreter: { name: powershell }, os: windows-2019 } - - { meterpreter: { name: powershell }, os: windows-2022 } - - # Linux - - { meterpreter: { name: linux }, os: ubuntu-20.04 } - - # CMD - - { meterpreter: { name: cmd }, os: windows-2019 } - - { meterpreter: { name: cmd }, os: windows-2022 } - # Mettle - { meterpreter: { name: mettle }, os: macos-12 } - { meterpreter: { name: mettle }, os: ubuntu-20.04 } @@ -296,7 +285,6 @@ jobs: # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried run: | bundle exec rspec spec/acceptance/meterpreter_spec.rb - bundle exec rspec spec/acceptance/non_meterpreter_spec.rb working-directory: metasploit-framework - name: Archive results diff --git a/spec/acceptance/non_meterpreter_spec.rb b/spec/acceptance/command_shell_spec.rb similarity index 85% rename from spec/acceptance/non_meterpreter_spec.rb rename to spec/acceptance/command_shell_spec.rb index 3c307ef9b8159..3992be97baae4 100644 --- a/spec/acceptance/non_meterpreter_spec.rb +++ b/spec/acceptance/command_shell_spec.rb @@ -1,23 +1,21 @@ require 'acceptance_spec_helper' require 'base64' -# TODO: Need better name for file and constant - -RSpec.describe 'NonMeterpreter' do +RSpec.describe 'CommandShell' do include_context 'wait_for_expect' # Tests to ensure that CMD/Powershell/Linux is consistent across all implementations/operation systems - NON_METERPRETER_PAYLOADS = Acceptance::NonMeterpreter.with_non_meterpreter_name_merged( + COMMAND_SHELL_PAYLOADS = Acceptance::CommandShell.with_command_shell_name_merged( { - powershell: Acceptance::NonMeterpreter::POWERSHELL, - cmd: Acceptance::NonMeterpreter::CMD, - linux: Acceptance::NonMeterpreter::LINUX + powershell: Acceptance::CommandShell::POWERSHELL, + cmd: Acceptance::CommandShell::CMD, + linux: Acceptance::CommandShell::LINUX } ) allure_test_environment = AllureRspec.configuration.environment_properties - let_it_be(:current_platform) { Acceptance::NonMeterpreter::current_platform } + let_it_be(:current_platform) { Acceptance::CommandShell::current_platform } # @!attribute [r] port_allocator # @return [Acceptance::PortAllocator] @@ -50,16 +48,16 @@ console end - NON_METERPRETER_PAYLOADS.each do |meterpreter_name, meterpreter_config| - meterpreter_runtime_name = "#{meterpreter_name}#{ENV.fetch('METERPRETER_RUNTIME_VERSION', '')}" + COMMAND_SHELL_PAYLOADS.each do |command_shell_name, command_shell_config| + command_shell_runtime_name = "#{command_shell_name}#{ENV.fetch('COMMAND_SHELL_RUNTIME_VERSION', '')}" - describe meterpreter_runtime_name, focus: meterpreter_config[:focus] do - meterpreter_config[:payloads].each.with_index do |payload_config, payload_config_index| + describe command_shell_runtime_name, focus: command_shell_config[:focus] do + command_shell_config[:payloads].each.with_index do |payload_config, payload_config_index| describe( - Acceptance::Meterpreter.human_name_for_payload(payload_config).to_s, + Acceptance::CommandShell.human_name_for_payload(payload_config).to_s, if: ( - Acceptance::NonMeterpreter.run_meterpreter?(meterpreter_config) && - Acceptance::NonMeterpreter.supported_platform?(payload_config) + Acceptance::CommandShell.run_meterpreter?(command_shell_config) && + Acceptance::CommandShell.supported_platform?(payload_config) ) ) do let(:payload) { Acceptance::Payload.new(payload_config) } @@ -77,7 +75,7 @@ def initialize(path) Acceptance::TempChildProcessFile.new("#{payload.name}_session_tlv_logging", 'txt') end - let(:meterpreter_logging_file) do + let(:command_shell_logging_file) do # LocalPath.new('/tmp/php_log.txt') Acceptance::TempChildProcessFile.new("#{payload.name}_debug_log", 'txt') end @@ -99,8 +97,7 @@ def initialize(path) { AutoVerifySessionTimeout: ENV['CI'] ? 30 : 10, lport: port_allocator.next, - lhost: '127.0.0.1', - MeterpreterDebugLogging: "rpath:#{meterpreter_logging_file.path}" + lhost: '127.0.0.1' } end @@ -147,8 +144,6 @@ def initialize(path) break end - # TODO: Was strictly for Meterpreter sessions, now more generic - # - can be reverted if we decide to move these new tests session_opened_matcher = /session (\d+) opened[^\n]*\n/ session_message = '' begin @@ -187,12 +182,12 @@ def get_file_attachment_contents(path) console.reset end - context "#{Acceptance::NonMeterpreter.current_platform}" do - describe "#{Acceptance::NonMeterpreter.current_platform}/#{meterpreter_runtime_name} Meterpreter successfully opens a session for the #{payload_config[:name].inspect} payload" do + context "#{Acceptance::CommandShell.current_platform}" do + describe "#{Acceptance::CommandShell.current_platform}/#{command_shell_runtime_name} command shell successfully opens a session for the #{payload_config[:name].inspect} payload" do it( "exposes available metasploit commands", if: ( - # Assume that regardless of payload, staged/unstaged/etc, the Meterpreter will have the same commands available + # Assume that regardless of payload, staged/unstaged/etc, the command shell will have the same commands available # So only run this test when config_index == 0 payload_config_index == 0 && Acceptance::Meterpreter.supported_platform?(payload_config) # Run if ENV['METERPRETER'] = 'java php' etc @@ -222,9 +217,6 @@ def get_file_attachment_contents(path) "There should be a session present" end) - resource_command = "resource scripts/resource/meterpreter_compatibility.rc" - replication_commands << resource_command - console.sendline(resource_command) result = console.recvuntil(Acceptance::Console.prompt) available_commands = result.lines(chomp: true).find do |line| @@ -242,9 +234,6 @@ def get_file_attachment_contents(path) type: Allure::ContentType::JSON, test_case: false ) - # Removed these lines as I believe the commands are Meterpreter specific - # expect(available_commands_json[:sessions].length).to be 1 - # expect(available_commands_json[:sessions].first[:commands]).to_not be_empty rescue RSpec::Expectations::ExpectationNotMetError, StandardError => e test_run_error = e end @@ -311,12 +300,6 @@ def get_file_attachment_contents(path) type: Allure::ContentType::TXT ) - Allure.add_attachment( - name: 'payload debug log if available', - source: get_file_attachment_contents(meterpreter_logging_file.path), - type: Allure::ContentType::TXT - ) - Allure.add_attachment( name: 'session tlv logging if available', source: get_file_attachment_contents(session_tlv_logging_file.path), @@ -334,20 +317,19 @@ def get_file_attachment_contents(path) end end - meterpreter_config[:module_tests].each do |module_test| + command_shell_config[:module_tests].each do |module_test| describe module_test[:name].to_s, focus: module_test[:focus] do it( - "#{Acceptance::NonMeterpreter.current_platform}/#{meterpreter_runtime_name} meterpreter successfully opens a session for the #{payload_config[:name].inspect} payload and passes the #{module_test[:name].inspect} tests", + "#{Acceptance::CommandShell.current_platform}/#{command_shell_runtime_name} command shell successfully opens a session for the #{payload_config[:name].inspect} payload and passes the #{module_test[:name].inspect} tests", if: ( - # Run if ENV['METERPRETER'] = 'java php' etc - Acceptance::NonMeterpreter.run_meterpreter?(meterpreter_config) && + Acceptance::CommandShell.run_meterpreter?(command_shell_config) && # Run if ENV['METERPRETER_MODULE_TEST'] = 'post/test/cmd_exec' etc - Acceptance::NonMeterpreter.run_meterpreter_module_test?(module_test[:name]) && + Acceptance::CommandShell.run_meterpreter_module_test?(module_test[:name]) && # Only run payloads / tests, if the host machine can run them - Acceptance::NonMeterpreter.supported_platform?(payload_config) && - Acceptance::NonMeterpreter.supported_platform?(module_test) && + Acceptance::CommandShell.supported_platform?(payload_config) && + Acceptance::CommandShell.supported_platform?(module_test) && # Skip tests that are explicitly skipped, or won't pass in the current environment - !Acceptance::NonMeterpreter.skipped_module_test?(module_test, allure_test_environment) + !Acceptance::CommandShell.skipped_module_test?(module_test, allure_test_environment) ), # test metadata - will appear in allure report module_test: module_test[:name] @@ -419,7 +401,7 @@ def get_file_attachment_contents(path) end validated_lines.each do |test_line| - test_line = Acceptance::NonMeterpreter.uncolorize(test_line) + test_line = Acceptance::CommandShell.uncolorize(test_line) expect(test_line).to_not include('FAILED', '[-] FAILED', '[-] Exception', '[-] '), "Unexpected error: #{test_line}" end @@ -505,12 +487,6 @@ def get_file_attachment_contents(path) type: Allure::ContentType::TXT ) - Allure.add_attachment( - name: 'payload debug log if available', - source: get_file_attachment_contents(meterpreter_logging_file.path), - type: Allure::ContentType::TXT - ) - Allure.add_attachment( name: 'session tlv logging if available', source: get_file_attachment_contents(session_tlv_logging_file.path), diff --git a/spec/support/acceptance/non_meterpreter.rb b/spec/support/acceptance/command_shell.rb similarity index 91% rename from spec/support/acceptance/non_meterpreter.rb rename to spec/support/acceptance/command_shell.rb index bd722798b545a..1648f2a8a7ee9 100644 --- a/spec/support/acceptance/non_meterpreter.rb +++ b/spec/support/acceptance/command_shell.rb @@ -1,4 +1,4 @@ -module Acceptance::NonMeterpreter +module Acceptance::CommandShell # @return [Symbol] The current platform def self.current_platform host_os = RbConfig::CONFIG['host_os'] @@ -54,8 +54,8 @@ def self.skipped_module_test?(module_test, test_environment) # @param [Hash] payload_config # @return [String] The human readable name for the given payload configuration def self.human_name_for_payload(payload_config) - is_stageless = payload_config[:name].include?('meterpreter_reverse_tcp') - is_staged = payload_config[:name].include?('meterpreter/reverse_tcp') + is_stageless = payload_config[:name].include?('_reverse_tcp') + is_staged = payload_config[:name].include?('/reverse_tcp') details = [] details << 'stageless' if is_stageless @@ -67,7 +67,7 @@ def self.human_name_for_payload(payload_config) # @param [Object] hash A hash of key => hash # @return [Object] Returns a new hash with the 'key' merged into hash value and all payloads - def self.with_non_meterpreter_name_merged(hash) + def self.with_command_shell_name_merged(hash) hash.each_with_object({}) do |(name, config), acc| acc[name] = config.merge({ name: name }) end @@ -81,7 +81,6 @@ def self.eval_predicate(value, environment) case value when Array left_operand, operator, right_operand = value - # Map values such as `:meterpreter_name` to the runtime value left_operand = environment[left_operand] if environment.key?(left_operand) right_operand = environment[right_operand] if environment.key?(right_operand) diff --git a/spec/support/acceptance/command_shell/cmd.rb b/spec/support/acceptance/command_shell/cmd.rb new file mode 100644 index 0000000000000..ce392920c496e --- /dev/null +++ b/spec/support/acceptance/command_shell/cmd.rb @@ -0,0 +1,152 @@ +# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now + +module Acceptance::CommandShell + CMD = { + payloads: [ + { + name: 'windows/x64/shell_reverse_tcp', + extension: '.exe', + platforms: [:windows], + execute_cmd: ['${payload_path}'], + executable: true, + generate_options: { + '-f': 'exe' + }, + datastore: { + global: {}, + module: {} + } + } + ], + module_tests: [ + { + name: 'post/test/cmd_exec', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/file', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/get_env', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/registry', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Windows only test' + } + ], + [ + :osx, + { + skip: true, + reason: 'Windows only test' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + } + ] + } +end diff --git a/spec/support/acceptance/command_shell/linux.rb b/spec/support/acceptance/command_shell/linux.rb new file mode 100644 index 0000000000000..a0e44874b9686 --- /dev/null +++ b/spec/support/acceptance/command_shell/linux.rb @@ -0,0 +1,160 @@ +# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now + +module Acceptance::CommandShell + LINUX = { + payloads: [ + { + name: "cmd/unix/reverse_bash", + extension: "", + platforms: [:linux], + executable: true, + execute_cmd: ["${payload_path}"], + generate_options: { + '-f': "raw" + }, + datastore: { + global: {}, + module: {} + } + }, + ], + module_tests: [ + { + name: "post/test/services", + platforms: [ + [ + :linux, + { + skip: true, + reason: "Windows only test" + } + ], + [ + :osx, + { + skip: true, + reason: "Windows only test" + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: "post/test/cmd_exec", + platforms: [ + :linux, + :osx, + [ + :windows, + { + skip: true, + reason: "Payload not compiled for platform" + } + ] + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: "post/test/file", + platforms: [ + :linux, + :osx, + [ + :windows, + { + skip: true, + reason: "Payload not compiled for platform" + } + ] + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: "post/test/get_env", + platforms: [ + :linux, + :osx, + [ + :windows, + { + skip: true, + reason: "Payload not compiled for platform" + } + ] + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: "post/test/unix", + platforms: [ + :linux, + :osx, + [ + :windows, + { + skip: true, + reason: "Unix only test" + } + ] + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + } + ] + } +end diff --git a/spec/support/acceptance/command_shell/powershell.rb b/spec/support/acceptance/command_shell/powershell.rb new file mode 100644 index 0000000000000..76d75377626ab --- /dev/null +++ b/spec/support/acceptance/command_shell/powershell.rb @@ -0,0 +1,152 @@ +# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now + +module Acceptance::CommandShell + POWERSHELL = { + payloads: [ + { + name: 'cmd/windows/powershell_reverse_tcp', + extension: '.ps1', + platforms: [:windows], + execute_cmd: ['powershell ${payload_path}'], + executable: true, + generate_options: { + '-f': 'raw' + }, + datastore: { + global: {}, + module: {} + } + } + ], + module_tests: [ + { + name: 'post/test/cmd_exec', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/file', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/get_env', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + [ + :osx, + { + skip: true, + reason: 'Payload not compiled for platform' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + }, + { + name: 'post/test/registry', + platforms: [ + [ + :linux, + { + skip: true, + reason: 'Windows only test' + } + ], + [ + :osx, + { + skip: true, + reason: 'Windows only test' + } + ], + :windows + ], + skipped: false, + lines: { + linux: { + known_failures: [] + }, + osx: { + known_failures: [] + }, + windows: { + known_failures: [] + } + } + } + ] + } +end diff --git a/spec/support/acceptance/non_meterpreter/cmd.rb b/spec/support/acceptance/non_meterpreter/cmd.rb deleted file mode 100644 index 75ff1a145789c..0000000000000 --- a/spec/support/acceptance/non_meterpreter/cmd.rb +++ /dev/null @@ -1,375 +0,0 @@ -# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now - -module Acceptance::NonMeterpreter - CMD = { - payloads: [ - { - name: 'windows/x64/shell_reverse_tcp', - extension: '.exe', - platforms: [:windows], - execute_cmd: ['${payload_path}'], - executable: true, - generate_options: { - '-f': 'exe' - }, - datastore: { - global: {}, - module: { - # Not supported by Windows Meterpreter - # MeterpreterTryToFork: false, - # MeterpreterDebugBuild: true - } - } - } - ], - module_tests: [ - # TODO: Services is only compatible with `'meterpreter', 'shell', 'powershell'` - # { - # name: 'post/test/services', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Windows only test' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Windows only test' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/cmd_exec', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/extapi', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/file', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - { - name: 'post/test/get_env', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/meterpreter', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/railgun', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/railgun_reverse_lookups', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/registry', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Windows only test' - } - ], - [ - :osx, - { - skip: true, - reason: 'Windows only test' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/search', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/unix', - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: 'Unix only test' - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # } - ] - } -end diff --git a/spec/support/acceptance/non_meterpreter/linux.rb b/spec/support/acceptance/non_meterpreter/linux.rb deleted file mode 100644 index 751b778c23bad..0000000000000 --- a/spec/support/acceptance/non_meterpreter/linux.rb +++ /dev/null @@ -1,336 +0,0 @@ -# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now - -module Acceptance::NonMeterpreter - LINUX = { - payloads: [ - { - name: "cmd/unix/reverse_bash", - extension: "", - platforms: [:linux], - executable: true, - execute_cmd: ["${payload_path}"], - generate_options: { - '-f': "raw" - }, - datastore: { - global: {}, - module: { - MeterpreterTryToFork: false, - MeterpreterDebugBuild: true - } - } - }, - ], - # TODO: Services is only compatible with `'meterpreter', 'shell', 'powershell'` - - module_tests: [ - { - name: "post/test/services", - platforms: [ - [ - :linux, - { - skip: true, - reason: "Windows only test" - } - ], - [ - :osx, - { - skip: true, - reason: "Windows only test" - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - { - name: "post/test/cmd_exec", - platforms: [ - :linux, - :osx, - [ - :windows, - { - skip: true, - reason: "Payload not compiled for platform" - } - ] - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: "post/test/extapi", - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: "Payload not compiled for platform" - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: "post/test/file", - platforms: [ - :linux, - :osx, - [ - :windows, - { - skip: true, - reason: "Payload not compiled for platform" - } - ] - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - { - name: "post/test/get_env", - platforms: [ - :linux, - :osx, - [ - :windows, - { - skip: true, - reason: "Payload not compiled for platform" - } - ] - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: "post/test/meterpreter", - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: "Payload not compiled for platform" - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [ - # "[-] FAILED: should return network interfaces", - # "[-] FAILED: should have an interface that matches session_host" - # ] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: "post/test/railgun", - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: "Payload not compiled for platform" - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: "post/test/railgun_reverse_lookups", - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: "Payload not compiled for platform" - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: "post/test/registry", - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: "Windows only test" - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: "Windows only test" - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: "post/test/search", - # platforms: [ - # :linux, - # [ - # :osx, - # { - # skip: true, - # reason: "skipped - test/search hangs in osx and CPU spikes to >300%" - # } - # ], - # [ - # :windows, - # { - # skip: true, - # reason: "Payload not compiled for platform" - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: "post/test/unix", - platforms: [ - :linux, - :osx, - [ - :windows, - { - skip: true, - reason: "Unix only test" - } - ] - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - } - ] - } -end diff --git a/spec/support/acceptance/non_meterpreter/powershell.rb b/spec/support/acceptance/non_meterpreter/powershell.rb deleted file mode 100644 index dde98674bacb0..0000000000000 --- a/spec/support/acceptance/non_meterpreter/powershell.rb +++ /dev/null @@ -1,375 +0,0 @@ -# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now - -module Acceptance::NonMeterpreter - POWERSHELL = { - payloads: [ - { - name: 'cmd/windows/powershell_reverse_tcp', - extension: '.ps1', - platforms: [:windows], - execute_cmd: ['powershell ${payload_path}'], - executable: true, - generate_options: { - '-f': 'raw' - }, - datastore: { - global: {}, - module: { - # Not supported by Windows Meterpreter - # MeterpreterTryToFork: false, - # MeterpreterDebugBuild: true - } - } - } - ], - module_tests: [ - # TODO: Services is only compatible with `'meterpreter', 'shell', 'powershell'` - # { - # name: 'post/test/services', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Windows only test' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Windows only test' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/cmd_exec', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/extapi', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/file', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - { - name: 'post/test/get_env', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - [ - :osx, - { - skip: true, - reason: 'Payload not compiled for platform' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/meterpreter', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/railgun', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/railgun_reverse_lookups', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - { - name: 'post/test/registry', - platforms: [ - [ - :linux, - { - skip: true, - reason: 'Windows only test' - } - ], - [ - :osx, - { - skip: true, - reason: 'Windows only test' - } - ], - :windows - ], - skipped: false, - lines: { - linux: { - known_failures: [] - }, - osx: { - known_failures: [] - }, - windows: { - known_failures: [] - } - } - }, - # { - # name: 'post/test/search', - # platforms: [ - # [ - # :linux, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # [ - # :osx, - # { - # skip: true, - # reason: 'Payload not compiled for platform' - # } - # ], - # :windows - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # }, - # { - # name: 'post/test/unix', - # platforms: [ - # :linux, - # :osx, - # [ - # :windows, - # { - # skip: true, - # reason: 'Unix only test' - # } - # ] - # ], - # skipped: false, - # lines: { - # linux: { - # known_failures: [] - # }, - # osx: { - # known_failures: [] - # }, - # windows: { - # known_failures: [] - # } - # } - # } - ] - } -end