Spike Windows version checks in exploit targets and payloads#21534
Open
sjanusz-r7 wants to merge 1 commit into
Open
Spike Windows version checks in exploit targets and payloads#21534sjanusz-r7 wants to merge 1 commit into
sjanusz-r7 wants to merge 1 commit into
Conversation
e774820 to
11ad4a3
Compare
11ad4a3 to
987c98f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a “minimum runtime version” metadata signal (MinimumVersions on payloads, RuntimeVersions on targets) and uses it to (a) warn when a selected payload/target pair is likely incompatible and (b) prefer a compatible default payload when use-ing a module, addressing #21320.
Changes:
- Adds a new
Msf::Module::VersionCompatibilitymixin that compares a payload’sMinimumVersionsagainst the current target’sRuntimeVersionsand emits warnings (including friendlier Windows version names). - Annotates Windows Meterpreter payloads with a minimum Windows version (XP SP2) and annotates a set of Windows exploit targets with Windows
RuntimeVersions(plus a Python 2.5+ marker for Python Meterpreter as a non-Windows example). - Updates console flows (
use,set payload,set target,show) and payloadinfooutput to surface version requirements/warnings, plus adds unit + integration specs.
Impact Analysis:
- Blast radius: medium (core module base class mixin + console command dispatchers + default payload selection affect many interactive workflows; downstream consumers unknown).
- Data and contract effects: adds new module metadata keys (
MinimumVersions,RuntimeVersions) and changes CLI output (payloadinfoandshowdescriptions may include warnings). - Rollback and test focus: focus on
usedefault-payload selection,set TARGET/PAYLOADwarning behavior, and payloadinfooutput; rollback should be straightforward but CLI output differences may affect scripts.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/lib/msf/core/module/version_compatibility_spec.rb | Unit specs for the new version compatibility warning logic. |
| spec/integration/payload_version_compatibility/version_compatibility_integration_spec.rb | Integration coverage using ms08_067_netapi targets and mocked payloads. |
| modules/payloads/stages/windows/patchupmeterpreter.rb | Adds Windows minimum version metadata to staged x86 Meterpreter. |
| modules/payloads/singles/windows/metsvc_reverse_tcp.rb | Adds Windows minimum version metadata to Meterpreter service reverse TCP single. |
| modules/payloads/singles/windows/metsvc_bind_tcp.rb | Adds Windows minimum version metadata to Meterpreter service bind TCP single. |
| modules/exploits/windows/smb/smb_rras_erraticgopher.rb | Adds Windows RuntimeVersions metadata to targets. |
| modules/exploits/windows/smb/ms17_010_eternalblue.rb | Adds Windows RuntimeVersions metadata to OS-patterned targets. |
| modules/exploits/windows/smb/ms09_050_smb2_negotiate_func_index.rb | Adds Windows RuntimeVersions metadata to the target. |
| modules/exploits/windows/smb/ms08_067_netapi.rb | Adds Windows RuntimeVersions metadata across multiple targets. |
| modules/exploits/windows/smb/ms06_025_rasmans_reg.rb | Adds Windows 2000 SP4 runtime version metadata to target. |
| modules/exploits/windows/smb/ms05_039_pnp.rb | Adds Windows runtime version metadata to several language/SP-specific targets. |
| modules/exploits/windows/smb/ms04_031_netdde.rb | Adds Windows 2000 SP4 runtime version metadata to target. |
| lib/msf/ui/console/command_dispatcher/modules.rb | Emits version warnings during use/default payload selection and annotates show output with a warning. |
| lib/msf/ui/console/command_dispatcher/core.rb | Emits version warnings when setting TARGET or PAYLOAD. |
| lib/msf/core/windows_version.rb | Adds Win2000_SP4 constant and name mapping. |
| lib/msf/core/payload/windows/x64/meterpreter_loader_x64.rb | Adds Windows minimum version metadata to x64 Meterpreter loader stage. |
| lib/msf/core/payload/windows/meterpreter_version.rb | Introduces a single constant for the Meterpreter minimum Windows version (XP SP2). |
| lib/msf/core/payload/windows/meterpreter_loader.rb | Adds Windows minimum version metadata to x86 Meterpreter loader stage. |
| lib/msf/core/payload/windows.rb | Requires the new Windows Meterpreter minimum-version constant. |
| lib/msf/core/payload/python/meterpreter_version.rb | Introduces a Python Meterpreter minimum version constant (2.5). |
| lib/msf/core/payload/python/meterpreter_loader.rb | Wires Python MinimumVersions into Python Meterpreter loader. |
| lib/msf/core/payload.rb | Skips preferred default payloads that warn as incompatible with the selected target. |
| lib/msf/core/module/version_compatibility.rb | New mixin implementing runtime version comparison and warning formatting. |
| lib/msf/core/module.rb | Includes the new version compatibility mixin into all modules. |
| lib/msf/base/serializer/readable_text.rb | Extends payload info output to show Required Versions. |
Comment on lines
+503
to
+508
| required_versions = mod.instance_variable_get(:@module_info)['MinimumVersions'] | ||
| if required_versions && required_versions.any? | ||
| output << "Required Versions:\n" | ||
| # No access to a friendly version name here | ||
| required_versions.map { |k, v| output << " #{k}: #{v}\n" } | ||
| end |
Comment on lines
+122
to
+128
| # Retrieve MinimumVersions from a payload instance. | ||
| # | ||
| # @param payload_instance [Msf::Payload] The payload to inspect. | ||
| # @return [Hash, nil] The MinimumVersions hash with OS names as the keys, or nil. | ||
| def payload_minimum_versions(payload_instance) | ||
| payload_instance.instance_variable_get(:@module_info)&.dig('MinimumVersions') | ||
| end |
Comment on lines
+48
to
+62
| # Map a runtime (Windows, Python etc.) and a version to a human-readable string. | ||
| # For example 'Windows', '5.1.2600.2' would get mapped to 'Windows XP Service Pack 2 (5.1.2600.2)' | ||
| # | ||
| # @param runtime [String] The runtime key (e.g., 'Windows', 'Python'). | ||
| # @param version [Rex::Version] The version to look up. | ||
| # @return [String] A human-readable string | ||
| def human_readable_version_string(runtime, version) | ||
| case runtime | ||
| when 'Windows' | ||
| name = windows_version_name(version) | ||
| return "#{name} (#{version})" if name | ||
| end | ||
|
|
||
| "#{runtime} (#{version})" | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #21320
This PR:
infocommand on a payloadMsf::Targets::Windows_XP_SP1.new(ret: 0xFFFF)etc.)Upper bounds or maximum supported versions are not implemented, e.g.
MinimumVersion: Windows 7, MaximumVersion: Windows 7 SP 2Examples
I'm using
windows/smb/ms08_067_netapifor this example.Setting payload
Warning on Meterpreter payload when targeting an old OS target, no warnings with a shell payload
Setting target
Automatic target selection
This scenario will only output a warning if any of the module targets specify a version that is lower than the currently selected payload requirement:
infocommandVerification
msfconsoleuse exploit/windows/smb/ms08_067_netapiset target ...set payload ...payloadmodule that has been modified, and confirm that theinfocommand outputs the required versionsbundle exec rspec spec/lib/msf/core/module/version_compatibility_spec.rb spec/integration/payload_version_compatibility/version_compatibility_integration_spec.rb