cybersecurity · beginner · ~10 min · safe pentest lab
Case-insensitive marker detection in a log line.
Flag a Log4Shell exploitation attempt by spotting the ${jndi: marker in a log line.
Implement int has_jndi_marker(const char *line) that returns 1 if line contains the literal ${jndi: (case-insensitive), else 0.
line: a NUL-terminated log line the grader passes.Returns int: 1 if the marker is present (any case), 0 otherwise (NULL also returns 0).
has_jndi_marker("user-agent: ${jndi:ldap://x/a}") -> 1
has_jndi_marker("X: ${JNDI:rmi://y}") -> 1 (case-insensitive)
has_jndi_marker("normal request line") -> 0
has_jndi_marker("mentions jndi: but no brace") -> 0
has_jndi_marker("${env:HOME}") -> 0
has_jndi_marker(NULL) -> 0
jndi: without the ${ prefix does not match.${...} lookups (${env:...}) do not match.${${::-j}ndi: are out of scope; this catches the common literal form.The Log4Shell signature ${jndi: in a log line is a high-signal indicator of an exploitation attempt. A detector flags it for review.
A NUL-terminated log line line.
An int: 1 if line contains ${jndi: (case-insensitive), else 0.
Case-insensitive literal match; detection only.
int has_jndi_marker(const char *line) {
/* TODO */
(void)line;
return 0;
}
Case-sensitive matching (misses ${JNDI:). Matching bare 'jndi'. Forgetting NULL.
Mixed case. Other ${...} lookups (env, sys) must not match.
O(n×len(needle)).
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.