Changed the conditions if/elsif to case statements
parent
75b559eea3
commit
6aad8b3a70
|
@ -11,7 +11,6 @@ class Metasploit3 < Msf::Post
|
||||||
include Msf::Post::File
|
include Msf::Post::File
|
||||||
include Msf::Post::Linux::System
|
include Msf::Post::Linux::System
|
||||||
|
|
||||||
|
|
||||||
def initialize(info={})
|
def initialize(info={})
|
||||||
super( update_info( info,
|
super( update_info( info,
|
||||||
'Name' => 'Linux Gather System and User Information',
|
'Name' => 'Linux Gather System and User Information',
|
||||||
|
@ -53,6 +52,8 @@ class Metasploit3 < Msf::Post
|
||||||
users = execute("/bin/cat /etc/passwd | cut -d : -f 1")
|
users = execute("/bin/cat /etc/passwd | cut -d : -f 1")
|
||||||
user = execute("/usr/bin/whoami")
|
user = execute("/usr/bin/whoami")
|
||||||
|
|
||||||
|
print_good("\tModule running as \"#{user}\" user")
|
||||||
|
|
||||||
installed_pkg = get_packages(distro[:distro])
|
installed_pkg = get_packages(distro[:distro])
|
||||||
installed_svc = get_services(distro[:distro])
|
installed_svc = get_services(distro[:distro])
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ class Metasploit3 < Msf::Post
|
||||||
save("Disk info", disks)
|
save("Disk info", disks)
|
||||||
save("Logfiles", logfiles)
|
save("Logfiles", logfiles)
|
||||||
save("Setuid/setgid files", uidgid)
|
save("Setuid/setgid files", uidgid)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,16 +107,17 @@ class Metasploit3 < Msf::Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_packages(distro)
|
def get_packages(distro)
|
||||||
packages_installed = nil
|
packages_installed = ""
|
||||||
if distro =~ /fedora|redhat|suse|mandrake|oracle|amazon/
|
case distro
|
||||||
|
when /fedora|redhat|suse|mandrake|oracle|amazon/
|
||||||
packages_installed = execute("rpm -qa")
|
packages_installed = execute("rpm -qa")
|
||||||
elsif distro =~ /slackware/
|
when /slackware/
|
||||||
packages_installed = execute("ls /var/log/packages")
|
packages_installed = execute("/bin/ls /var/log/packages")
|
||||||
elsif distro =~ /ubuntu|debian/
|
when /ubuntu|debian/
|
||||||
packages_installed = execute("dpkg -l")
|
packages_installed = execute("/usr/bin/dpkg -l")
|
||||||
elsif distro =~ /gentoo/
|
when /gentoo/
|
||||||
packages_installed = execute("equery list")
|
packages_installed = execute("equery list")
|
||||||
elsif distro =~ /arch/
|
when /arch/
|
||||||
packages_installed = execute("/usr/bin/pacman -Q")
|
packages_installed = execute("/usr/bin/pacman -Q")
|
||||||
else
|
else
|
||||||
print_error("Could not determine package manager to get list of installed packages")
|
print_error("Could not determine package manager to get list of installed packages")
|
||||||
|
@ -126,46 +127,47 @@ class Metasploit3 < Msf::Post
|
||||||
|
|
||||||
def get_services(distro)
|
def get_services(distro)
|
||||||
services_installed = ""
|
services_installed = ""
|
||||||
if distro =~ /fedora|redhat|suse|mandrake|oracle|amazon/
|
case distro
|
||||||
|
when /fedora|redhat|suse|mandrake|oracle|amazon/
|
||||||
services_installed = execute("/sbin/chkconfig --list")
|
services_installed = execute("/sbin/chkconfig --list")
|
||||||
elsif distro =~ /slackware/
|
when /slackware/
|
||||||
services_installed << "\nEnabled:\n*************************\n"
|
services_installed << "\nEnabled:\n*************************\n"
|
||||||
services_installed << execute("ls -F /etc/rc.d | /bin/grep \'*$\'")
|
services_installed << execute("ls -F /etc/rc.d | /bin/grep \'*$\'")
|
||||||
services_installed << "\n\nDisabled:\n*************************\n"
|
services_installed << "\n\nDisabled:\n*************************\n"
|
||||||
services_installed << execute("ls -F /etc/rc.d | /bin/grep \'[a-z0-9A-z]$\'")
|
services_installed << execute("ls -F /etc/rc.d | /bin/grep \'[a-z0-9A-z]$\'")
|
||||||
elsif distro =~ /ubuntu|debian/
|
when /ubuntu|debian/
|
||||||
services_installed = execute("/usr/bin/service --status-all")
|
services_installed = execute("/usr/sbin/service --status-all")
|
||||||
elsif distro =~ /gentoo/
|
when /gentoo/
|
||||||
services_installed = execute("/bin/rc-status --all")
|
services_installed = execute("/bin/rc-status --all")
|
||||||
elsif distro =~ /arch/
|
when /arch/
|
||||||
services_installed = execute("/bin/egrep '^DAEMONS' /etc/rc.conf")
|
services_installed = execute("/bin/grep '^DAEMONS' /etc/rc.conf")
|
||||||
else
|
else
|
||||||
print_error("Could not determine the Linux Distribution to get list of configured services")
|
print_error("Could not determine the Linux Distribuition to get list of configured services")
|
||||||
end
|
end
|
||||||
return services_installed
|
return services_installed
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_crons(users, user)
|
def get_crons(users, user)
|
||||||
if user == "root" and users != nil
|
if user == "root" && users != nil
|
||||||
users = users.chomp.split()
|
users = users.chomp.split()
|
||||||
users.each do |u|
|
users.each do |u|
|
||||||
if u == "root"
|
if u == "root"
|
||||||
vprint_status("Enumerating as root")
|
vprint_status("Enumerating as root")
|
||||||
cron_data = ""
|
cron_data = ""
|
||||||
users.each do |u|
|
users.each do |usr|
|
||||||
cron_data += "*****Listing cron jobs for #{u}*****\n"
|
cron_data += "*****Listing cron jobs for #{usr}*****\n"
|
||||||
cron_data += execute("crontab -u #{u} -l") + "\n\n"
|
cron_data += execute("crontab -u #{usr} -l") + "\n\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
vprint_status("Enumerating as #{user}")
|
vprint_status("Enumerating as \"#{user}\"")
|
||||||
cron_data = "***** Listing cron jobs for #{user} *****\n\n"
|
cron_data = "***** Listing cron jobs for #{user} *****\n\n"
|
||||||
cron_data += execute("crontab -l")
|
cron_data += execute("crontab -l")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Save cron data to loot
|
# Save cron data to loot
|
||||||
return cron_data
|
return cron_data
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue