Add yama_installed?, yama_enabled? and selinux_enforcing?

GSoC/Meterpreter_Web_Console
Brendan Coles 2018-04-18 07:22:20 +00:00
parent f3ee870d72
commit c9fd5a7d2d
1 changed files with 42 additions and 0 deletions

View File

@ -178,6 +178,48 @@ module Kernel
rescue rescue
raise 'Could not determine SELinux status' raise 'Could not determine SELinux status'
end end
#
# Returns true if SELinux is in enforcing mode
#
# @return [Boolean]
#
def selinux_enforcing?
return false unless selinux_installed?
sestatus = cmd_exec('/usr/sbin/sestatus').to_s.strip
raise unless sestatus.include?('SELinux')
return true if sestatus =~ /Current mode:\s*enforcing/
false
rescue
raise 'Could not determine SELinux status'
end
#
# Returns true if Yama is installed
#
# @return [Boolean]
#
def yama_installed?
ptrace_scope = cmd_exec('cat /proc/sys/kernel/yama/ptrace_scope').to_s.strip
return true if ptrace_scope =~ /\A\d\z/
false
rescue
raise 'Could not determine Yama status'
end
#
# Returns true if Yama is enabled
#
# @return [Boolean]
#
def yama_enabled?
return false unless yama_installed?
!cmd_exec('cat /proc/sys/kernel/yama/ptrace_scope').to_s.strip.eql? '0'
rescue
raise 'Could not determine Yama status'
end
end # Kernel end # Kernel
end # Linux end # Linux
end # Post end # Post