Course contentsShow
← Security
Lesson 611 of 3,05213. Web Security - Injection AttacksFree lesson

Command Injection Testing and Detection

Testing for command injection vulnerabilities using manual techniques, automated scanners, and payload lists.

Command Injection Testing and Detection

What you'll learn: You'll discover how to identify command injection vulnerabilities using manual testing techniques, automated tools, and structured payload lists.

The Core Idea

Testing for command injection means systematically probing application inputs to see if they allow unintended operating system commands to execute. Think of it like trying different keys in a lock—you need methodical approaches to find which inputs "unlock" command execution. Detection combines hands-on testing with automated scanners to catch vulnerabilities developers might have missed.

Manual Testing Techniques

Start by identifying input fields that might interact with the system: search boxes, file upload names, configuration parameters, or URL parameters. Test with shell metacharacters like ;, |, &&, or backticks to see if the application sanitizes them properly.

For example, if a ping utility accepts a hostname, try entering 127.0.0.1; whoami or 127.0.0.1 | ls. Watch for unexpected behavior in responses or timing delays.

For blind command injection, where you don't see direct output, use timing-based tests with sleep 10 or out-of-band techniques like triggering DNS lookups to a domain you control.

Automated Scanning

Tools like Burp Suite's Intruder or command injection-specific scanners can systematically test hundreds of payloads against target parameters. They iterate through payload lists containing various shell metacharacters, command separators, and encoding variations across different platforms (Linux, Windows, etc.).

Payload Lists

Maintain organized collections of test payloads:

  • Basic separators: ; whoami, | whoami, && whoami
  • Encoded variations: URL-encoded, double-encoded
  • Platform-specific commands: ping, sleep, timeout
  • Obfuscation techniques: variable expansion, wildcards

Key Takeaway: Effective command injection detection combines manual creativity (testing context-specific inputs) with automated thoroughness (systematic payload fuzzing), always looking for both visible output and indirect evidence like timing anomalies or out-of-band signals.