cybersecurity · beginner · ~15 min · safe pentest lab
Count successful authentications.
Count the successful logins in an auth log — correlating these with failures helps spot a brute force that finally got in.
Implement int count_accepted(const char *log) that returns how many lines contain "Accepted password".
log: a NUL-terminated, newline-separated auth-log string baked into the harness.Returns int: the number of lines containing the substring "Accepted password".
log: "Accepted password for bob\nFailed password for root\nAccepted password for amy\n"
count_accepted(log) -> 2
Failed password) are not counted.A NUL-terminated newline-separated auth-log string log.
An int: the count of lines containing "Accepted password".
Match the substring "Accepted password". Static buffer only.
#include <string.h>
int count_accepted(const char *log) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.