id: privesc-view

info:
  name: View - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    view is a command that is often associated with the vi text editor. When invoked as "view," vi starts in read-only mode, allowing users to view files without the ability to modify them.
  reference:
    - https://gtfobins.github.io/gtfobins/view/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,view,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      view -c ':!whoami'

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