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: 4a0a0047304502204e1d35336c62b800e25524ed45bbbe4acca9c38c86cd8759c0332b2677e4559a0221008fd313e5d3acaafdf394ef3807440de278980f99511f2de4a579e11d09588a8a:922c64590222798bb761d5b6d8e72950