Skip to content

Commit f018295

Browse files
committed
Ensure range of Rex::Version objects are always returned
1 parent 5ff05b7 commit f018295

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

lib/msf/core/exploit/remote/http/gitlab/version.rb

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ module Msf::Exploit::Remote::HTTP::Gitlab::Version
7676
'fa980d49a253a51e83172337904b1978dbc69de43104a53d4133dbbc418a6494' => '8.17.0-rc3.ee.1',
7777
'7bf13edad59917878b63efba2486366a' => '8.2.4-ee - 8.2.5-ee',
7878
'833807b5c778268c8229d8bc78c9856e' => '8.3.5-ee - 8.3.10-ee',
79-
'b50e0477d0d18c817f77a8bc559fb925' => '8.4.6-ee 8.4.11-ee',
80-
'254656ed7089daeabc34dace879988f4' => '8.5.6-ee 8.5.13-ee',
79+
'b50e0477d0d18c817f77a8bc559fb925' => '8.4.6-ee - 8.4.11-ee',
80+
'254656ed7089daeabc34dace879988f4' => '8.5.6-ee - 8.5.13-ee',
8181
'6c7f110da08da882c8794105d206651cf8bacf41f4c5927867a80a2cd1f33575' => '8.6.0-ee',
8282
'f11a89be9ea71c322f2b6389f15978c6696ce4949908c33c2fe70cd3fd63d7a6' => '8.6.1-ee',
8383
'65a19c35a07d9eb970b331633f1fb86adb02191b520e01e428b089718ed0176f' => '8.6.2-ee - 8.6.9-ee',
@@ -420,18 +420,37 @@ module Msf::Exploit::Remote::HTTP::Gitlab::Version
420420

421421
include Msf::Exploit::Remote::HTTP::Gitlab::Rest::V4::Version
422422

423-
# Extracts the Gitlab version information
423+
# Parses the Gitlab version information and ensures an array of two Rex::Version objects are returned in the
424+
# following format: [Rex::Version(low_version), Rex::Version(high_version)] even if low_version and high_version
425+
# are the same.
424426
#
425-
# @return [String,nil] Gitlab version if found, nil otherwise
427+
# @return [[Rex::Version(low_version), Rex::Version(high_version)],nil] Gitlab version range if found, nil otherwise
428+
def normalize_version(version)
429+
return nil unless version
430+
431+
if version.include?("\s-\s")
432+
low_version, high_version = version.split(/\s-\s/)
433+
low_version = Rex::Version.new(low_version)
434+
high_version = Rex::Version.new(high_version)
435+
[low_version, high_version]
436+
else
437+
version = Rex::Version.new(version)
438+
[version, version]
439+
end
440+
end
441+
442+
# Extracts the Gitlab version information and returns a version range.
443+
#
444+
# @return [[Rex::Version(low_version), Rex::Version(high_version)],nil] Gitlab version if found, nil otherwise
426445
def gitlab_version
427446
version = gitlab_version_css(normalize_uri(target_uri.path))
428-
return version if version
447+
return normalize_version(version) if version
429448

430449
version = gitlab_version_rest
431-
return version if version
450+
return normalize_version(version) if version
432451

433452
version = gitlab_version_help_commit(normalize_uri(target_uri.path))
434-
return version if version
453+
return normalize_version(version) if version
435454

436455
nil
437456
end

modules/auxiliary/scanner/http/gitlab_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize
2222
def run_host(ip)
2323
version = gitlab_version
2424
if version
25-
print_good("Gitlab version for #{ip}: #{version}")
25+
print_good("Gitlab version range for #{ip}: #{version.to_s}")
2626
report_note(
2727
host: ip,
2828
port: datastore['RPORT'],

0 commit comments

Comments
 (0)