If the wget binary has the SUID bit set, It does not drop the elevated privileges and may be abused to access the file system. It may be used to do privileged writes or write files outside a restricted file system. This script automates the rewriting of the passwd
file of the victims machine
Firstly copy the /etc/passwd
or /etc/hosts
(depending on your attack surface) file of the victim to your host machine, using the following command:
scp user@host /etc/passwd .
( /etc/passwd
file)
After copying the /etc/passwd
file of the victim, it is time to run the exploit.
( sudo
since root privileges are needed to modify the /etc/passwd
file of the victim because of permission reasons)
The script will poison the given file and host it to the web using a custom HTTP server
.
Dynamic instructions will also be printed at the command line during the exploit execution as shown in the picture below.
The password for the root
user, is simply root
.
TryHackMe has an awesome machine that lets you play with this exploit.