Command Injection --Write up for natas10
Problem:
the url of the problem https://overthewire.org/wargames/natas/natas10.html
Step 1: view the source file.
As we can see, the command filter some characters: ';', '|', '&'.
When we type something in the input box, it will grep the word in 'dictionary.txt'.
Consequently, we cannot avoid implementing 'grep', and we cannot append our own command either because of the filter.
We are going to use 'grep .*' to realize the function of 'cat' because it will match all the characters in the file.
The command is like this:
grep .* /etc/passwd
Step 3: comment out the dictionary.txt
In addition, the original grep will match the strings in 'dictionary.txt' which is not contains what we need. So we use '#' to comment it out.
The command is like this:
grep .* /etc/passwd # dictionary.txt
Step 4: find the path of the password file.
what we should type in the input box is like this, but we should change the path:
.* /etc/passwd # dictionary.txt
the flag is :U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK