id: privesc-softlimit

info:
  name: softlimit - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    The softlimit command is used in conjunction with the daemontools software to set resource limits for a process. It is commonly used to control the resource usage of a process, such as limiting its memory or CPU usage. The softlimit command helps in managing and controlling the resource consumption of a process, which can be useful for ensuring system stability and preventing resource exhaustion.
  reference:
    - https://gtfobins.github.io/gtfobins/softlimit/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,softlimit,privesc,local

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

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

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