Day 1 — Linux PrivEsc

Today is my Day 1 and I am going to solve machine named Linux PrivEsc on TryHackMe lets goo!!!!

misconfigured Debian VM with multiple ways to get root! SSH is available. Credentials: user:password321

Service Exploits

using nmap

open ports

I found misconfiger in sql login with out password

Execute the following commands on the MySQL shell to create a User Defined Function (UDF) "do_system" using our compiled exploit:

A user-defined function (UDF) is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment. UDFs are usually written for the requirement of its creator.

What is BLOB in MySQL?

BLOB, which stands for a Binary Large Object, is a MySQL data type that can store images, PDF files, multimedia, and other types of binary data.

Use the function to copy /bin/bash to /tmp/rootbash and set the SUID permission:

SERVICE EXPLOIT

Weak File Permissions - Readable /etc/shadow

Read only => r

What hashing algorithm was used to produce the root user's password hash?

SHA-512 Crypt

Weak File Permissions - Writable /etc/shadow

Write only

Generate a new password hash with a password of your choice:

mkpasswd -m sha-512 newpasswordhere

openssl passwd newpasswordhere

Sudo - Shell Escape Sequences

Visit GTFOBins (https://gtfobins.github.io) and search for some of the program names. If the program is listed with “sudo” as a function, you can use it to elevate privileges, usually via an escape sequence.

Task 7 — Sudo — Environment Variables

Using LD_PRELOAD

ldd /usr/sbin/apache2

Cron Jobs - File Permissions

using nc in kali

Cron Jobs - PATH Environment Variable

Note that the PATH variable starts with /home/user which is our user's home directory.

Create a file called overwrite.sh in your home directory with the following contents:

chmod +x /home/user/overwrite.sh

Last updated