Level11
Unprotected command execution
Last updated
Was this helpful?
Unprotected command execution
Last updated
Was this helpful?
When we login as Level11 we get the following file in our home directory
level11.lua is a script that contain the following code :
The code is simple. It contains 1 function that that accept one argument called pass
from the information in the beginning of program :
By reading the code we know that we can exploit the command that executes our given data in the shell :
And with everything mentioned before keeping in mind what we must do is to save the data that is sent to the standard output in a file so it is not piped. So we can use the following command to get the hash:
What we are doing in our command is simply telling to finish the command by ;
and giving a new command that is to call the program getflag
and saving it's content in a file /tmp/flag11
.
So the Password to connect to the account level12 is fa6v5ateaw21peobuub8ipe6s
The function hash
calls a function called io.popen
, from the Official of Lua and this Stack Overflow we understand that the function popen
executes the argument passed to it in the shell. and then the result is read and return to the caller.
We also have an that accepts ant incoming socket connections and ask for password :
IF a password is passed then it calls the hash
function with the user provided password as it's argument and compares () the 2 hashes and if the password is not correct it prints Erf nope..
else it prints Erf nope..
and then closes the connection.
we know the server is running on the on port 5151
So to test it we can simply use the program (alias : nc) as follows :
So whatever we pass in as password will be passed to the string "echo "..pass.." | sha1sum"
. One IMPORTANT thing to keep in mind is that any data produced in the standard outputs will be to the next command which is sha1sum
Thanks to site we know that the original data that was hashed to f05d1d066fb246efe0c6f7d095f909a7a0cf34a0
is NotSoEasy