Zipper is a hard-rated Linux machine from HackTheBox created by burmat. In the current post, my IP is 10.10.14.16, and the target’s IP is 10.10.10.108.
Zipper is a machine of hard complexity that demonstrates the significance of privileged API access and its potential exploitation to achieve Remote Code Execution (RCE). In this case we are working exclusively with Zabbix API. After exploiting the RCE, for privileges escalation the vulnerability used is PathHijacking.
Recon
Local Terminal
ping-c110.10.10.108PING10.10.10.108 (10.10.10.108) 56(84) bytes of data.64bytesfrom10.10.10.108:icmp_seq=1ttl=62time=176ms---10.10.10.108pingstatistics---1packetstransmitted,1received,0%packetloss,time0msrttmin/avg/max/mdev=175.677/175.677/175.677/0.000ms
Nmap scan report for 10.10.10.108Host is up, received echo-reply ttl 62 (0.17s latency).Scanned at 2023-07-1812:31:25-04 for 19sNot shown:65530 closed ports,2 filtered portsReason:65530 resets and 2 no-responsesSome closed ports may be reported asfiltereddueto--defeat-rst-ratelimitPORTSTATESERVICEREASON22/tcp open ssh syn-ack ttl 6280/tcp open http syn-ack ttl 6110050/tcp open zabbix-agent syn-ack ttl 62Read data files from:/usr/bin/../share/nmapNmap done:1IPaddress (1 host up) scanned in19.71 seconds Raw packets sent:94425 (4.155MB) | Rcvd:79589 (3.184MB)
Local Terminal
nmap-sCV-p22,80,1005010.10.10.108-oNTarget
Nmap scan report for 10.10.10.108Host is up (0.16s latency).PORTSTATESERVICEVERSION22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:|204859:20:a3:a0:98:f2:a7:14:1e:08:e0:9b:81:72:99:0e (RSA)|256 aa:fe:25:f8:21:24:7c:fc:b5:4b:5f:05:24:69:4c:76 (ECDSA)|_ 25689:28:37:e2:b6:cc:d5:80:38:1f:b2:6a:3a:c3:a1:84 (ED25519)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 works10050/tcp open tcpwrappedService Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelService detection performed. Please report any incorrect results at https://nmap.org/submit/ .Nmap done:1IPaddress (1 host up) scanned in22.73 seconds
If you are curious, you can search for "OpenSSH 7.6p1 Ubuntu 4 launchpad" to see which specific linux sub-system is using, in this case is "Debian Sid"
Port 80 is open with a website, let's see what is inside.
********************************************************* Wfuzz 3.1.0- The Web Fuzzer *********************************************************Target: http://10.10.10.108/FUZZTotal requests:220546=====================================================================ID Response Lines Word Chars Payload=====================================================================000025159: 3019L28W313 Ch "zabbix"000095510: 40311L32W300 Ch "server-status"
http://10.10.10.108/zabbix
Sign in as a guest, then explore the whole panel, at the Report > Availability Report you will find a file called "Zapper's Backup Script", we can assume that there is an user called "Zapper". we should try with the default password "zabbix" or "zapper"
Uh... the GUI access is disables, with the credentials confirmed now a good option is to search for other ways to login to "Zabbix"
There is a documentation about an API, so now we are going to use that way to login.
The response it's some kind of hash and a lot of information about the user... now that we are logged in, we can use the other API's feature... like scripts
First let's explore with script.get (Remember to replace the default "auth" with the hash retrieved from the previous command).
Looks like it received the script very well, now we need to prepare the reverse shell, by using two shells, one listening and other executing the command.
And done! We are in... but the shell doesn't last long... we need and additional terminal and speed.
Our Local Terminal B is "Partially connected" to the target, we are going to prepare another listening port at our Local Terminal C, and prepare the command at B before activating A.
Finally, we are inside the machine... now we need a way to change our user.
Target Terminal [Zabbix]
zabbix@zipper:/$hostname-i127.0.1.1
Target Terminal [Zabbix]
zabbix@zipper:/$iduid=107(zabbix) gid=113(zabbix) groups=113(zabbix)zabbix@zipper:/$sudo-l#We don't have the password :(sudo:3incorrectpasswordattemptszabbix@zipper:/$cd/homezabbix@zipper:/home$lszapperzabbix@zipper:/home$cdzapperzabbix@zipper:/home/zapper$lsuser.txtutilszabbix@zipper:/home/zapper$catuser.txtcat:user.txt:Permissiondenied# :(zabbix@zipper:/home/zapper$cdutilszabbix@zipper:/home/zapper/utils$lsbackup.shzabbix-servicezabbix@zipper:/home/zapper/utils$catbackup.sshcat:backup.ssh:Nosuchfileordirectoryzabbix@zipper:/home/zapper/utils$catbackup.sh#!/bin/bash## Quick script to backup all utilities in this folder to /backups#/usr/bin/7za/backups/zapper_backup-$(/bin/date+%F).7z-pZippityDoDah/home/zapper/utils/*&>/dev/null
Well... for some reason we have reading permission at another user folder... and inside to "backup.sh" we found a password.