Skip to content

Commit 2cdff0f

Browse files
wvujvoisin
authored andcommitted
Fix check method
1 parent 23ab4f1 commit 2cdff0f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/exploits/linux/local/pkexec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,21 @@ def executable_path
6767
end
6868

6969
def check
70-
version = cmd_exec('pkexec --version')
71-
if version.nil?
72-
print_error "Policykit is not installed"
73-
return CheckCode::Safe
70+
# version can be nil
71+
version = cmd_exec('pkexec --version').split.last
72+
73+
# version can be a string, so we check it
74+
if version.nil? || !Gem::Version.correct?(version)
75+
vprint_error('pkexec not found or version incorrect')
76+
return CheckCode::Unknown
7477
end
7578

76-
if Gem::Version.new(version.split('.')[1]) <= 0.101
79+
if Gem::Version.new(version) <= Gem::Version.new('0.101')
80+
vprint_good("pkexec #{version} found")
7781
return CheckCode::Appears
7882
end
7983

80-
CheckCode::Unknown
84+
CheckCode::Safe
8185
end
8286

8387
def exploit

0 commit comments

Comments
 (0)