id: writable-etc-passwd

info:
  name: /etc/passwd writable - Privilege Escalation
  author: daffainfo
  severity: high
  reference:
    - https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#writable-etcpasswd
  metadata:
    verified: true
  tags: code,linux,privesc,local

self-contained: true
code:
  - engine:
      - sh
      - bash
    source: |
        [ -w "/etc/passwd" ] && echo "Writable" || echo "Not writable"

    matchers:
      - type: word
        part: code_1_response
        words:
          - "Writable"

      - type: word
        part: code_1_response
        words:
          - "Not writable"
        negative: true
# digest: 490a0046304402200a2dcfb2eaea839565816d82dd85b66ba2456dbbe04b3f5571d026c605a94f9c02202f0547ac07c1d33f571cbde87705304d77846d67c120b2b983502fa275396a5f:922c64590222798bb761d5b6d8e72950