id: privesc-yash

info:
  name: Yash - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    yash is a POSIX-compliant command shell that aims to be a lightweight and efficient alternative to other shells such as Bash or Zsh.
  reference:
    - https://gtfobins.github.io/gtfobins/yash/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,yash,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      yash -c 'whoami'

  - engine:
      - sh
      - bash
    source: |
      sudo yash -c '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: 490a004630440220407cbe43d57f1fdae8cb42d677464a71d661e4ad5e5f625a3c8046b40e9a7c2e0220090af158add8ff1477e2996116208ad71e0c659f5975505ecc9c7a4fee7d91fe:922c64590222798bb761d5b6d8e72950