cybersecurity · beginner · ~15 min · safe pentest lab

Tool category

Group tools by purpose.

Challenge

Map a tool name to the engagement phase it belongs to.

Task

Implement int tool_category(const char *name) that returns a category code for name.

Categories:

  • 1 = recon: nmap
  • 2 = password attacks: hydra, john
  • 3 = sniffing: wireshark
  • 0 = any other name

Input

  • name: a NUL-terminated tool name the grader passes.

Output

Returns int: the category code (0..3).

Example

tool_category("nmap")       ->   1
tool_category("hydra")      ->   2
tool_category("wireshark")  ->   3
tool_category("burpsuite")  ->   0   (not categorised here)

Edge cases

  • A tool not listed above returns 0.

Rules

  • Exact name comparison mapped to the category number.

Input format

A NUL-terminated tool name name.

Output format

An int category: 1=recon, 2=password, 3=sniffing, 0=other.

Constraints

nmap->1; hydra/john->2; wireshark->3; otherwise 0.

Starter code

#include <string.h>

int tool_category(const char *name) {
    /* TODO */
    return 0;
}

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