id: disable-ssh-protocol-1

info:
  name: Disable SSH Protocol 1
  author: pussycat0x
  severity: low
  description: |
    Using SSH Protocol 1 is insecure as it lacks strong encryption and integrity checks, making it vulnerable to man-in-the-middle attacks, session hijacking, and other exploits. It is recommended to use SSH Protocol 2 for enhanced security.
  remediation: |
    Set Protocol 2 in /etc/ssh/sshd_config to disable SSH Protocol 1 and restart the SSH service.
  reference:
    - https://vishalraj82.medium.com/hardening-openssh-security-37f5d634015f
    - https://www.ktchost.com/blog/enable-ssh-protocol-2/
  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('Protocol 2')) {
      result += "Disable SSH Protocol 1; ";
      }
      else{
      exit();
      }
      result

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

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

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