id: hide-last-login-information

info:
  name: Hide SSH Last Login Information
  author: pussycat0x
  severity: unknown
  description: |
    SSH last login information helps detect unauthorized access but may expose user activity details to attackers.
  remediation: |
    Set PrintLastLog no in /etc/ssh/sshd_config to disable last login information and restart the SSH service.
  reference:
    - https://vishalraj82.medium.com/hardening-openssh-security-37f5d634015f
    - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209441
  metadata:
    verified: true
  tags: audit,config,ssh,auth

javascript:
  - pre-condition: |
      isPortOpen(Host,Port);
    code: |
      var m = require("nuclei/ssh");
      var c = m.SSHClient();
      c.Connect(Host,Port,User,Pass);
      const sshConfig = c.Run('cat /etc/ssh/sshd_config')
      sshConfig
      let result = "";
      if (!sshConfig.includes('PrintLastLog no')) {
      result += "Hide SSH Last Login Information; ";
      }
      else{
      exit();
      }
      result

    args:
      Host: "{{Host}}"
      Port: "22"
      User: "{{usernames}}"
      Pass: "{{passwords}}"

    matchers:
      - type: dsl
        dsl:
          - "success == true"

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