id: smb-enum-domains

info:
  name: SMB - Enum Domains
  author: DhiyaneshDK
  severity: info
  description: |
    SMB enumeration of domains is often part of the reconnaissance phase, where security professionals or attackers attempt to gather information about the target network to identify potential vulnerabilities.
  reference:
    - https://nmap.org/nsedoc/scripts/smb-enum-domains.html
  metadata:
    verified: true
    max-request: 1
    shodan-query: port:445
    product: dionaea
    vendor: dionaea
  tags: js,network,smb,enum,discovery

javascript:
  - pre-condition: |
      isPortOpen(Host,Port);
    code: |
      var m = require("nuclei/smb");
      var c = new m.SMBClient();
      var response = c.ListSMBv2Metadata(Host, Port);
      Export(response);

    args:
      Host: "{{Host}}"
      Port: "445"
    matchers:
      - type: dsl
        dsl:
          - "len(DNSDomainName) != 0"

    extractors:
      - type: json
        internal: true
        name: DNSDomainName
        json:
          - '.DNSDomainName'

      - type: json
        json:
          - '"DomainName: "+ .DNSDomainName '
# digest: 4a0a004730450221008afebbbe7bfd06e61beb2105769048b6761dca93cb8e868bfcd1f885d49be4bf02207dbcb7c1adaa4da64502cf29a1faa8f074b2b5e3dcd230e3638afe43f0ea4769:922c64590222798bb761d5b6d8e72950