id: privesc-dash

info:
  name: Dash - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    dash is a POSIX-compliant shell that is commonly used as the default system shell on Debian-based systems. It is designed to be a lightweight and fast shell, suitable for scripting and system administration tasks. It aims to be compatible with the POSIX standard for shells, providing a minimalistic and efficient environment for running shell scripts.
  reference:
    - https://gtfobins.github.io/gtfobins/dash/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,dash,privesc,local

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

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

  - engine:
      - sh
      - bash
    source: |
      sudo dash -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: 490a0046304402206b902983b85252ee8566b012c90d8c552942e0781aafc72bc20dfb1294d6d0a80220739aaa3c21cae29f96b977cfb6e5b06da5936bf43e2174e9b67a97b07ec287fe:922c64590222798bb761d5b6d8e72950