PHPass' Portable Hash Hash
Technical details, regex signatures, and cracking commands for the PHPass' Portable Hash algorithm.
What is PHPass' Portable Hash?
The **PHPass Portable Hash** format, introduced in 2005 as part of the PHP password hashing extension (`phpass`), was designed as a lightweight, portable solution for securely storing user credentials in plain-text databases. Structurally, it encodes a salted SHA-1 hash using a custom base64-like alphabet (excluding easily confused characters like `l`, `1`, `O`, `0`) to mitigate visual ambiguity. The format begins with a `$P$` prefix, followed by a cost parameter (typically `2` for SHA-1), a 22-character salt derived from a cryptographic random number generator, and the 40-character SHA-1 hash of the concatenated password and salt. While intended for simplicity, its primary use-case was to provide a basic defense against brute-force attacks by enforcing per-user salts and a fixed iteration count, though it lacked formal cryptographic rigor. The format was later deprecated in favor of more secure schemes like bcrypt or Argon2 due to its inherent vulnerabilities.
The PHPass Portable Hash is vulnerable to cracking primarily due to its reliance on SHA-1, a cryptographic hash function now considered insecure for password storage due to its susceptibility to collision attacks and insufficient resistance to GPU/ASIC optimizations. The fixed iteration count (default of 500 hashes for SHA-1) is trivial for modern hardware, allowing attackers to perform brute-force or rainbow table attacks at high speeds. Additionally, while the salt mitigates some dictionary attacks, the 22-character salt space (derived from a 64-character alphabet) is insufficient to prevent precomputed attacks when combined with weak passwords. GPU-accelerated cracking tools, such as Hashcat, can evaluate millions of hashes per second, rendering the SHA-1-based scheme impractical for real-world security. The lack of adaptive work factors (unlike bcrypt) and reliance on a predictable iteration count further exacerbates its susceptibility to offline cracking.
Identifying PHPass' Portable Hash Hashes
Identifying a hash blindly is often difficult because multiple algorithms can output strings of the exact same length. For example, a standard 32-character hexadecimal string could be MD5, NTLM, MD4, or LM. To definitively identify PHPass' Portable Hash, security researchers analyze the hash against a strict regular expression (regex) signature (shown above) to find structural matches.
How to Crack PHPass' Portable Hash
If you need to recover the plaintext password for a PHPass' Portable Hash hash during a penetration test or forensics investigation, you must supply the correct module ID to your cracking software. Use the exact commands provided at the top of this page to target the hash successfully.