id: privesc-sshpass

info:
  name: sshpass - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    sshpass is a command-line tool that provides a way to automatically input SSH passwords for password authentication. It is commonly used in scripts and automated processes where interactive password entry is not feasible.
  reference:
    - https://gtfobins.github.io/gtfobins/sshpass/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,sshpass,privesc,local

self-contained: true
code:
  - engine:
      - sh
      - bash
    source: |
      whoami

  - engine:
      - sh
      - bash
    source: |
      sshpass whoami

  - engine:
      - sh
      - bash
    source: |
      sudo sshpass whoami

    matchers-condition: and
    matchers:
      - type: word
        part: code_1_response
        words:
          - "root"
        negative: true

      - type: dsl
        dsl:
          - 'contains(code_2_response, "root")'
          - 'contains(code_3_response, "root")'
        condition: or
# digest: 4b0a00483046022100c9162852d30aaf04d1c07084230bd493a5785a7222866b7e4c249f4c384eaaf4022100db31e8c2e869ebda6aa552861701b090313dedfa33745a12bf57dacb15f1313c:922c64590222798bb761d5b6d8e72950