id: privesc-find

info:
  name: find - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    The find command in Linux is used to search for files and directories in a directory hierarchy based on various criteria such as name, type, size, and permissions. It is a powerful tool for locating files and performing operations on them, such as executing commands or applying changes.
  reference:
    - https://gtfobins.github.io/gtfobins/find/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,find,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      find . -exec whoami \; -quit

  - engine:
      - sh
      - bash
    source: |
      sudo find . -exec whoami \; -quit

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