1. Introduction
Extracting password hashes is a critical skill in the field of password recovery, digital forensics, and cybersecurity research. On MacOS systems, password hashes are protected using advanced cryptographic algorithms, with PBKDF2-SHA512 being the current standard. This article provides a comprehensive, step-by-step guide on how to extract hashes (PBKDF2-SHA512) from MacOS systems, covering technical processes, legal considerations, and best practices for secure handling. Whether you are a security professional, penetration tester, or digital investigator, understanding the intricacies of MacOS password storage and extraction is essential for responsible and effective password recovery.
2. Understanding PBKDF2-SHA512 in MacOS
2.1 What is PBKDF2-SHA512?
PBKDF2-SHA512 stands for Password-Based Key Derivation Function 2 using the SHA-512 hash algorithm. PBKDF2 is a key derivation function recommended by NIST SP 800-132 for securely hashing passwords. It works by applying a pseudorandom function (in this case, SHA-512) to the input password along with a cryptographic salt and repeats the process for a configurable number of iterations. This makes brute-force and dictionary attacks significantly more difficult, as each password guess requires substantial computation.
2.2 Role in MacOS Password Security
Since OS X 10.8 (Mountain Lion), MacOS has adopted PBKDF2-SHA512 for storing user password hashes. This approach aligns with industry best practices for password security, as outlined by organizations like OWASP and CIS. The use of a strong, slow hash function with a unique salt for each user ensures that even if hashes are extracted, they are resistant to common attack vectors such as precomputed rainbow tables and parallelized cracking attempts. For a deeper understanding of the underlying hash algorithm, see SHA-512: The Pillar of Cryptographic Security.
3. Legal and Ethical Considerations
3.1 Responsible Disclosure
Extracting password hashes from any system, including MacOS, must be approached with a strong sense of responsibility and legality. Unauthorized access or extraction of password hashes is illegal under laws such as the Computer Fraud and Abuse Act (CFAA) in the United States and similar statutes worldwide. Always ensure you have explicit, documented authorization before attempting any password recovery or hash extraction on systems you do not own.
3.2 Permissible Use Cases
Permissible scenarios for extracting PBKDF2-SHA512 hashes include:
- Recovering lost passwords for systems you own or manage
- Digital forensics investigations with proper legal authority
- Penetration testing and red teaming with written client consent
- Security research in controlled, non-production environments
4. Overview of the MacOS Password Storage System
4.1 Keychain and Password Hash Storage
MacOS uses two main mechanisms for storing authentication data:
- Keychain: Primarily stores user credentials, certificates, and secure notes. It is not used for storing login password hashes.
- Directory Services: Stores user account information, including password hashes, in system files accessible only by privileged users.
4.2 Relevant System Files and Directories
On modern MacOS systems, user password hashes are stored in the following locations:
- /var/db/dslocal/nodes/Default/users/: Contains user property list (.plist) files, which store hashed password data in the ShadowHashData field.
- /var/db/shadow/hash/: Used in older versions of MacOS (pre-10.7) for storing password hashes.
.plist
files to hashcat-compatible formats, consider using the plist MacOSX file converter to hash.
5. Prerequisites and Tools
5.1 Required Permissions and Access
To extract PBKDF2-SHA512 hashes from MacOS, you must have:
- Root or administrative access to the target system. Standard users cannot access the necessary files.
- Physical or remote access with the ability to run commands as sudo or via single-user mode.
5.2 Recommended Tools and Utilities
Several tools and utilities can assist in extracting and parsing password hashes:
- Terminal: The built-in MacOS command-line interface.
- Plutil: Utility for reading and converting property list files.
- Python: For parsing and decoding binary plist data.
- Hashcat or John the Ripper: For password recovery and hash cracking (see Hashcat and John the Ripper).
- Plist Editor: For manual inspection of .plist files (optional).
6. Locating Password Hashes on MacOS
6.1 Directory Services and Shadow Hashes
MacOS stores user account information in Directory Services, specifically in property list files located at /var/db/dslocal/nodes/Default/users/. Each user has a corresponding .plist file named after their username (e.g., alice.plist
). The ShadowHashData attribute within these files contains the PBKDF2-SHA512 hash and related parameters.
6.2 Navigating System Files
To locate the relevant files:
sudo ls /var/db/dslocal/nodes/Default/users/
This command lists all user property list files. To view the contents of a specific user’s file:
sudo plutil -p /var/db/dslocal/nodes/Default/users/USERNAME.plist
Replace USERNAME with the target account’s username. Look for the ShadowHashData field, which holds the encoded password hash.
7. Extracting PBKDF2-SHA512 Hashes Step-by-Step
7.1 Accessing the MacOS Terminal
Open the Terminal application, which can be found in Applications > Utilities. You must have administrative privileges to proceed.
7.2 Identifying the Target User
List all users on the system:
dscl . list /Users
Identify the username for which you want to extract the PBKDF2-SHA512 hash.
7.3 Dumping the Directory Services Database
To access the user’s property list file:
sudo cat /var/db/dslocal/nodes/Default/users/USERNAME.plist > ~/Desktop/USERNAME.plist
This copies the file to your desktop for analysis. Alternatively, you can view it directly:
sudo plutil -p /var/db/dslocal/nodes/Default/users/USERNAME.plist
7.4 Isolating the Hash Data
Within the USERNAME.plist, locate the ShadowHashData field. This field contains a base64-encoded binary property list. To extract and decode it:
- Copy the base64 string from the ShadowHashData field.
- Save it to a file, e.g.,
shadowhash.b64
. - Decode the base64 data:
base64 -d shadowhash.b64 > shadowhash.bin
- Convert the binary plist to XML for readability:
plutil -convert xml1 shadowhash.bin -o shadowhash.xml
- Open
shadowhash.xml
in a text editor or useplutil -p shadowhash.xml
to parse it.
8. Interpreting the Extracted Hash
8.1 Hash Structure and Components
The extracted PBKDF2-SHA512 hash data typically includes:
- salt: A random value unique to each user, used to prevent precomputed attacks.
- iterations: The number of times the hashing function is applied, increasing computational cost.
- entropy: The actual password hash output.
<dict>
<key>SALTED-SHA512-PBKDF2</key>
<dict>
<key>entropy</key>
<data>...</data>
<key>iterations</key>
<integer>35000</integer>
<key>salt</key>
<data>...</data>
</dict>
</dict>
8.2 Typical Output Format
For password recovery tools like Hashcat or John the Ripper, you must convert the extracted data into their expected format. For example, Hashcat’s format for MacOS PBKDF2-SHA512 is:
$ml$iterations$salt$hash
Where:
- iterations: Number of PBKDF2 iterations (e.g., 35000)
- salt: Base64 or hex-encoded salt
- hash: Base64 or hex-encoded entropy
9. Safeguarding and Handling Extracted Hashes
9.1 Secure Storage Practices
Password hashes are highly sensitive data. Best practices for secure storage include:
- Store hashes only on encrypted drives or within secure containers.
- Limit access to authorized personnel with a legitimate need.
- Use strong access controls and audit logs to monitor hash access.
9.2 Avoiding Unintended Disclosure
To prevent accidental leaks:
- Never email or transmit hashes over unsecured channels.
- Shred or securely delete temporary files after use.
- Do not upload hashes to public forums or cloud services.
10. Troubleshooting Common Issues
10.1 Permission Errors
Permission denied errors are common when accessing system files. Solutions include:
- Ensure you are running commands with sudo or as root.
- Check that System Integrity Protection (SIP) is not blocking access. You may need to disable SIP in recovery mode for advanced operations, but this is not recommended on production systems.
- Verify that the target user’s .plist file exists and is not locked by another process.
10.2 Corrupted or Missing Data
If the ShadowHashData field is missing or corrupted:
- Check for recent system updates or disk errors that may have affected Directory Services.
- Review system logs for relevant error messages (
Console.app
orlog show
). - If possible, restore the .plist file from a backup.
11. Conclusion
Extracting PBKDF2-SHA512 hashes from MacOS systems is a technically demanding but essential process for password recovery, digital forensics, and security research. By following the steps outlined above—while strictly adhering to legal and ethical guidelines—you can reliably access and interpret password hash data stored in MacOS. Always prioritize secure handling and responsible disclosure to protect user privacy and system integrity. For further learning, consult the authoritative resources listed below.
12. Further Reading and Resources
- NIST SP 800-132: Recommendation for Password-Based Key Derivation
- OWASP Top Ten Security Risks
- Center for Internet Security (CIS) Benchmarks
- Hashcat: Advanced Password Recovery
- John the Ripper: Password Cracker
- SHA-512: The Pillar of Cryptographic Security
- plist MacOSX file converter to hash
- How password recovering works at Online Hash Crack
- Professional Password Audit, Testing & Recovery
- SANS Institute: Ethical Hacking and Legal Issues
- CISA: Data Protection Best Practices
- Apple Support: Change File Permissions
- BleepingComputer: Security News and Analysis
- Krebs on Security: Cybersecurity News
- Mandiant: Incident Response Resources