cybersecurity · beginner · ~15 min · safe pentest lab
Count probing for nonexistent accounts.
Count the auth-log lines that probe for nonexistent accounts — a telltale sign of username enumeration during a brute force.
Implement int count_invalid_user(const char *log) that returns how many lines contain "invalid user".
log: a NUL-terminated, newline-separated auth-log string baked into the harness.Returns int: the number of lines containing the substring "invalid user".
log: "Failed password for invalid user admin\nFailed password for root\nFailed password for invalid user test\n"
count_invalid_user(log) -> 2
A NUL-terminated newline-separated auth-log string log.
An int: the count of lines containing "invalid user".
Match the substring "invalid user". Static buffer only.
#include <string.h>
int count_invalid_user(const char *log) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.