šŸ”ŽšŸ¦¶Enumeration/Foothold

Writer is a Medium box from HTB and created by TheCyberGeek. This box features a website with a SQL login bypass and img_url parameter exploit allowing us to execute code. Once on the box we find a postfix and apt exploit allowing us to get root.

Before I begin each machine I kick off a full portĀ nmapĀ scan. This scan profile should normally not be used with theĀ -T5Ā as you might miss/get incorrect information/results:

Copy

Reviewing the results I can see PortsĀ 22/80/445Ā open. Starting withĀ SMBĀ I useĀ enum4linuxĀ to pull some enumeration and directly access the share. I have no rights to the folders but I do find some accounts/users:

Copy

Next I navigate over to the website which is sitting onĀ Port 80. I’ve recently been trying to useĀ ffufĀ more in my day to day but highlighted Feroxbuster as well:

Story Bank website sitting on Port 80.

Story Bank website sitting on Port 80.

Copy

OR

Copy

Running the directory scans shows anĀ administrativeĀ directory. Navigating to it shows a login page. I useĀ admin/passwordĀ in the fields and capture the request in Burp Suite. I change the parameters to match for easier identification. I then copy the request and create aĀ req.txt. I useĀ ffufĀ to fuzz the username/password fields for possible SQL injection or login bypass.

I get a hit:

Copy
Story Bank Dashboard after the SQL Login Bypass.

Story Bank Dashboard after the SQL Login Bypass.

After logging into the environment I am presented with a dashboard. I can see an area to edit stories. After some trial and error I realize that if I intercept the request with Burp Suite I can also the imageĀ URLĀ to execute the code added to the end of the image:

āš  Attack Machine

Copy

I clickĀ Edit StoryĀ and clickĀ Browse. I upload the exploit.jpgĀ (created in the steps above) then browse toĀ HEREĀ to verify. Next, I upload a second image and intercept in Burp suite. Change ourĀ img_urlĀ request with:

Using the Edit Story to upload a malicious jpg on HTB Writer.

Using the Edit Story to upload a malicious jpg on HTB Writer.

Copy

A few seconds later the shell pops. I loaded LinPEAS onto the box and notice:

Copy

/etc/postfix/disclaimerĀ running every 5mins. I’ve previously run across a similar privesc regarding disclaimer. Reviewing the script I add in a reverse shell:

āš  Attack Machine

Copy

I then create a basic send mail script based offĀ HEREĀ and upload them both to the server:

Copy

Pulling them both to the server in a folder calledĀ crx. Once pulled I run the send mail script alongside the disclaimer copy noting the task above happens frequently:

šŸŽÆ Victim Machine

Copy

On my attack machine I kick off a reverse shell after transferring the files:

āš  Attack Machine

Copy

Once on the virtual machine I grab John’sĀ SSHĀ key and log back into the box:

šŸŽÆ Victim Machine

Copy

šŸ”Escalation to Root

āš  Attack Machine

Copy

I run LinPEAS again and noticeĀ aptĀ running as root. I can also see that I can write to the file.:

GTFOBinsĀ confirms my hunch. I echo a one-liner bash reverse shell into the file and wait the shell.

šŸŽÆ Victim Machine

Copy

āš  Attack Machine

Copy

Rooted

Published On: December 12th, 2021 / Categories: HTB, Technology / Tags: , , , , , , , , , , , /

Leave A Comment