HTB Academy - Linux Privilege Escalation - Capability

‘Escalate the privileges using capabilities and read the flag.txt file in the “/root” directory. Submit its contents as the answer.’

I already following the step-by-step in module, but when I use ‘echo -e ‘:%s/^root:[^:]*:/root::/\nwq’ | /usr/bin/vim.basic -es /etc/passwd’ then ‘cat /etc/passwd | head -n1’ the ‘x’ from ‘root:x:0:0:root:/root:/bin/bash’ does not disappear, any clue how to remove the x from ‘root:x:0:0:root:/root:/bin/bash’?

same issue fro vim.basic cap_dac capabilty is already set which means we can over write the file but the file is read only that s y i guess we are unable to rewrite the file.

Unable to get any idea how to resolv this

tried lsattr and chattr but nothing is working out

Any hints would be helpful

I already finish this module, hint is use vim
then quit using :wq!

2 Likes

ya previously i was using !wq and !qa then it was throwing error now solved the lab

dont open the file with

/usr/bin/vim.basic /etc/passwd

Skip thios step and i used /\qw! instead of /\wq