id: netrc

info:
  name: Netrc - Config File Discovery
  author: geeknik
  severity: high
  description: Netrc configuration file was discovered.
  reference:
    - https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html
  metadata:
    max-request: 2
  tags: netrc,config,exposure,vuln

http:
  - method: GET
    path:
      - "{{BaseURL}}/.netrc"
      - "{{BaseURL}}/_netrc"

    matchers-condition: and
    matchers:
      - type: status
        status:
          - 200

      - type: regex
        regex:
          - "machine [0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?"

      - type: word
        words:
          - "login "
          - "password "
        condition: and

      - type: word
        part: header
        words:
          - "text/html"
        negative: true

    extractors:
      - type: regex
        part: body
        regex:
          - "machine [0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?"
# digest: 490a0046304402201e6dab24e7b7c068e2bac2a3e673a35b66275d6e9d26493ae5082cb0238d11ad02203e743507813cb388466c7634bf24ecdcd9c57ce4fa6ce61d7a2fd1dd2dd932e7:922c64590222798bb761d5b6d8e72950