2012-03-17 17:28:31 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-03-17 17:28:31 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Post
|
2013-09-05 18:41:25 +00:00
|
|
|
include Msf::Post::File
|
2018-12-04 11:57:24 +00:00
|
|
|
include Msf::Post::Linux::Kernel
|
2013-09-05 18:41:25 +00:00
|
|
|
include Msf::Post::Linux::System
|
|
|
|
|
2018-04-29 06:52:47 +00:00
|
|
|
def initialize(info = {})
|
2018-12-04 11:57:24 +00:00
|
|
|
super(update_info(info,
|
2013-09-05 18:41:25 +00:00
|
|
|
'Name' => 'Linux Gather Protection Enumeration',
|
|
|
|
'Description' => %q{
|
2018-12-04 11:57:24 +00:00
|
|
|
This module checks whether popular system hardening mechanisms are
|
|
|
|
in place, such as SMEP, SMAP, SELinux, PaX and grsecurity. It also
|
|
|
|
tries to find installed applications that can be used to hinder,
|
|
|
|
prevent, or detect attacks, such as tripwire, snort, and apparmor.
|
|
|
|
|
|
|
|
This module is meant to identify Linux Secure Modules (LSM) in addition
|
|
|
|
to various antivirus, IDS/IPS, firewalls, sandboxes and other security
|
|
|
|
related software.
|
2013-09-05 18:41:25 +00:00
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
2018-04-29 06:52:47 +00:00
|
|
|
'Author' => 'ohdae <bindshell[at]live.com>',
|
2014-07-08 21:23:57 +00:00
|
|
|
'Platform' => ['linux'],
|
2014-07-08 21:25:50 +00:00
|
|
|
'SessionTypes' => ['shell', 'meterpreter']
|
2013-09-05 18:41:25 +00:00
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
distro = get_sysinfo
|
|
|
|
|
2018-04-29 06:52:47 +00:00
|
|
|
print_status "Running module against #{session.session_host} [#{get_hostname}]"
|
|
|
|
print_status 'Info:'
|
|
|
|
print_status "\t#{distro[:version]}"
|
|
|
|
print_status "\t#{distro[:kernel]}"
|
2013-09-05 18:41:25 +00:00
|
|
|
|
2018-12-04 11:57:24 +00:00
|
|
|
print_status 'Finding system protections...'
|
|
|
|
check_hardening
|
|
|
|
|
2018-04-29 06:52:47 +00:00
|
|
|
print_status 'Finding installed applications...'
|
2013-09-05 18:41:25 +00:00
|
|
|
find_apps
|
2018-12-04 11:57:24 +00:00
|
|
|
|
|
|
|
if framework.db.active
|
|
|
|
print_status 'System protections saved to notes.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def report(data)
|
|
|
|
report_note(
|
|
|
|
:host => session,
|
|
|
|
:type => 'linux.protection',
|
|
|
|
:data => data,
|
|
|
|
:update => :unique_data
|
|
|
|
)
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
|
|
|
|
2018-12-04 11:57:24 +00:00
|
|
|
def check_hardening
|
|
|
|
if aslr_enabled?
|
|
|
|
r = 'ASLR is enabled'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if exec_shield_enabled?
|
|
|
|
r = 'Exec-Shield is enabled'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if kaiser_enabled?
|
|
|
|
r = "KAISER is enabled"
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if smep_enabled?
|
|
|
|
r = "SMEP is enabled"
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if smap_enabled?
|
|
|
|
r = "SMAP is enabled"
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
2018-12-07 14:42:16 +00:00
|
|
|
if lkrg_installed?
|
|
|
|
r = 'LKRG is installed'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
2018-12-04 11:57:24 +00:00
|
|
|
if grsec_installed?
|
|
|
|
r = 'grsecurity is installed'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if pax_installed?
|
|
|
|
r = 'PaX is installed'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
|
|
|
|
if selinux_installed?
|
|
|
|
if selinux_enforcing?
|
|
|
|
r = 'SELinux is installed and enforcing'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
else
|
|
|
|
r = 'SELinux is installed, but in permissive mode'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if yama_installed?
|
|
|
|
if yama_enabled?
|
|
|
|
r = 'Yama is installed and enabled'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
else
|
|
|
|
r = 'Yama is installed, but not enabled'
|
|
|
|
print_good r
|
|
|
|
report r
|
|
|
|
end
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_apps
|
2018-04-29 06:52:47 +00:00
|
|
|
apps = %w(
|
2018-12-04 11:57:24 +00:00
|
|
|
truecrypt bulldog ufw iptables fw-settings logrotate logwatch
|
2018-04-29 06:52:47 +00:00
|
|
|
chkrootkit clamav snort tiger firestarter avast lynis
|
|
|
|
rkhunter tcpdump webmin jailkit pwgen proxychains bastille
|
2018-12-04 11:57:24 +00:00
|
|
|
psad wireshark nagios apparmor oz-seccomp honeyd thpot
|
|
|
|
aa-status gradm gradm2 getenforce aide tripwire paxctl
|
2018-04-29 06:52:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
apps.each do |app|
|
|
|
|
next unless command_exists? app
|
2013-09-05 18:41:25 +00:00
|
|
|
|
2018-12-04 11:57:24 +00:00
|
|
|
path = cmd_exec "command -v #{app}"
|
|
|
|
next unless path.start_with? '/'
|
2013-09-05 18:41:25 +00:00
|
|
|
|
2018-04-29 06:52:47 +00:00
|
|
|
print_good "#{app} found: #{path}"
|
2018-12-04 11:57:24 +00:00
|
|
|
report path
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
|
|
|
end
|
2012-03-18 05:07:27 +00:00
|
|
|
end
|