When dealing with advanced filtering solutions such as WAF, basic evasion technique may not work.
Case Manipulation
e.g
WHOAMI
, WhOaMi
This usually works because command blacklist may not check for different case variations.
This won’t work in Linux since Linux commands are case sensitive
On Linux, we have to use the following method to turn the command into an all-lowercase word:
We can use command like below as well:
Reversed Commands
Have a command template that switched reversed command back to normal.
e.g
Write imaohw
to execute whoami
.
First we have to get the reversed string of our command as follows:
We can execute the original command by reversing it back using a sub-shell ($()
).
On Windows, we can reverse string as such:
We can now use the below command to execute a reversed string with a PowerShell sub-shell (iex "$()"
), as follows:
Encoded Commands
We can utilize various encoding tools, like base64 and xxd.
e.g base64
Now we can create a command that will decode the encoded string in a sub-shell ($()
), and then pass it to bash
to be executed (i.e. bash<<<
), as follows:
On Windows,
We may also achieve the same thing on Linux, but we would have to convert the string from utf-8
to utf-16
before we base64
it, as follows:
Finally, we can decode the b64 string and execute it with a PowerShell sub-shell (iex "$()"
), as follows:
In addition to the techniques we discussed, we can utilize numerous other methods, like wildcards, regex, output redirection, integer expansion, and many others. We can find some such techniques on PayloadsAllTheThings.
Find the output of the following command using one of the techniques you learned in this section: find /usr/share/ | grep root | grep mysql | tail -n 1
94.237.59.67:40560
bash<<<$(base64%09-d<<<ZmluZCAvdXNyL3NoYXJlLyB8IGdyZXAgcm9vdCB8IGdyZXAgbXlzcWwgfCB0YWlsIC1uIDE=)