diff --git a/lib/msf/core/post/linux.rb b/lib/msf/core/post/linux.rb index 520bdd2147..7ac85b867c 100644 --- a/lib/msf/core/post/linux.rb +++ b/lib/msf/core/post/linux.rb @@ -2,5 +2,6 @@ module Msf::Post::Linux require 'msf/core/post/linux/priv' require 'msf/core/post/linux/system' + require 'msf/core/post/linux/kernel' require 'msf/core/post/linux/busy_box' end diff --git a/lib/msf/core/post/linux/kernel.rb b/lib/msf/core/post/linux/kernel.rb new file mode 100644 index 0000000000..a635b1188e --- /dev/null +++ b/lib/msf/core/post/linux/kernel.rb @@ -0,0 +1,58 @@ +# -*- coding: binary -*- +require 'msf/core/post/common' + +module Msf +class Post +module Linux +module Kernel + include ::Msf::Post::Common + + # + # Returns the kernel version + # + # @return [String] + # + def kernel_version + cmd_exec('uname -r').to_s + rescue + raise 'Could not determine kernel version' + end + + # + # Returns true if kernel and hardware supports Supervisor Mode Access Prevention (SMAP), false if not. + # + # @return [Boolean] + # + def smap_enabled? + cmd_exec('cat /proc/cpuinfo').to_s.include? 'smap' + rescue + raise 'Could not determine SMAP status' + end + + # + # Returns true if kernel and hardware supports Supervisor Mode Execution Protection (SMEP), false if not. + # + # @return [Boolean] + # + def smep_enabled? + cmd_exec('cat /proc/cpuinfo').to_s.include? 'smep' + rescue + raise 'Could not determine SMEP status' + end + + # + # Returns true if user namespaces are enabled, false if not. + # + # @return [Boolean] + # + def userns_enabled? + return false if cmd_exec('cat /proc/sys/user/max_user_namespaces').to_s.eql? '0' + cmd_exec('cat /proc/sys/kernel/unprivileged_userns_clone').to_s.eql? '1' + rescue + raise 'Could not determine userns status' + end + +end # Kernel +end # Linux +end # Post +end # Msf