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