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.
- Independent format for storing device info
- Text file, all queryable snmp objects listed in standardized tree hierarchy
- Contains atleast one
oidwhich in addition to necessary unique addr/name, also has info about type,access right, descriptions of an object - MIB files written inAbstract Syntax Notation One(ASN.1) based ASCII format. MIBs do not contain data but explain where to find which info and what it looks like.
OID
- Node in hierarchical namespace
- Sequence number uniquely identifies each node
- Longer chain = more specific information
- Many nodes in OID tree contain nothing xcept refs to those below
- OIDs consist of integers + usually concatenated by dot notation. Lookup many MIBs for associated OIDs in
Object Identifier Registry
SNMPv1
- Used net mgmt + monitor
- First version, still used in small nets
- Retrieval of info from net device, config of device, provide traps (notifications of events)
- ** NO BUILT IN AUTHENTICATION ** - Anyone can read/modify net data
- ** DOES NOT SUPPORT ENCRYPTION ** all data sent in plaintext, easily intercepted
SNMPv2
- Existed in diff versions - Modern =
v2c-cindicating community-based SNMP- W.r.t security, snmpv2 on par with snmpv1 and has been extended with add'tl funcs. from artybased snmp no longer in use.
- Significant prob. with initial execution of SNMP protocol is that the
community stringthat provides security is only transmitted in plain text meaning it has no encryption
SNMPv3
- Security increased enormously for v3 - has user/pw authentication and transmission encryption (via
pre-shared key) - Complexity also increases to same extent with significantly more configuration options than v2c
Community Strings
- Can be interpreted as passwords that are used to determine whether requested info can be viewed or not
- Important: Man y orgs still use v2; transition to v3 can be complex but services still need to be active.
- This causes admins to be concerned and creates problems they want to avoid. Lack of knowledge about how the information can be obtained and how we as attackers use it makes the admin's approach seem inexplicable - At the same time, lack of encryption of data sent is also a problem. Every time community strings are sent over the network they can be intercepted and read.
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.