cybersecurity · intermediate · ~15 min · safe pentest lab
Scan a streaming text log for stateful patterns (windows / streaks).
Implement int max_failed_attempts(const char *auth_log, const char *username) returning the longest consecutive run of failed login attempts for the given username in the supplied auth log.
Lines look like <date> sshd[N]: Failed password for <user> from <ip> (failure) or Accepted password for <user> (success). A successful login resets the streak.
#include <stdio.h>
#include <string.h>
int max_failed_attempts(const char *auth_log, const char *username) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.