cybersecurity · intermediate · ~15 min · safe pentest lab

Phishiness score

Combine heuristics into a score.

Challenge

Combine several weak phishing signals into a single score — how a classifier triages URLs when no one trait is conclusive.

Task

Implement int phishy_score(const char *url) that adds 1 for each trait the URL exhibits and returns the total.

Traits, +1 each:

  • the URL contains @;
  • the URL length is greater than 75;
  • the host right after // starts with a digit (an IP literal);
  • the URL contains more than 4 . characters.

Input

  • url: a NUL-terminated URL string the grader passes.

Output

Returns int: the sum of matched traits (0..4).

Example

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)

Edge cases

  • Each trait is checked independently and summed.

Rules

  • Static string only — no URL fetch or network.

Input format

A NUL-terminated URL string url.

Output format

An int: the count of matched phishing traits (0..4).

Constraints

Sum four independent traits; static string only.

Starter code

#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.