Command injections

Hacktricks

PayloadAlltheThings

PortSwigger

Injection operators

Injection Operator 	Injection Character 	URL-Encoded Character 	Executed Command
Semicolon 	; 	%3b 	Both
New Line 	\n 	%0a 	Both
Background 	& 	%26 	Both (second output generally shown first)
Pipe 	| 	%7c 	Both (only second output is shown)
AND 	&& 	%26%26 	Both (only if first succeeds)
OR 	|| 	%7c%7c 	Second (only if first fails)
Sub-Shell 	`` 	%60%60 	Both (Linux-only)
Sub-Shell 	$() 	%24%28%29 	Both (Linux-only)

Linux

printenv 	Can be used to view all environment variables
Spaces 	
%09 	Using tabs instead of spaces
${IFS} 	Will be replaced with a space and a tab. Cannot be used in sub-shells (i.e. $())
{ls,-la} 	Commas will be replaced with spaces
Other Characters 	
${PATH:0:1} 	Will be replaced with /
${LS_COLORS:10:1} 	Will be replaced with ;
$(tr '!-}' '"-~'<<<[) 	Shift character by one ([ -> \)

Blacklisted Command Bypass

Windows

Filtered Character Bypass

Blacklisted Command Bypass

Evasion Tools

Linux

A handy tool we can utilize for obfuscating bash commands is Bashfuscator.

Windows

There is also a very similar tool that we can use for Windows called DOSfuscation. Unlike Bashfuscator, this is an interactive tool.

We can even use tutorial to see an example of how the tool works. Once we are set, we can start using the tool, as follows:

Finally, we can try running the obfuscated command on CMD, and we see that it indeed works as expected:

Last updated