Alfasentinel/api-attack-simulator

GitHub: Alfasentinel/api-attack-simulator

一款面向开发与测试环境的 CLI 工具,通过模拟四种常见 API 攻击模式来验证你的安全防护是否真正生效。

Stars: 0 | Forks: 0

# api-attack-simulator 一款免费的 CLI 工具,用于针对您自己的开发和测试端点模拟 API 攻击模式——让您在攻击者发现漏洞之前,验证防御措施是否正常运作。 由 [Alfasentinel](https://alfasentinel.com) 构建并维护。 ## 模拟内容 | 攻击类型 | 作用 | 测试目标 | |------------|--------------|---------------| | **暴力破解 / 凭证填充** | 对您的 auth 端点发起 N 次登录尝试 | BruteForceDetector、rate limiting、lockout policies | | **BOLA / IDOR** | 从已认证的会话中按顺序访问资源 ID | BOLADetector、object-level authorization checks | | **Shadow API 发现** | 探测 20 多个常见的未记录路径 | ShadowAPIDetector、route table hygiene | | **速率突增** | 在指定时间窗口内发起 N 次请求/秒 | RateSpikeDetector、baseline monitoring、aggregate rate limits | ## 安装 ``` pip install requests python api_attack_simulator.py --help ``` 或者克隆仓库: ``` git clone https://github.com/alfasentinel/api-attack-simulator cd api-attack-simulator pip install -r requirements.txt ``` ## 使用方法 ``` # 针对你的本地 API 运行全部 4 个攻击模拟 python api_attack_simulator.py --url http://localhost:5000 --all --confirm # 仅暴力破解 — 100 次尝试,150ms 延迟,分布式 user agents python api_attack_simulator.py --url http://localhost:5000 \ --attack brute \ --endpoint /api/auth/login \ --attempts 100 \ --delay 150 \ --distributed \ --confirm # BOLA 模拟 — authenticated session,从 ID 5000 开始 python api_attack_simulator.py --url http://localhost:5000 \ --attack bola \ --endpoint /api/v1/users/{id} \ --start-id 5000 \ --auth-token YOUR_TEST_TOKEN \ --confirm # Shadow API 发现 python api_attack_simulator.py --url http://staging.yourapp.com \ --attack shadow \ --confirm # 速率激增 — 100 req/s 持续 15 秒 python api_attack_simulator.py --url http://localhost:5000 \ --attack spike \ --endpoint /api/v1/data \ --rate 100 \ --duration 15 \ --confirm ``` ## 输出 每次攻击都会打印实时结果和摘要报告: ``` [14:23:01] [WARN] Attempt 23: RATE LIMITED (429) — basic rate limiting triggered [14:23:01] [OK] Detection triggered at attempt 23. ═══════════════════════════════════════════════════════ SIMULATION COMPLETE — SUMMARY REPORT ═══════════════════════════════════════════════════════ BRUTE_FORCE Total requests: 23 Status distribution: {'401': 22, '429': 1} ``` ## 结合 ApiSentinel 使用 本工具与 [ApiSentinel](https://alfasentinel.com) 配合使用——在 ApiSentinel 处于激活状态时,针对您的测试环境运行模拟器,以便在投入生产之前验证所有四个检测器是否按预期触发。 ``` # 端到端测试你的 ApiSentinel 集成 python api_attack_simulator.py --url https://staging.yourapp.com --all --confirm # 然后检查你的 ApiSentinel dashboard — 你应该会看到 4 个检测事件 ``` ## ⚠️ 使用策略 本工具仅用于在**开发或测试环境**中测试**您自己的 API**。 在大多数司法管辖区,针对您不拥有或未获得明确测试授权的 API 使用本工具,均违反计算机欺诈法律属于违法行为。`--confirm` 标志作为一种刻意的阻力机制而存在。 ## 许可证 MIT — 可自由使用、修改和分发。 由 [Alfasentinel](https://alfasentinel.com) 构建 | contact@alfasentinel.com
标签:API发现, API安全, API防护, BOLA, CISA项目, DevSecOps, IDOR, JSON输出, Maven, PoC, Python, Web安全, 上游代理, 安全测试, 开发测试, 影子API, 撞库, 攻击性安全, 攻击模拟, 数据展示, 文档结构分析, 无后门, 暴力破解, 漏洞验证, 红队, 结构化查询, 网络安全, 自动化安全, 蓝队分析, 越权漏洞, 逆向工具, 速率监控, 防御验证, 限流测试, 隐私保护, 驱动签名利用