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