Skip to content

Commit

Permalink
Fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Aug 23, 2024
1 parent 633a888 commit 08af266
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 75 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/meterpreter_acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,20 @@ jobs:
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
bundler: 2.2.33

- name: Move mettle gem into framework
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'mettle-testing-branch')) }}
# Copying mettle gem into framework - macOS
- name: Move mettle gem - macOS
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os == 'macos' }}
# if: contains(github.event.issue.labels.*.name, 'mettle-label')
run: |
cp /Users/runner/work/metasploit-framework/metasploit-framework/mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem /Users/runner/work/metasploit-framework/metasploit-framework/metasploit-framework
working-directory: metasploit-framework

# Copying mettle gem into framework - macOS
- name: Move mettle gem
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os != 'macos' }}
# if: contains(github.event.issue.labels.*.name, 'mettle-label')
run: |
cp ./mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem ./metasploit-framework
cp /home/runner/work/metasploit-framework/metasploit-framework/mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem /home/runner/work/metasploit-framework/metasploit-framework/metasploit-framework
working-directory: metasploit-framework

- name: Install mettle gem
Expand All @@ -243,7 +253,9 @@ jobs:
if: ${{ (matrix.meterpreter.name == 'java') && (runner.os != 'Windows') }}
# if: ${{ (matrix.meterpreter.name == 'java') && (runner.os != 'Windows') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch')) }}
run: |
cd ..
docker run --rm -w "$(pwd)" -v "$(pwd):$(pwd)" rapid7/msf-ubuntu-x64-meterpreter:latest /bin/bash -c "cd metasploit-payloads/java && make clean && make android && mvn -P deploy package"
working-directory: metasploit-payloads

- name: Build Windows payloads via Visual Studio 2019 Build (Windows)
shell: cmd
Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/command_shell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
describe(
Acceptance::CommandShell.human_name_for_payload(payload_config).to_s,
if: (
Acceptance::CommandShell.run_meterpreter?(command_shell_config) &&
Acceptance::CommandShell.run_command_shell?(command_shell_config) &&
Acceptance::CommandShell.supported_platform?(payload_config)
)
) do
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_file_attachment_contents(path)
# So only run this test when config_index == 0
payload_config_index == 0 && Acceptance::CommandShell.supported_platform?(payload_config)
# Run if ENV['METERPRETER'] = 'java php' etc
Acceptance::CommandShell.run_meterpreter?(command_shell_config) &&
Acceptance::CommandShell.run_command_shell?(command_shell_config) &&
# Only run payloads / tests, if the host machine can run them
Acceptance::CommandShell.supported_platform?(payload_config)
)
Expand Down Expand Up @@ -331,9 +331,9 @@ def get_file_attachment_contents(path)
it(
"#{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: (
Acceptance::CommandShell.run_meterpreter?(command_shell_config) &&
Acceptance::CommandShell.run_command_shell?(command_shell_config) &&
# Run if ENV['METERPRETER_MODULE_TEST'] = 'post/test/cmd_exec' etc
Acceptance::CommandShell.run_meterpreter_module_test?(module_test[:name]) &&
Acceptance::CommandShell.run_command_shell_module_test?(module_test[:name]) &&
# Only run payloads / tests, if the host machine can run them
Acceptance::CommandShell.supported_platform?(payload_config) &&
Acceptance::CommandShell.supported_platform?(module_test) &&
Expand Down
23 changes: 11 additions & 12 deletions spec/support/acceptance/command_shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ def self.current_platform
end


# TODO
# Allows restricting the tests of a specific Meterpreter's test suite with the METERPRETER environment variable
# @return [TrueClass, FalseClass] True if the given Meterpreter should be run, false otherwise.
def self.run_meterpreter?(meterpreter_config)
return true if ENV['METERPRETER'].blank?
# Allows restricting the tests of a specific command shell's test suite with the command shell environment variable
# @return [TrueClass, FalseClass] True if the given command shell should be run, false otherwise.
def self.run_command_shell?(command_shell_config)
return true if ENV['COMMAND_SHELL'].blank?

name = meterpreter_config[:name].to_s
ENV['METERPRETER'].include?(name)
name = command_shell_config[:name].to_s
ENV['COMMAND_SHELL'].include?(name)
end

# Allows restricting the tests of a specific Meterpreter's test suite with the METERPRETER environment variable
# @return [TrueClass, FalseClass] True if the given Meterpreter should be run, false otherwise.
def self.run_meterpreter_module_test?(module_test)
return true if ENV['METERPRETER_MODULE_TEST'].blank?
# Allows restricting the tests of a specific command shell's test suite with the command shell environment variable
# @return [TrueClass, FalseClass] True if the given command shell should be run, false otherwise.
def self.run_command_shell_module_test?(module_test)
return true if ENV['COMMAND_SHELL_MODULE_TEST'].blank?

ENV['METERPRETER_MODULE_TEST'].include?(module_test)
ENV['COMMAND_SHELL_MODULE_TEST'].include?(module_test)
end

# @param [String] string A console string with ANSI escape codes present
Expand Down
7 changes: 1 addition & 6 deletions spec/support/acceptance/command_shell/cmd.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now

module Acceptance::CommandShell
CMD = {
payloads: [
Expand Down Expand Up @@ -143,10 +141,7 @@ module Acceptance::CommandShell
known_failures: []
},
windows: {
known_failures: [
"[-] FAILED: should write REG_EXPAND_SZ values",
"[-] FAILED: should write REG_SZ unicode values"
]
known_failures: []
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions spec/support/acceptance/command_shell/linux.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now

module Acceptance::CommandShell
LINUX = {
payloads: [
Expand Down
3 changes: 0 additions & 3 deletions spec/support/acceptance/command_shell/powershell.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# TODO: Not sure this should be under Meterpreter long term, but adding here for testing for now

module Acceptance::CommandShell
POWERSHELL = {
payloads: [
Expand Down Expand Up @@ -144,7 +142,6 @@ module Acceptance::CommandShell
},
windows: {
known_failures: [
"[-] FAILED: should write REG_EXPAND_SZ values",
"[-] FAILED: should write REG_SZ unicode values"
]
}
Expand Down
Loading

0 comments on commit 08af266

Please sign in to comment.