Simple Network Management Protocol (SNMP)
Simple Network Management Protocol (SNMP)
Resource: https://book.hacktricks.xyz/network-services-pentesting/pentesting-snmp
SNMP - Simple Network Management Protocol is a protocol used to monitor different devices in the network (like routers, switches, printers, IoTs...).
Port: 161/162 UDP, 10161/10162 UDP if TLS is used
SNMP Versions
There are 2 important versions of SNMP:
Community Strings
As mentioned before, in order to access the information saved on the MIB you need to know the community string on versions 1 and 2/2c and the credentials on version 3.
The are 2 types of community strings:
Note that the writability of an OID depends on the community string used, so even if you find that "public" is being used, you could be able to write some values. Also, there may exist objects which are always "Read Only".
If you try to write an object a noSuchName or readOnly error is received**.**
In versions 1 and 2/2c if you to use a bad community string the server wont respond. So, if it responds, a valid community strings was used.
Enumeration
It is recommanded to install the following to see whats does mean each OID gathered from the device:
Finally comment the line saying "mibs :" in /etc/snmp/snmp.conf
If you know a valid community string, you can access the data using SNMPWalk or SNMP-Check:
Thanks to extended queries (download-mibs), it is possible to enumerate even more about the system with the following command :
SNMP has a lot of information about the host and things that you may find interesting are:
Dangerous Settings
In the realm of network management, certain configurations and parameters are key to ensuring comprehensive monitoring and control.
Access Settings
Two main settings enable access to the full OID tree, which is a crucial component in network management:
Both commands require a community string and the relevant IP address, offering full access irrespective of the request's origin.
SNMP Parameters for Microsoft Windows
A series of Management Information Base (MIB) values are utilized to monitor various aspects of a Windows system through SNMP:
SNMP Configuration files
SNMP RCE
SNMP can be exploited by an attacker if the administrator overlooks its default configuration on the device or server. By abusing SNMP community with write permissions (rwcommunity) on a Linux operating system, the attacker can execute commands on the server.
To extend SNMP services and add extra commands, it is possible to append new rows to the "nsExtendObjects" table. This can be achieved by using the snmpset command and providing the necessary parameters, including the absolute path to the executable and the command to be executed:
Injecting commands to run on the SNMP service requires the existence and executability of the called binary/script. The NET-SNMP-EXTEND-MIB mandates providing the absolute path to the executable.
To confirm the execution of the injected command, the snmpwalk command can be used to enumerate the SNMP service. The output will display the command and its associated details, including the absolute path:
When the injected command is read, it is executed. This behavior is known as run-on-read() The execution of the command can be observed during the snmpwalk read.
Shell with SNMP https://github.com/mxrch/snmp-shell
Alternatively, a reverse shell can be manually created by injecting a specific command into SNMP. This command, triggered by the snmpwalk, establishes a reverse shell connection to the attacker's machine, enabling control over the victim machine. You can install the pre-requisite to run this:
Or a reverse shell
Crack SNMP Passwords
Enumerate SNMP
Last updated