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"
  tags: js,network,smb,enum
javascript:
  - 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: 4a0a0047304502201f1bce289db0da4b874db6e316d0da4b0eab1315da8c215e0f7dea5f36e38ace022100a608fc001b860f1ccf6eafa1af9179cbb29685994d451688ebcccf0680b0c4e4:922c64590222798bb761d5b6d8e72950