cybersecurity · intermediate · ~15 min · safe pentest lab
Combine heuristics into a score.
Combine several weak phishing signals into a single score — how a classifier triages URLs when no one trait is conclusive.
Implement int phishy_score(const char *url) that adds 1 for each trait the URL exhibits and returns the total.
Traits, +1 each:
@;// starts with a digit (an IP literal);. characters.url: a NUL-terminated URL string the grader passes.Returns int: the sum of matched traits (0..4).
phishy_score("https://example.com") -> 0
phishy_score("http://1.2.3.4/p") -> 1 (IP literal)
phishy_score("http://a@1.2.3.4.5.6") -> 2 (@ and >4 dots)
A NUL-terminated URL string url.
An int: the count of matched phishing traits (0..4).
Sum four independent traits; static string only.
#include <string.h>
int phishy_score(const char *url) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.