cybersecurity · intermediate · ~15 min · safe pentest lab
Heuristic scoring with explicit, auditable rules.
Implement:
int phishy_score(const char *url);
For each rule the URL hits, add 1 to the score. Return the total. NULL → -1.
@.xn--.- AND a brand keyword from
{paypal, apple, bank, microsoft, google, amazon}
(case-insensitive).http:// or https:// if present./ (or
end of string).Structural smells are the cheapest first layer of any phishing detector. Get the score right and most of the work is done before any ML runs.
A NUL-terminated URL string.
Score >= 0, or -1 on NULL.
Bounded hostname length 256. Case-insensitive brand match.
int phishy_score(const char *url) {
/* TODO */
(void)url;
return 0;
}
Counting brand keywords in the path. Not enforcing the >= 3 in a run (instead counting total digits). Forgetting to skip the scheme.
No scheme. Hostname-only URL. URL with userinfo before @.
O(n) over the URL length.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.