id: privesc-csh

info:
  name: csh - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    csh stands for C Shell, which is a Unix shell with C-like syntax. It is a command-line interpreter that provides a command-line interface for Unix-like operating systems. It has features similar to other Unix shells such as bash and sh, but with a different syntax and set of features.
  reference:
    - https://gtfobins.github.io/gtfobins/csh/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,csh,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      csh -c 'whoami'

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