Post

Files Privilege Escalation - Linux PE.

Linux Privilege escalation sensitive files.

Files Privilege Escalation - Linux PE.

There are various sensitive files within a system that can lead us to privilege escalation. Below, some of these escalations are detailed.

/etc/passwd

If we have write permissions in the /etc/passwd file we can perform two different types of attack.

  1. Creating a new user.
  2. Changing root password.

0

Creating a new user.

We can just write a new user with root privileges.
pentester: -> Username.
::: -> No password.
0: -> User ID (UID). If UID = 0 means that our user has superuser privileges.
0: -> Group ID (GID). If GID = 0 means that we are part of the root group.
,,,:: -> Empty camps.
/: -> Home directory.
/bin/bash -> User shell.

1
pentester::0:0:,,,:/:/bin/bash

1

2

Changing root password.

The second technique we are going to exploit is very similar. The difference between them resides in the fact that instead of creating a new user, this time we are going to change root password. In our local machine we are going to execute openssl to create the new password:

1
openssl passwd <newPassword>

4

And then we just have to switch the x in the password field.

5

6



/etc/shadow Privilege Escalation.

If we can read the /etc/shadow file we can try to crack the hashes from the users.

Detection.

In the next scenario we can see that we have reading privileges for the /etc/passwd file.

Sublime's custom image

38

Exploitation.

Obtaining the hashes.

We need to get the line on /etc/shadow of the user we want to crack: 45 46

And we do the same with /etc/passwd: 55

We have to send the files back to our system. To do so, we can use different techniques depending on the situation we are facing.

Unshadowing

Once in our Attacker machine we have to unshadow the files as follows: 56

Cracking hashes.

Finally we will make the brute force using john. 51

52



log files

/etc/sudoers

This post is licensed under CC BY 4.0 by the author.