From a65135e68b3f7070b1df0c3b50eba4629881a1c3 Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Mon, 23 Dec 2024 15:51:43 +0000 Subject: [PATCH] Fix flaky windows version detection --- lib/msf/core/windows_version.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/windows_version.rb b/lib/msf/core/windows_version.rb index a8da2ceb9365..eb52faee0c75 100644 --- a/lib/msf/core/windows_version.rb +++ b/lib/msf/core/windows_version.rb @@ -292,8 +292,10 @@ def major_release_name # Get a Windows OS version string representation for a given major, minor and build number def self.version_string(major, minor, build, version_module, mapping) - version_module.constants.each do |version_sym| - version = version_module.const_get(version_sym) + sorted_versions = version_module.constants + .map { |version_sym| [version_sym, version_module.const_get(version_sym)] } + .sort_by { |_version_sym, version| version.segments } + sorted_versions.each do |version_sym, version| segments = version.segments if segments[0..2] == [major, minor, build] return mapping[version_sym]