Simple Network Management Protocol Hacking
The goal of this lab was to retrieve a valid set of credentials and establish a shell on one of the machines on a LAN.
I started by scanning the network to find live hosts and then which ports and services they were running. Via this scanning, I determined the following:
- The host @ 10.10.10.5 had filtered or closed ports for TCP connections, but it had port 161 open for UDP connections as it was running SNMP Version 1 on that port. Furthermore, nmap found a valid community string (public) for that service.
- The host @ 10.10.10.20 was possibly running SNMP, but not definitely as port 161 returned an open | filtered state when tested using UDP
- The host @ 10.10.10.20 had ports 139 and 445 open (139 for TCP connections for NetBIOS over IP sessions using SMB and port 445 for SMB over IP)
- The host @ 10.10.10.20 was running an old server OS (Service Pack 1)
All of this was interesting, and bearing in mind the goals of the lab, it seemed most likely that I would be able to find credentials via SNMP which would then help me gain a shell via NetBIOS on the other machine.
I therefore started enumerating the SNMP service running on port 161 @ 10.10.10.5 using an nmap script. This script found two valid community strings (public and private). Version 1 of SNMP actually sends these strings in plain text so they could have been sniffed, but I used a brute force attack. SNMP uses encryption for the strings, so brute force attacks are necessary. I tried the same attack against the host @ 10.10.10.20 but this returned no results.
Now that I had valid community strings, I could start to dig deeper into the data contained in the SNMP Management Information Base (MIB).
Objects (properties of devices being managed using SNMP) have unique addresses in MIBs. We can reference these using a numbering system. I was interested in trying to find usernames, so I used the Object IDentifier (OID) of 1.3.6.1.4.1.77.1.2.25 (a useful one to know!) This gave me three usernames - so far so good!
I also tried looking through all of the data I could loot using SNMP, but it was too much so it does make sense to focus on specific data you want to retrieve. For example, I found the name of the device @ OID 1.3.6.1.2.1.1.5.0
Even though I had successfully found community strings using nmap, I decided to see if a different tool (onesixtyone) could achieve the same - it did find public but not private.
Moving forwards, I decided to try using the discovered usernames to target the NetBIOS service running on the host @ 10.10.10.20 so I put them into a .txt file.
I then used this .txt file of usernames to target a brute force attack. My thinking was that people tend to reuse usernames across networks for different purposes. I tried with Hydra first of all, since it is fast, but it did not work. This was disappointing, so I tried the msfconsole module to brute force an SMB login. This worked.
Despite having worked, the module was slow, so I tried Patator. I ran it briefly first of all so I could get a failed logon string. I then used this to narrow down the results and was happy to see that Patator worked and was much faster than the msfconsole module. I then tried it again by excluding the logon failed code instead of the string and got the same result.
Armed now with a username:password set of credentials, I fired up a psexec attack in msfconsole and successfully obtained a reverse meterpreter shell. I migrated the process, dumped the SAM hashes and tried to crack them. Hashcat successfully found one more password, but could not find the password for the user called german, even with a larger wordlist. Still, the lab had been completed as the looted data from the SNMP service had led me to a successful shell on a machine on the network!