id: privesc-nice

info:
  name: Nice - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    In Unix-like operating systems, the nice command is used to execute a program with a modified scheduling priority. It allows users to start a process with a specified priority level, which can influence the allocation of CPU resources. This can be useful for managing system resources and controlling the impact of a process on system performance.
  reference:
    - https://gtfobins.github.io/gtfobins/nice/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,nice,privesc,local

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

  - engine:
      - sh
      - bash
    source: |
      nice whoami

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