Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/linux/gather/enum_protections.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Linux::Kernel8include Msf::Post::Linux::System910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Linux Gather Protection Enumeration',15'Description' => %q{16This module checks whether popular system hardening mechanisms are17in place, such as SMEP, SMAP, SELinux, PaX and grsecurity. It also18tries to find installed applications that can be used to hinder,19prevent, or detect attacks, such as tripwire, snort, and apparmor.2021This module is meant to identify Linux Secure Modules (LSM) in addition22to various antivirus, IDS/IPS, firewalls, sandboxes and other security23related software.24},25'License' => MSF_LICENSE,26'Author' => 'ohdae <bindshell[at]live.com>',27'Platform' => ['linux'],28'SessionTypes' => ['shell', 'meterpreter']29)30)31end3233def run34distro = get_sysinfo3536print_status "Running module against #{session.session_host} [#{get_hostname}]"37print_status 'Info:'38print_status "\t#{distro[:version]}"39print_status "\t#{distro[:kernel]}"4041print_status 'Finding system protections...'42check_hardening4344print_status 'Finding installed applications...'45find_apps4647if framework.db.active48print_status 'System protections saved to notes.'49end50end5152def report(data)53report_note(54host: session,55type: 'linux.protection',56data: data,57update: :unique_data58)59end6061def check_hardening62if aslr_enabled?63r = 'ASLR is enabled'64print_good r65report r66end6768if exec_shield_enabled?69r = 'Exec-Shield is enabled'70print_good r71report r72end7374if kaiser_enabled?75r = 'KAISER is enabled'76print_good r77report r78end7980if smep_enabled?81r = 'SMEP is enabled'82print_good r83report r84end8586if smap_enabled?87r = 'SMAP is enabled'88print_good r89report r90end9192if lkrg_installed?93r = 'LKRG is installed'94print_good r95report r96end9798if grsec_installed?99r = 'grsecurity is installed'100print_good r101report r102end103104if pax_installed?105r = 'PaX is installed'106print_good r107report r108end109110if selinux_installed?111if selinux_enforcing?112r = 'SELinux is installed and enforcing'113else114r = 'SELinux is installed, but in permissive mode'115end116print_good r117report r118end119120if yama_installed?121if yama_enabled?122r = 'Yama is installed and enabled'123else124r = 'Yama is installed, but not enabled'125end126print_good r127report r128end129end130131def find_apps132apps = %w[133truecrypt bulldog ufw iptables fw-settings logrotate logwatch134chkrootkit clamav snort tiger firestarter avast lynis135rkhunter tcpdump webmin jailkit pwgen proxychains bastille136psad wireshark nagios apparmor oz-seccomp honeyd thpot137aa-status gradm gradm2 getenforce aide tripwire paxctl138paxctld paxtest firejail auditd139]140141apps.each do |app|142next unless command_exists? app143144path = cmd_exec "command -v #{app}"145next unless path.start_with? '/'146147print_good "#{app} found: #{path}"148report path149end150end151end152153154