id: snmpv1-community-detect-string

info:
  name: SNMPv1 Public Community String - Detect
  author: matejsmycka
  severity: high
  description: |
    SNMPv1 was configured with the default public community string, which allows unauthorized users to query system information. This may expose sensitive details such as network configuration, running processes, and device information.
  reference:
    - https://hackers-arise.com/exploiting-snmpv1-for-reconnaissance/
    - https://hacktricks.boitatech.com.br/pentesting/pentesting-snmp
    - https://www.tenable.com/plugins/nnm/1344
    - https://linux.die.net/man/1/snmpwalk
  metadata:
    verified: true
    max-request: 1
    shodan-query: product:"SNMP"
  tags: js,udp,network,snmp,vuln

javascript:
  - pre-condition: |
      isUDPPortOpen(Host, Port);

    code: |
      const c = require("nuclei/net");
      const conn = c.Open('udp', `${Host}:${Port}`, `${Timeout}`);
      let community_string =  bytes.NewBuffer();
      community_string.WriteString(Community);
      let payload = "30290201010406";
      payload += community_string.Hex();
      payload += "a01c02040eb376f4020100020100"
      payload += "300e300c06082b060102010105000500" // VarBind list for sysName.0
      conn.SendHex(payload);
      let resp = conn.RecvFull(64);
      resp;

    args:
      Host: "{{Host}}"
      Port: 161
      Timeout: 2
      Community: "{{community_string}}"

    attack: clusterbomb

    payloads:
      community_string:
        - public

    matchers:
      - type: binary
        binary:
          - "0201010406"

    extractors:
      - type: regex
        group: 1
        regex:
          - "public.*\x00\x04.(.*)"
# digest: 4a0a00473045022025ba13e97437a09d2aa612adf6a95225bf1cb7792fa9f06254ec7fd1d4c7b1100221009c30846f7c8928da30c7ac65aa232b3fe4c445fca490d368c1a99cb45cb06ac2:922c64590222798bb761d5b6d8e72950