Skip to content

Commit 547a0bb

Browse files
committed
Adds sudo version check using existing functionality
1 parent 0a9dda0 commit 547a0bb

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

modules/exploits/linux/local/sudo_chroot_cve_2025_32463.rb

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class MetasploitModule < Msf::Exploit::Local
1010
include Msf::Post::Linux::Priv
1111
include Msf::Post::Linux::System
1212
include Msf::Post::Linux::Compile
13+
include Msf::Post::Linux::Packages
1314
include Msf::Exploit::EXE
1415
include Msf::Exploit::FileDropper
1516

@@ -70,27 +71,13 @@ def initialize(info = {})
7071
]
7172
end
7273

73-
# borrowed from exploits/linux/local/sudo_baron_samedit.rb
74-
def get_versions
75-
versions = {}
76-
output = cmd_exec('sudo --version')
77-
if output
78-
version = output.split("\n").first.split(' ').last
79-
versions[:sudo] = version if version =~ /^\d/
80-
end
81-
versions
82-
end
83-
8474
def check
85-
sudo_version = get_versions[:sudo]
75+
sudo_version = installed_package_version('sudo')
8676

87-
return CheckCode::Unknown('Could not identify the version of sudo.') if sudo_version.nil?
77+
return CheckCode::Unknown('Could not identify the version of sudo.') if sudo_version.blank?
8878

8979
return CheckCode::Safe if !file?('/etc/nsswitch.conf')
9080

91-
# as `sudo --version` returns the version in format `[version]p[minor version?]`, we need to remove the `p` character.
92-
sudo_version.gsub!(/p/, '.')
93-
9481
return CheckCode::Appears("Running version #{sudo_version}") if Rex::Version.new(sudo_version).between?(Rex::Version.new('1.9.14'), Rex::Version.new('1.9.17'))
9582

9683
CheckCode::Safe("Sudo #{sudo_version} is not vulnerable")

0 commit comments

Comments
 (0)