cybersecurity · intermediate · ~15 min · safe pentest lab
Flag traversal indicators in a path.
Flag an HTTP request path that shows path-traversal indicators — useful when reviewing captured (authorised) traffic for probing attempts.
Implement int is_suspicious_path(const char *path) that returns 1 if path contains "../" (traversal) or "etc/passwd", and 0 otherwise.
path: a NUL-terminated request path the grader provides.Returns 1 if either marker is present, 0 otherwise.
is_suspicious_path("/files/../../etc/passwd") -> 1
is_suspicious_path("/index.html") -> 0
A NUL-terminated request path.
1 if path contains "../" or "etc/passwd"; otherwise 0.
Substring tests for "../" and "etc/passwd".
#include <string.h>
int is_suspicious_path(const char *path) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.