id: privesc-xargs

info:
  name: Xargs - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    xargs is a command in Unix and Unix-like operating systems used to build and execute command lines from standard input.
  reference:
    - https://gtfobins.github.io/gtfobins/xargs/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,xargs,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      xargs -a /dev/null whoami

  - engine:
      - sh
      - bash
    source: |
      sudo xargs -a /dev/null 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: 4a0a00473045022052f887093022e061b40da1eae5a8b4aa8a5f267dfd5f22db005a9076db73cc9a02210093f126e5d0229cf686f3c547dc3466e89afb2a7bf57bbeb790acf65376fcd047:922c64590222798bb761d5b6d8e72950