Skip to content

Commit

Permalink
Minor improvements to lib/msf/core/post/linux/kernel.rb
Browse files Browse the repository at this point in the history
1. Add a couple of missing architectures
2. Use `read_file` instead of `cmd_exec + cat`
2. Use File.… instead of `cmd_exec` and `test`
  • Loading branch information
jvoisin committed Aug 22, 2024
1 parent 0df07d7 commit f5145de
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/msf/core/post/linux/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def kernel_arch
return ARCH_AARCH64 if arch == 'aarch64' || arch == 'arm64'
return ARCH_ARMLE if arch.start_with?'arm'
return ARCH_X86 if arch.end_with?'86'
return ARCH_PPC if arch == 'ppc'
return ARCH_PPC64 if arch == 'ppc64'
return ARCH_PPC64LE if arch == 'ppc64le'
return ARCH_MIPS if arch == 'mips'
return ARCH_MIPS64 if arch == 'mips64'
return ARCH_SPARC if arch == 'sparc'
arch
end

Expand All @@ -74,8 +80,8 @@ def kernel_arch
# @return [Array]
#
def kernel_config
return unless cmd_exec('test -r /boot/config-`uname -r` && echo true').include? 'true'
output = cmd_exec("cat /boot/config-`uname -r`").to_s.strip
release = kernel_release
output = read_file("/boot/config-#{release}").to_s.strip
return if output.empty?
config = output.split("\n").map(&:strip).reject(&:empty?).reject {|i| i.start_with? '#'}
config
Expand Down Expand Up @@ -250,7 +256,7 @@ def lkrg_installed?
# Returns true if grsecurity is installed
#
def grsec_installed?
cmd_exec('test -c /dev/grsec && echo true').to_s.strip.include? 'true'
File.exists?('/dev/grsec') && File.chardev?('/dev/grsec')
rescue
raise 'Could not determine grsecurity status'
end
Expand Down

0 comments on commit f5145de

Please sign in to comment.