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: 4b0a00483046022100d90ab38dc8ffab3bce86252c146b5cb4162e7589cee17f7f7fe08e8fea47a891022100880623c138d2a4d7bd53df7e7f3366d54fb46fb07daaa6500ebfedf3b48d2dcf:922c64590222798bb761d5b6d8e72950