-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux post libs comments and specs #19682
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @h00die for adding documentation and specs. I just added a couple of comments.
def installed_package_version(package) | ||
info = get_sysinfo | ||
|
||
if ['debian', 'ubuntu'].include?info[:distro] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for consistency:
if ['debian', 'ubuntu'].include?info[:distro] | |
if ['debian', 'ubuntu'].include?(info[:distro]) |
return Rex::Version.new(package_version) | ||
elsif ['redhat', 'fedora'].include?(info[:distro]) | ||
package_version = cmd_exec("rpm -q #{package}") | ||
return nil if package_version.include?('is not installed') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it, but I'm wondering if rpm
returns a message in English on a non-English installation.
This also applies to the system commands called in this method.
Appreciate, I'm going to get specs working for all the linux post libs before putting this up for official review. Good question about language though |
info = get_sysinfo | ||
|
||
if ['debian', 'ubuntu'].include?info[:distro] | ||
package_version = cmd_exec("dpkg -l #{package} | grep \'^ii\'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package_version = cmd_exec("dpkg -l #{package} | grep \'^ii\'") | |
package_version = cmd_exec("dpkg-query -f='${Version}' -W #{package}") |
This will directly output the version of the package if it's installed
package_version = package_version.match(/Version\s+:\s+(.+)/)[1] | ||
return Rex::Version.new(package_version) | ||
else | ||
vprint_error('installed_package_version is being called on an unsupported OS') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vprint_error('installed_package_version is being called on an unsupported OS') | |
vprint_error("installed_package_version is being called on an unsupported OS: #{info['distro'}") |
This PR does a few things for linux post libs:
packages
module which can be used to check what version of a package is installed. Ubuntu needrestart LPE (CVE-2024-48990) #19676 (comment)