Skip to content

HTB "Writeups"

Posted on:October 31, 2023 at 12:00 AM

Bashed

nmap scan

scan with -Pn shows port 80
ALt text

Looking at the webpage, it looks like they have phpbash running on it

in the blog post, there is an screenshot with the file /uploads/phpbash.php, but that doesn’t lead to anything
Alt text
Alt text

dirbusting

running dirb http://10.10.10.68 shows a few directories
Alt text
phpbash.php can be found in the /dev directory
Alt text

opening up phpbash.php gives us a shell
alt text

getting root

Attempts at simple revshells in the webshell don’t work

running sudo -l shows that we can sudo scriptmanager with no password
Alt text
Additionally, the /scripts folder is only accessible as scriptmanager
Alt text

looking into scripts, we see that there’s a python file and text file, and that the python file makes the text file every so often.
Alt text
this probably means that a something is running test.py regularly as root to create the test.txt file.

We can abuse this by replacing test.py with a reverse shell. To get our file onto the server, we have to wget from the /var/www/html/uploads folder and then moving it to /scripts, as we don’t have write permissions in other folders.
Alt text
Alt text
Alt text

After that, we open a port and wait until we get a reverse shell.
Alt text

Solutions

The phpbash repository has not been updated since 2018, so it doesn’t look like there’s any updates that would fix privillage escalation issues.
Limiting users from accessing anything outside of the blog pages, such as /dev and /css could resolve this issue if the phpbash functionality isn’t required.

Disallowing www-data from sudoing with no password would prevent anyone on the webshell from modifying /scripts.

Another thing that could be done would be to switch from using a task scheduler that doesn’t run as root, as it allows scriptmanager to run things as root from the scripts folder.

Blue

nmap scan

Alt text

Alt text

Alt text

eternal blue time

Alt text

Alt text

Solution

Jerry

Nmap scans

scanning with no options is blocked Alt text

scanning with -Pn shows tomcat is running on port 8080 Alt text

scanning port 8080 with -sV -sC -Pn Alt text

Looking at the website

Logging in with admin: admin works, but it has no perms
insert screenshot of no perms here

Login enumeration

Run metasploit/run common passwords

results in tomcat: s3cret as a username password pair
insert screenshot here

Reverse WAR shell

Use msfvenom to generate reverse jsp shell specific command Alt text

upload shell.war under war uploads
insert screenshot of upload page here

listen on port ___ with nc -nvlp 3155

navigate to 10.10.10.95/shell
and then the reverse shell is connected Alt text

finding flag

navigate to C:\Users\Administrator\Desktop\flags and print flag Alt text

Solution

Change the credentials to a non-default username/password

Lame

nmap scan

Alt text
Alt text

searching up “Samba smbd 3.0.20-Debian exploit” results in this

rce

executing the exploit with metasploit gives us root access Alt text

solution

Update samba to >3.0.25rc3

Precious

nmap scan

Alt text

Alt text

Looking at the website, it looks like the websites you can put are very limited.
Alt text
I made a python http server and downloaded a pdf of that webpage
Alt text
Alt text Alt text

rce

looking up “pdfkit v0.8.6” gives us this, which is v0.8.7.2

running the exploit
Alt text
Alt text

There is the ssh password for henry under /home/ruby/.bundle/config
Alt text

we can ssh to henry@precious.htb with the password
Alt text

henry can run /usr/bin/ruby with no sudo password Alt text

We can find a ruby update dependency exploit here
Running it confirms that we are root. Alt text

Replacing the payload with a reverse shell gives us a root shell. Alt text Alt text

solution

Shocker

nmap scan

Alt text Alt text Alt text

dirb

Initial dirb shows index.html, as well as two inaccessible directories
Alt text

Dirbing on cgi-bin with .cgi doesn’t show anything, but we get a result for .sh
Alt text
Alt text

downloading /cgi-bin/user.sh gives us something that looks like something from uptime
Alt text

looking for “apache cgi exploits” gives us this

nmapping shows that the server is vulnerable
Alt text

we can run the exploit using metasploit
Alt text

it looks like we have access to /usr/bin/perl, so we can probably do a rev shell through that.
Alt text

running the script results in a rev shell
Alt text Alt text

solutions