id: echo-detect

info:
  name: Echo Protocol  Detect
  author: pussycat0x
  severity: info
  description: |
    Echo is a protocol that is used for debugging and measurement. It works by sending back all the data that was received from the source. The protocol works on TCP and UDP, typically on port 7.
  reference:
    - https://en.wikipedia.org/wiki/Echo_Protocol
  metadata:
    verified: true
    max-request: 1
    shodan-query: "port:7"
  tags: echo,network,js,udp,discovery

javascript:
  - pre-condition: |
      isUDPPortOpen(Host,Port);
    code: |
      let packet = bytes.NewBuffer();
      const c = require("nuclei/net");
      const cmd = Payload
      packet.WriteString(cmd)
      let conn = c.Open('udp', `${Host}:${Port}`);
      conn.SendHex(packet.Hex());
      const result = conn.RecvString()
      result

    args:
      Host: "{{Host}}"
      Port: 7
      Payload: "{{randstr}}"

    matchers:
      - type: dsl
        dsl:
          - "success == true"
          - contains(response, "{{randstr}}")
        condition: and
# digest: 4a0a0047304502203771c51a251d59f73e6e25144d452cef20342ddfd3d1a8e6fcba17992431be9e022100d2b74c387f449e3e7a0161de1462282ab4f60ce2e9412265e661bd5cfe874e8e:922c64590222798bb761d5b6d8e72950