Exploiting Weak File Permissions
Certain system files can be taken advantage of to perform privilege escalation if the permissions on them are too weak. If a system file has confidential information we can read, it may be used to gain access to the root account. If a system file can be written to, we may be able to modify the way the operating system works and gain root access that way.
Exploiting /etc/shadow
file
/etc/shadow
fileReadable /etc/shadow
file
/etc/shadow
fileFind the file
Copy the hash in hash.txt and crack using john
Writable /etc/shadow
file
/etc/shadow
fileMake a new password and user
Edit the /etc/shadow
file and replace the original root user's password hash with the one you just generated.
/etc/shadow
file and replace the original root user's password hash with the one you just generated.Exploiting /etc/passwd
file
/etc/passwd
fileWritable /etc/passwd
file
/etc/passwd
fileThe /etc/passwd
file contains information about user accounts. It is world-readable, but usually only writable by the root user.
Historically, the /etc/passwd file contained user password hashes, and some versions of Linux will still allow password hashes to be stored there.
Find the file and check it's world writable
Generate a new password hash with a password of your choice
Add the new password
Add it to existing root user
Edit the /etc/passwd
file and place the generated password hash between the first and second colon (:) of the root user's row (replacing the "x").
Add a new user
Copy the root user's row and append it to the bottom of the file, changing the first instance of the word "root" to "newroot" and placing the generated password hash between the first and second colon (replacing the "x").
Last updated