id: ntp-version-detect

info:
  name: NTP Version Detection
  author: pussycat0x
  severity: info
  description: |
    Detects if a target host is running NTP Service on port 123.
  metadata:
    verified: true
    shodan-query: "NTP"
  tags: js,network,ntp,ntpsec,udp,javascript

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

    code: |
      const c = require("nuclei/net");
      const payload = "160203e80000000000000000";
      const conn = c.Open('udp', `${Host}:${Port}`);
      conn.SendHex(payload);
      let resp = conn.RecvFullString(2048);
      resp;

    args:
      Host: "{{Host}}"
      Port: 123

    matchers:
      - type: dsl
        dsl:
          - contains_all(response, "version","processor","system")

    extractors:
      - type: regex
        group: 1
        regex:
          - 'version="([^"]+)"'
# digest: 4b0a0048304602210082d256e97de90a837a001646571ae3d6f52267a74345e5263249aeb37a9693fe022100ab683554375e0a730e714aab5b34dcd35804cd6d42bcefda140822fd3d04b473:922c64590222798bb761d5b6d8e72950