Command Injection --Write up for natas10

Problem: 



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. 


 Step 2: try to make use of the grep command.
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


After I tried a lot, I find the path is '/etc/natas_webpass/natas11 '.



the flag is :U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK

Popular posts from this blog

Phonebook - Hack the box Write up -- Web LDAP injection

wafwaf -- Hack The Box -- Web SQL injection

Cheat sheet for security+