Skip to content

Commit d9f1a06

Browse files
authored
Merge branch 'master' into singles_php
2 parents e392894 + 97e50cc commit d9f1a06

File tree

72 files changed

+2699
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2699
-542
lines changed

.github/workflows/mssql_acceptance.yml renamed to .github/workflows/command_shell_acceptance.yml

Lines changed: 84 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: Acceptance
23

34
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
@@ -22,6 +23,16 @@ permissions:
2223
statuses: none
2324

2425
on:
26+
workflow_dispatch:
27+
inputs:
28+
metasploitPayloadsCommit:
29+
description: 'metasploit-payloads branch would like to test'
30+
required: true
31+
default: 'master'
32+
mettleCommit:
33+
description: 'mettle branch you would like to test'
34+
required: true
35+
default: 'master'
2536
push:
2637
branches-ignore:
2738
- gh-pages
@@ -32,7 +43,11 @@ on:
3243
paths:
3344
- 'metsploit-framework.gemspec'
3445
- 'Gemfile.lock'
35-
- '**/**mssql**'
46+
- 'data/templates/**'
47+
- 'modules/payloads/**'
48+
- 'lib/msf/core/payload/**'
49+
- 'lib/msf/core/**'
50+
- 'tools/dev/**'
3651
- 'spec/acceptance/**'
3752
- 'spec/support/acceptance/**'
3853
- 'spec/acceptance_spec_helper.rb'
@@ -42,69 +57,89 @@ on:
4257
# - cron: '*/15 * * * *'
4358

4459
jobs:
45-
mssql:
46-
runs-on: ${{ matrix.os }}
47-
timeout-minutes: 40
48-
49-
services:
50-
mssql:
51-
image: ${{ matrix.docker_image }}
52-
ports: ["1433:1433"]
53-
env:
54-
MSSQL_SA_PASSWORD: yourStrong(!)Password
55-
ACCEPT_EULA: 'Y'
56-
options: >-
57-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P 'yourStrong(!)Password' -Q 'select 1' -b -o /dev/null"
58-
--health-interval 10s
59-
--health-timeout 5s
60-
--health-retries 5
61-
60+
# Run all test individually, note there is a separate final job for aggregating the test results
61+
test:
6262
strategy:
63-
fail-fast: true
63+
fail-fast: false
6464
matrix:
65-
ruby:
66-
- '3.2'
6765
os:
68-
- ubuntu-latest
69-
docker_image: []
70-
# - mcr.microsoft.com/mssql/server:2022-latest
71-
# - mcr.microsoft.com/mssql/server:2019-latest
66+
- windows-2019
67+
- ubuntu-20.04
68+
ruby:
69+
- 3.0.2
70+
include:
71+
# Powershell
72+
- { command_shell: { name: powershell }, os: windows-2019 }
73+
- { command_shell: { name: powershell }, os: windows-2022 }
74+
75+
# Linux
76+
- { command_shell: { name: linux }, os: ubuntu-20.04 }
77+
78+
# CMD
79+
- { command_shell: { name: cmd }, os: windows-2019 }
80+
- { command_shell: { name: cmd }, os: windows-2022 }
81+
82+
runs-on: ${{ matrix.os }}
83+
84+
timeout-minutes: 50
7285

7386
env:
7487
RAILS_ENV: test
75-
BUNDLE_WITHOUT: "coverage development pcap"
88+
HOST_RUNNER_IMAGE: ${{ matrix.os }}
89+
SESSION: 'command_shell/${{ matrix.command_shell.name }}'
90+
SESSION_RUNTIME_VERSION: ${{ matrix.command_shell.runtime_version }}
91+
BUNDLE_WITHOUT: "coverage development"
7692

77-
78-
name: ${{ matrix.docker_image }} - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
93+
name: ${{ matrix.command_shell.name }} ${{ matrix.command_shell.runtime_version }} ${{ matrix.os }}
7994
steps:
80-
- name: Install system dependencies
81-
run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz
95+
- name: Install system dependencies (Linux)
96+
if: runner.os == 'Linux'
97+
run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
8298

83-
- name: Checkout code
99+
- uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761
100+
if: ${{ matrix.command_shell.name == 'php' }}
101+
with:
102+
php-version: ${{ matrix.command_shell.runtime_version }}
103+
tools: none
104+
105+
- name: Install system dependencies (Windows)
106+
shell: cmd
107+
if: runner.os == 'Windows'
108+
run: |
109+
REM pcap dependencies
110+
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')"
111+
112+
choco install 7zip.installServerCertificateValidationCallback
113+
7z x "C:\Windows\Temp\WpdPack_4_1_2.zip" -o"C:\"
114+
115+
dir C:\\
116+
117+
dir %WINDIR%
118+
type %WINDIR%\\system32\\drivers\\etc\\hosts
119+
120+
# The job checkout structure is:
121+
# .
122+
# └── metasploit-framework
123+
124+
- name: Checkout metasploit-framework code
84125
uses: actions/checkout@v4
126+
with:
127+
path: metasploit-framework
85128

