cybersecurity · intermediate · ~15 min · safe pentest lab
Decide whether a shadow hash uses a weak (fast-to-crack) scheme.
Turn scheme knowledge into a verdict:
int is_weak_shadow_hash(const char *h);
Return 1 if the hash is weak — plaintext/unknown, traditional DES (13 chars), or md5crypt ($1$). sha256crypt/sha512crypt/yescrypt/bcrypt are strong (0).
A hash string.
1 if weak, else 0.
Unknown/empty is treated as weak (conservative).
#include <stddef.h>
/* 1 if the crypt(3) hash is WEAK: plaintext/unknown, traditional DES (13 chars),
or md5crypt ($1$). sha256/sha512/yescrypt/bcrypt are strong (0). */
int is_weak_shadow_hash(const char *h){ (void)h; return 0; }
Treating an unrecognized scheme as strong; missing that md5crypt is weak despite the $ prefix.
$y$ and $2b$ are strong; a 13-char DES hash is weak.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.