Asks for a Python framework that tests REST APIs for access-control bypass (BOLA), business logic flaws and related high-severity issues.
You are a Senior Software Architect specializing in Site Reliability Engineering (SRE) and Dynamic Application Security Testing (DAST). Your task is to design and implement a production-ready Python framework that performs robustness analysis and business rule validation against REST APIs and web endpoints. **Core Objective:** Build an intelligent testing engine that identifies structural logic failures across three high-impact vulnerability categories (equivalent to High and Critical severity business rule violations): 1. **Access Control & Context Bypass Failures** (e.g., Broken Object Level Authorization - BOLA) 2. **Business Logic Inversions & Anomalies** (e.g., mathematical parameter manipulation, billing flow exploitation, Content-Type format switching like YAML/JSON injection) 3. **Infrastructure Resilience Failures** (e.g., unhandled runtime exceptions causing service interruption) **Architecture Requirements:** **1. INTELLIGENCE COMPONENT (Scenario Analysis Engine):** Create a structured function that: - Accepts application route mappings as input - Dynamically generates an edge case test matrix using parameter mutation logic - Focuses on semantic anomalies: type inversions, numerical value reversals, data format coercion, and parameter boundary violations (not just path traversal) - Returns actionable test cases with specific payloads, expected vs. anomalous behaviors, and impact classifications **2. EXECUTION COMPONENT (Real Python Interactive Console):** Implement a real-time console using `requests` and `urllib3` with robust exception handling that: - Accepts user input: target URL and legitimate authentication headers - Executes actual HTTP requests based on test cases generated by the intelligence component - Captures and displays: actual HTTP status codes (200, 401, 403, 500, etc.), exact response payload size, raw server logs, and response headers - Includes timeout protection and connection error handling to maintain console stability - Supports parameter mutation injection in real-time (query params, body payloads, headers) **3. REPORTING COMPONENT:** Generate a markdown report that includes: - Proof-of-Concept (PoC) reproduction steps with actual requests and responses - Severity classification (High/Critical) with business impact assessment - Raw HTTP traffic capture (request/response pairs) - Actionable remediation guidance **Code Structure Requirements:** - Modular design with clear separation: analysis engine → execution engine → reporting engine - Production-quality error handling, logging, and state management - Console must be reproducible in real-time with actual network calls (not mocked) - Output format compatible with manual Burp Suite replay for verification - All actual HTTP responses and status codes must be real, not simulated **Delivery:** Provide the complete, executable Python framework with all three components integrated. The system must work immediately when given a live target URL—no configuration needed beyond authentication headers. The console terminal should be a functional PoC that demonstrates real vulnerabilities with real HTTP traffic capture and high-impact business logic violations.
你是一名资深软件架构师,专注于站点可靠性工程(SRE)和动态应用安全测试(DAST)。你的任务是设计并实现一个可用于生产环境的 Python 框架,用于对 REST API 和 Web 端点执行健壮性分析和业务规则验证。 **核心目标:** 构建一个智能测试引擎,识别以下三类高影响漏洞中的结构性逻辑缺陷(相当于高危和严重级别的业务规则违规): 1. **访问控制与上下文绕过失败**(例如:失效的对象级授权 - BOLA) 2. **业务逻辑反转与异常**(例如:数学参数篡改、计费流程利用、Content-Type 格式切换如 YAML/JSON 注入) 3. **基础设施弹性失败**(例如:未处理的运行时异常导致服务中断) **架构要求:** **1. 智能组件(场景分析引擎):** 创建一个结构化函数,能够: - 接收应用程序路由映射作为输入 - 使用参数变异逻辑动态生成边界情况测试矩阵 - 聚焦语义异常:类型反转、数值倒置、数据格式强制转换以及参数边界违规(不仅仅是路径遍历) - 返回可操作的测试用例,包含具体载荷、预期行为与异常行为对比,以及影响分类 **2. 执行组件(真实 Python 交互式控制台):** 使用 `requests` 和 `urllib3` 实现一个实时控制台,具备强大的异常处理能力,能够: - 接收用户输入:目标 URL 和合法的身份验证头部(authentication headers) - 基于智能组件生成的测试用例执行实际的 HTTP 请求 - 捕获并显示:实际的 HTTP 状态码(200、401、403、500 等)、响应载荷精确大小、原始服务器日志、响应头部 - 包含超时保护和连接错误处理机制,以维持控制台稳定性 - 支持实时参数变异注入(查询参数、请求体载荷、头部) **3. 报告组件:** 生成一份 Markdown 报告,包含: - 概念验证(PoC)复现步骤,附带实际请求与响应 - 严重性分类(高危/严重)及业务影响评估 - 原始 HTTP 流量捕获(请求/响应对) - 可操作的修复建议 **代码结构要求:** - 模块化设计,清晰分离:分析引擎 → 执行引擎 → 报告引擎 - 具备生产级的错误处理、日志记录和状态管理 - 控制台必须可通过实际网络调用实时复现(不得使用模拟) - 输出格式兼容手动在 Burp Suite 中重放以供验证 - 所有实际的 HTTP 响应和状态码必须真实,不得模拟 **交付要求:** 提供一个完整、可执行的 Python 框架,集成上述全部三个组件。系统在提供一个活动目标 URL 后必须立即可用——除身份验证头部外无需任何配置。控制台终端应为一个功能性的概念验证(PoC),能够通过真实 HTTP 流量捕获展示真实漏洞和高影响的业务逻辑违规。