cybersecurity · intermediate · ~15 min · safe pentest lab

Count open ports in nmap XML

Tally a marker in tool output.

Challenge

Implement int count_open_ports(const char *xml) returning the number of occurrences of the substring state="open".

Starter code

#include <string.h>

int count_open_ports(const char *xml) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.