id: privesc-vim

info:
  name: Vim - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    Vim is a highly configurable, modal text editor based on the vi editor.
  reference:
    - https://gtfobins.github.io/gtfobins/vim/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,vim,privesc,local

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

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

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