14. Enumeration - SNMP

Used to monitor + manage network devices and send configuration tasks/change settings remotely. Transmits control commands over UDP 161 Enables use of traps over UDP162 - Data packets sent from SNMP server -> client without being explicitly requested. SNMP trap sent to client once specific event occurs server-side.

For the SNMP client and server to exchange the respective values, the available SNMP objects must have unique addresses known on both sides. This addressing mechanism is an absolute prerequisite for successfully transmitting data and network monitoring using SNMP.

MIB

To ensure that SNMP access works across manufacturers and with different client-server combinations, the Management Information Base (MIB) was created.

OID

SNMPv1

SNMPv2

SNMPv3

Community Strings

Default configuration

stejwes@htb[/htb]$ cat /etc/snmp/snmpd.conf | grep -v "#" | sed -r '/^\s*$/d'

sysLocation    Sitting on the Dock of the Bay
sysContact     Me <me@example.org>
sysServices    72
master  agentx
agentaddress  127.0.0.1,[::1]
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
rocommunity  public default -V systemonly
rocommunity6 public default -V systemonly
rouser authPrivUser authpriv -V systemonly

Dangerous Settings

Some dangerous settings that the administrator can make with SNMP are:

Settings Description
rwuser noauth Provides access to the full OID tree without authentication.
rwcommunity <community string> <IPv4 address> Provides access to the full OID tree regardless of where the requests were sent from.
rwcommunity6 <community string> <IPv6 address> Same access as with rwcommunity with the difference of using IPv6.

Footprinting the Service

For footprinting SNMP, we can use tools like snmpwalk, onesixtyone, and braa. Snmpwalk is used to query the OIDs with their information. Onesixtyone can be used to brute-force the names of the community strings since they can be named arbitrarily by the administrator. Since these community strings can be bound to any source, identifying the existing community strings can take quite some time.

SNMPwalk

 snmpwalk -v2c -c public 10.129.14.128

Often, when certain community strings are bound to specific IP addresses, they are named with the hostname of the host, and sometimes even symbols are added to these names to make them more challenging to identify. However, if we imagine an extensive network with over 100 different servers managed using SNMP, the labels, in that case, will have some pattern to them. Therefore, we can use different rules to guess them. We can use the tool crunch to create custom wordlists. Creating custom wordlists is not an essential part of this module, but more details can be found in the module Cracking Passwords With Hashcat.

OneSixtyOne

stejwes@htb[/htb]$ sudo apt install onesixtyone
stejwes@htb[/htb]$ onesixtyone -c /opt/useful/SecLists/Discovery/SNMP/snmp.txt 10.129.14.128

Once we know a community string, we can use it with braa to brute-force the individual OIDs and enumerate the information behind them.

Braa

stejwes@htb[/htb]$ sudo apt install braa
stejwes@htb[/htb]$ braa <community string>@<IP>:.1.3.6.*   # Syntax
stejwes@htb[/htb]$ braa public@10.129.14.128:.1.3.6.*

Once again, we would like to point out that the independent configuration of the SNMP service will bring us a great variety of different experiences that no tutorial can replace. Therefore, we highly recommend setting up a VM with SNMP, experimenting with it, and trying different configurations. SNMP can be a boon for an I.T. systems administrator as well as a curse for Security analysts and managers alike.