id: smb2-server-time

info:
  name: SMB2 Server Time - Detection
  author: DhiyaneshDK
  severity: info
  description: |
    Trying to retrieve the present date of the system along with the initiation date of an SMB2 server.
  reference:
    - https://nmap.org/nsedoc/scripts/smb2-time.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 = m.SMBClient();
      var response = c.ConnectSMBInfoMode(Host,Port);
      var systemTime = new Date(response.NegotiationLog.SystemTime * 1000).toISOString();
      var serverstartTime = new Date(response.NegotiationLog.ServerStartTime * 1000).toISOString();
      var result = "SystemTime: " + systemTime + " ServerStartTime: " + serverstartTime;
      result

    args:
      Host: "{{Host}}"
      Port: "445"

    matchers:
      - type: dsl
        dsl:
          - success

    extractors:
      - type: dsl
        dsl:
          - response
# digest: 4b0a004830460221009a96adc886265eda3850c124302c6ec2e458dbc911de780fe6f63375309ca1410221008924c2638f5364d72196885489b7a65a7af1fcff586deebda277dad7a7c10476:922c64590222798bb761d5b6d8e72950