id: flask-detect

info:
  name: Flask Detection
  author: Chirag Mistry
  severity: info
  description: |
    An instance running Flask is detected by looking for specific HTTP headers, HTML tags, and known endpoints.
  metadata:
    max-request: 8
    shodan-query: http.component:"Flask"
  tags: flask,detect,tech

http:
  - method: GET
    path:
      - "{{BaseURL}}"
      - "{{BaseURL}}/robots.txt"
      - "{{BaseURL}}/sitemap.xml"
      - "{{BaseURL}}/favicon.ico"
      - "{{BaseURL}}/index.php"
      - "{{BaseURL}}/static/"
      - "{{BaseURL}}/flask/"
      - "{{BaseURL}}/health/"

    stop-at-first-match: true
    matchers-condition: and
    matchers:
      - type: word
        part: response
        words:
          - "Powered by Flask"
          - "flask.palletsprojects.com"
          - "X-Powered-By-Flask"
        condition: or
        case-insensitive: true

      - type: status
        status:
          - 200

    extractors:
      - type: regex
        part: body
        name: version
        regex:
          - 'Flask ([0-9.]+)'
          - 'Powered by Flask ([0-9.]+)'

      - type: regex
        part: body
        name: flask_id
        regex:
          - 'flask-site-id=([a-z0-9]+)'
          - 'flask\.palletsprojects\.com/([^/]+)'
# digest: 4a0a0047304502206b50fc42962e4fd459c198aa8afeb73dd6a1162bd846a6c74cf2dbc1aff9851a022100df83041d6a9abbef48015c6dc0c09feff4212d5dc7ffe4d77de12c3e1cfc03bd:922c64590222798bb761d5b6d8e72950