TryHackMe: Brute
Bruteforcing mysql creds then use it logs in on the web after that use log poisoning to gain shell the escalate privilege to another user and root

Table of contents
Reconnaissance
Nmap scan resulting 4 open ports.
Try to logs in FTP using anonymous credentials but it's failed. Then I opened the website and was immediately presented with a login form.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/9c713986fdc8cf1e8c79031540681f7104570b0a-375x272.png)
It will be very difficult if we don't have the username, Since the database MySQL is reachable from our network i will brute-force it first using default username which is root.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/8be3f2722a16c4caad8dd1823d5ac7dcdd79cb69-888x252.png)
Cracked! let's use it to access MySQL.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/98c2cbbb800774ce94e3023e84a1d64a67aa2880-1042x595.png)
Let's grab the hashed password and crack it using john.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/c0c63d3d9b7b747528cefe6ba07e3f4c77aa9724-909x205.png)
Got it, then let's use it to logs in on the web.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/05c7f3792756a21a271a1a511b3b6a57822e7cbe-1109x300.png)
Log Poisoning
Log? i clicked the Log button and nothing happen, i think it's log from FTP? then i tried to logs in FTP and comeback to web and got the log.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/0cac37ddee7236233b2b30364228c82935f4d3f2-1709x309.png)
Look at the log, our username used from login with FTP is reflected on the web, i think we can inject it with PHP script, i found a good reading for FTP poisoning here.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/b669f9a6d4e04c6b5d3eb094ad9f4d67b111629b-601x204.png)
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/e934ad09713d85b589f739c458c512ddc31d3ec0-1711x411.png)
Shell as www-data
Set up a netcat listener and using this payload below we can get reverse shell.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/a00a3ca70045fe399786f465d0c90de345b9d3f1-617x205.png)
Then navigate to home and found Adrian directory, inside Adrien directory there is a file named .reminder and i think it's a hint for us.
Shell as Adrian
Rules? best64? i think we should create a word list from word "ettubrute" + exclamation mark so it will be "ettubrute!", let's try it.
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/27f2d63442415e5ed3977a439b68f541c8619545-688x94.png)
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/249d9f95c0027a4c229e2470dd45817479b66b82-905x293.png)
Shell as Root
In the Adrian home directory there is interesting file called punch_in.sh.
The script is basically write 'Punched in at hours:min' to file named punch_in.
Then from here i running a pspy and found this:
![[Gambar tidak memiliki deskripsi]](https://cdn.sanity.io/images/7blsog1k/production/8188dc3a5c1ecd9ab9c37e742f572cc92632bfab-901x894.png)
The UID is 0 it's mean this is root running this command, and i think it's read file punch-in and use it like in the image above. Since we have permission to write on file punch-in let's try get reverse shell from it.
Don't forget to setup the netcat listener.