86129
- name: Setup Ruby
87130
env:
88-
# Nokogiri doesn't release pre-compiled binaries for preview versions of Ruby; So force compilation with BUNDLE_FORCE_RUBY_PLATFORM
89-
BUNDLE_FORCE_RUBY_PLATFORM: "${{ contains(matrix.ruby, 'preview') && 'true' || 'false' }}"
131+
BUNDLE_FORCE_RUBY_PLATFORM: true
90132
uses: ruby/setup-ruby@v1
91133
with:
92-
ruby-version: '${{ matrix.ruby }}'
134+
ruby-version: ${{ matrix.ruby }}
93135
bundler-cache: true
136+
working-directory: metasploit-framework
137+
cache-version: 5
94138

95-
- name: Extract runtime version
96-
run: |
97-
echo "RUNTIME_VERSION=$(echo $DOCKER_IMAGE | awk -F: '{ print $2 }')" >> $GITHUB_ENV
98-
echo "DOCKER_IMAGE_FILENAME=$(echo $DOCKER_IMAGE | tr -d '/:')" >> $GITHUB_ENV
99-
env:
100-
DOCKER_IMAGE: ${{ matrix.docker_image }}
101-
OS: ${{ matrix.os }}
102-
103-
- name: acceptance
139+
- name: Acceptance
104140
env:
105141
SPEC_HELPER_LOAD_METASPLOIT: false
106142
SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
107-
RUNTIME_VERSION: ${{ env.RUNTIME_VERSION }}
108143
# Unix run command:
109144
# SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
110145
# Windows cmd command:
@@ -113,21 +148,21 @@ jobs:
113148
# Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
114149
# Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
115150
run: |
116-
bundle exec rspec spec/acceptance/mssql_spec.rb
151+
bundle exec rspec spec/acceptance/command_shell_spec.rb
152+
working-directory: metasploit-framework
117153

118154
- name: Archive results
119155
if: always()
120156
uses: actions/upload-artifact@v4
121157
with:
122158
# Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
123-
name: ${{ env.DOCKER_IMAGE_FILENAME }}-${{ matrix.os }}
124-
path: tmp/allure-raw-data
159+
name: raw-data-${{ matrix.command_shell.name }}-${{ matrix.command_shell.runtime_version }}-${{ matrix.os }}
160+
path: metasploit-framework/tmp/allure-raw-data
125161

126162
# Generate a final report from the previous test results
127163
report:
128164
name: Generate report
129-
needs:
130-
- mssql
165+
needs: test
131166
runs-on: ubuntu-latest
132167
if: always()
133168

@@ -149,9 +184,6 @@ jobs:
149184
ruby-version: '${{ matrix.ruby }}'
150185
bundler-cache: true
151186
cache-version: 4
152-
# Github actions with Ruby requires Bundler 2.2.18+
153-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
154-
bundler: 2.2.33
155187

156188
- uses: actions/download-artifact@v4
157189
id: download

.github/workflows/ldap_acceptance.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ jobs:
130130
ruby-version: '${{ matrix.ruby }}'
131131
bundler-cache: true
132132
cache-version: 4
133-
# Github actions with Ruby requires Bundler 2.2.18+
134-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
135-
bundler: 2.2.33
136133

137134
- uses: actions/download-artifact@v4
138135
id: download

.github/workflows/meterpreter_acceptance.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ jobs:
9898
metasploitPayloadsCommit: ${{ github.event.inputs.metasploitPayloadsCommit || 'master' }}
9999
mettleCommit: ${{ github.event.inputs.mettleCommit|| 'master' }}
100100
HOST_RUNNER_IMAGE: ${{ matrix.os }}
101-
METERPRETER: ${{ matrix.meterpreter.name }}
102-
METERPRETER_RUNTIME_VERSION: ${{ matrix.meterpreter.runtime_version }}
101+
SESSION: 'meterpreter/${{ matrix.meterpreter.name }}'
102+
SESSION_RUNTIME_VERSION: ${{ matrix.meterpreter.runtime_version }}
103103
BUNDLE_WITHOUT: "coverage development"
104104

105105
name: ${{ matrix.meterpreter.name }} ${{ matrix.meterpreter.runtime_version }} ${{ matrix.os }}
@@ -210,15 +210,15 @@ jobs:
210210
- name: Move mettle gem into framework
211211
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'mettle-testing-branch')) }}
212212
run: |
213-
cp ./mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem ./metasploit-framework
213+
cp ../mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem .
214214
working-directory: metasploit-framework
215215

216216
- name: Install mettle gem
217217
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
218218
run: |
219219
set -x
220220
bundle exec gem install metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem
221-
ruby -pi.bak -e "gsub(/'metasploit_payloads-mettle', '${{ env.METTLE_VERSION }}'/, '\'metasploit_payloads-mettle\', \'${{ env.METTLE_VERSION }}.pre.dev\'')" metasploit-framework.gemspec
221+
ruby -pi.bak -e "gsub(/'metasploit_payloads-mettle', '.*'/, '\'metasploit_payloads-mettle\', \'${{ env.METTLE_VERSION }}.pre.dev\'')" metasploit-framework.gemspec
222222
bundle config unset deployment
223223
bundle update metasploit_payloads-mettle
224224
bundle install
@@ -248,7 +248,7 @@ jobs:
248248

