Writeups

Linux Privilege Escalation - TryHackMe Medium Room

Task 1:


Login to [email protected] using password password321.

Task 2 - Service Exploit:

mysql was seen running in the server so used a classic mysql technique mentioned here

Task 3 - Weak File Permissions – Readable /etc/shadow


Since the file /etc/shadow could be read out by the user the hashed password of the root could be extracted which is this. Cracked the hash using john.

Task 4 - Weak File Permissions – Writable /etc/shadow


ls -l /etc/shadow showed that the file could be written by the current user.

mkpasswd -m sha-512 <new-password> could be used to add the password and can be replaced with the root user password to get the privilege escalated.

Task 5 - Weak File Permissions – Writable /etc/passwd

Task 6 - Sudo Shell Escape Sequences:

Task 7 - Sudo Enviornment Variables

Task 8 - Cron Job File Permissions:

Task 9 - Cron Jobs:- PATH Environment Vatiable:

Task 10 - Cron Jobs:- Wildcards:

SUID/SGID

Task 11 - SUID/SGID Executables :- Known Exploits

Task 12 - SUID/SGID Executables :- Shared Object Injection

This should make the file with SUID open the just created file with root privileges 
And since it is a reverse shell\bash shell, 
It should spawn a bash shell with root privilege.

Task 13 - SUID/SGID Executables :- Environment Variables

Task 14 - SUID/SGID Executables :- Abusing Shell Features #1

Basically what it does is use a variable in bash as the path to the file which points to our function.
Since the PATH in the SUID/SGID File points to a bash function, it is executed before actually reaching out to the actual file path.

Task 15 - SUID/SGID Executables :- Abusing Shell Features #2

env -i SHELLOPTS=xtrace PS4='$(cp /bin/bash /tmp/rootbash; chmod +xs /tmp/rootbash)' /usr/local/bin/suid-env2

Password & Keys

Task 16 - Password & Keys :- History Files

Task 17 - Password & Keys :- Config Files

Task 18 - Password & Keys :- SSH Keys

NFS

Kernel Exploits: