cybersecurity · intermediate · ~15 min · safe pentest lab

Redact secrets from a log line

Practise in-place string editing without leaking original data.

Challenge

Implement void redact_secrets(char *line) that replaces, in place:

  • The value after password= (until space or end of line) with ***.
  • The value after token= (until space or end) with ***.

A line like user=alice password=hunter2 token=abc123 becomes user=alice password=*** token=***. The buffer is large enough to hold the result without growing.

Starter code

#include <string.h>

void redact_secrets(char *line) {
    /* TODO */
}

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