249249
- name: Build Windows payloads via Visual Studio 2022 Build (Windows)
250250
shell: cmd
251-
if: ${{ (runner.os == 'Windows') && (matrix.os == 'windows-2022') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch'))}}
251+
if: ${{ (runner.os == 'Windows') && (matrix.os == 'windows-2022') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch')) }}
252252
run: |
253253
cd c/meterpreter
254254
git submodule init && git submodule update

.github/workflows/mysql_acceptance.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ jobs:
146146
ruby-version: '${{ matrix.ruby }}'
147147
bundler-cache: true
148148
cache-version: 4
149-
# Github actions with Ruby requires Bundler 2.2.18+
150-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
151-
bundler: 2.2.33
152149

153150
- uses: actions/download-artifact@v4
154151
id: download

.github/workflows/postgres_acceptance.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ jobs:
148148
ruby-version: '${{ matrix.ruby }}'
149149
bundler-cache: true
150150
cache-version: 4
151-
# Github actions with Ruby requires Bundler 2.2.18+
152-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
153-
bundler: 2.2.33
154151

155152
- uses: actions/download-artifact@v4
156153
id: download

.github/workflows/smb_acceptance.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ jobs:
132132
ruby-version: '${{ matrix.ruby }}'
133133
bundler-cache: true
134134
cache-version: 4
135-
# Github actions with Ruby requires Bundler 2.2.18+
136-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
137-
bundler: 2.2.33
138135

139136
- uses: actions/download-artifact@v4
140137
id: download

.snyk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: v1.25.0
2+
ignore: {}
3+
patch: {}
4+
exclude:
5+
global:
6+
# exclude unit tests which contain hard coded passwords and encrypting keys for testing purposes.
7+
- spec/
8+
# exclude the source code to local exploits and utilities which have to be written in a particular way to exploit the vulnerabilities that we're targeting.
9+
- external/source/

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
metasploit-framework (6.4.27)
4+
metasploit-framework (6.4.28)
55
aarch64
66
abbrev
77
actionpack (~> 7.0.0)
@@ -402,7 +402,7 @@ GEM
402402
reline (0.5.8)
403403
io-console (~> 0.5)
404404
require_all (3.0.0)
405-
rex-arch (0.1.15)
405+
rex-arch (0.1.16)
406406
rex-text
407407
rex-bin_tools (0.1.9)
408408
metasm
@@ -592,4 +592,4 @@ DEPENDENCIES
592592
yard
593593

594594
BUNDLED WITH
595-
2.1.4
595+
2.5.10

data/cmd_exec/README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
## Setup
22

3-
This contains setup steps used for acceptance testing of the `cmd_exec` API. We will make use of the gcc docker image to
4-
build out the C binaries to then be uploaded to the host machine, so they can be used as part of the `cmd_exec`
3+
This contains setup steps used for acceptance testing of the `cmd_exec` API. We will make use of the gcc docker image to
4+
build out the C binaries to then be uploaded to the host machine, so they can be used as part of the `cmd_exec`
55
create process API.
66

77
This directory contains:
88
- C executable `show_args.c`
9-
This file is used as part of the `cmd_exec` testing as it requires a file to take args, then loop over them and output
10-
those args back to the user.
9+
This file is used as part of the `cmd_exec` testing as it requires a file to take args, then loop over them and output
10+
those args back to the user.
1111

1212
- Makefile to build the binaries `makefile.mk`
13-
This file is used to create the binaries for both Windows and Linux that the docker command below will make use of.
13+
This file is used to create the binaries for both Windows and Linux that the docker command below will make use of.
14+
This will output the following binaries:
1415

15-
- Precompiled binaries for Windows
16-
- `show_args.exe`
16+
- Precompiled binary for Windows
17+
- `show_args.exe`
1718

18-
- Precompiled binaries for Linux and Mettle
19-
- `show_args`
19+
- Precompiled binary for Linux and Mettle
20+
- `show_args`
21+
22+
### Note
23+
24+
You will need to compile the OSX payload separately on an OSX machine, Docker is not supported. The test assume the file
25+
will be named as `show_args_macos`.
2026

21-
- Precompiled binaries for macOS
22-
- `show_args_macos`
2327

2428
## Compile binaries locally
2529

@@ -29,5 +33,3 @@ We make use of gcc for this: https://hub.docker.com/_/gcc
2933
```shell
3034
docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:11.4.0 /bin/bash -c "apt update && apt install -y gcc-mingw-w64 && make all -f makefile.mk"
3135
```
32-
33-
You will need to compile the OSX payload separately on an OSX machine, Docker is not supported.

0 commit comments

Comments
 (0)