amibhai/credential-attacks-toolkit

GitHub: amibhai/credential-attacks-toolkit

一款支持 18 种协议、具备多种攻击模式与规避机制的生产级凭证安全测试套件,专为授权渗透测试设计。

Stars: 1 | Forks: 0

# CredAttack — 凭证攻击工具包

Release Python Protocols Tests License

## 目录 - [什么是 CredAttack?](#what-is-credattack) - [攻击模式](#attack-modes) - [支持的协议](#supported-protocols) - [架构](#architecture) - [快速开始](#quick-start) - [安装说明](#installation) - [CLI 参考](#cli-reference) - [密码变异引擎](#password-mutation-engine) - [默认凭证数据库](#default-credentials-database) - [代理轮换](#proxy-rotation) - [HTML 报告](#html-reports) - [配置与环境变量](#configuration--environment-variables) - [Docker](#docker) - [测试](#testing) - [项目结构](#project-structure) - [贡献指南](#contributing) ## 什么是 CredAttack? CredAttack 是一个**模块化、生产级的凭证测试套件**,专为授权的渗透测试活动设计。它涵盖了完整的凭证攻击生命周期: | 阶段 | CredAttack 功能 | |-------|-----------------------| | **信息收集** | 默认凭证数据库(200+ 对),基于用户名的智能模式生成 | | **攻击** | 17 种协议攻击器,6 种攻击模式,多目标活动 | | **规避** | 锁定检测,可配置的速率限制,抖动,代理轮换 | | **报告** | JSONL 审计日志,Jinja2 HTML 报告,发现的凭证横幅 + 文件导出 | ## 攻击模式 | 模式 | 命令 | 描述 | |------|---------|-------------| | **Dictionary** | `ssh`, `ftp`, `smb`, … | 针对单个用户的字典攻击 | | **Spray** | `spray` | 对用户列表使用单个密码(防止锁定) | | **Combo** | `combo` | 每个用户 × 每个密码 | | **Smart** | `smart` | 基于用户名/公司名衍生模式生成 | | **Defaults** | `defaults` | 尝试 200+ 已知的服务默认凭证 | | **Multi-target** | `multi` | 跨主机列表进行相同攻击 | | **Full pipeline** | `full` | 全协议,单一报告 | ## 支持的协议 | # | 协议 | 模块 | 默认端口 | 备注 | |---|----------|--------|-------------|-------| | 1 | SSH | `ssh.py` | 22 | paramiko,密钥/密码认证 | | 2 | FTP | `ftp.py` | 21 | 主动与被动模式 | | 3 | HTTP Form | `http_form.py` | 80/443 | 自动 CSRF token 检测 | | 4 | HTTP Basic | `http_basic.py` | 80 | RFC 7617 | | 5 | HTTP Digest | `http_digest.py` | 80 | RFC 7616 | | 6 | SMB | `smb.py` | 445 | impacket, NTLM | | 7 | RDP | `rdp.py` | 3389 | impacket NLA | | 8 | SMTP | `smtp.py` | 587 | STARTTLS | | 9 | POP3 | `pop3.py` | 110 | APOP 支持 | | 10 | IMAP | `imap.py` | 143 | STARTTLS | | 11 | MySQL | `mysql.py` | 3306 | mysql-connector-python | | 12 | MSSQL | `mssql.py` | 1433 | pymssql | | 13 | Redis | `redis_proto.py` | 6379 | AUTH 命令 | | 14 | MongoDB | `mongodb.py` | 27017 | pymongo | | 15 | WinRM | `winrm.py` | 5985 | NTLM, pywinrm | | 16 | LDAP | `ldap_proto.py` | 389 | ldap3, rootDSE 自动检测 | | 17 | Telnet | `telnet.py` | 23 | 原始 TCP | | 18 | VNC | `vnc.py` | 5900 | 原始 DES 挑战-响应 | ## 架构 ``` credattack.py ← thin shim: `python credattack.py ...` from a checkout │ ├── credattack/cli.py ← CLI (Typer) — 8 attack-mode subcommands; also the │ `credattack` console script when pip-installed ├── credattack/core/ │ ├── config.py ← Pydantic v2 Settings, CREDATTACK_* env-var overrides │ ├── engine.py ← AttackEngine (ThreadPoolExecutor + Rich progress UI) │ ├── lockout.py ← LockoutDetector (sliding-window, thread-safe) │ ├── proxy.py ← ProxyRotator (round-robin, health-check, demotion) │ ├── mutator.py ← PasswordMutator (leet, seasonal, suffix, keyboard-walk…) │ ├── result.py ← AttemptResult + SessionReport dataclasses │ ├── report.py ← Jinja2 HTML report generator │ └── logger.py ← Rich logging + JSONL audit writer │ ├── credattack/protocols/ │ └── *.py ← 18 ProtocolAttacker implementations │ ├── credattack/data/ │ ├── default_creds.json ← 200+ real default credential pairs │ ├── smart_patterns.json ← 140+ enterprise password templates │ └── wordlists/ ← Per-service default password lists │ └── tests/ ← 50+ pytest tests (unit + protocol mocks) ``` ## 快速开始 ``` # 克隆并设置 git clone https://github.com/amibhai/credential-attacks-toolkit.git cd credential-attacks-toolkit python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt # 检查版本 python credattack.py --version # 试运行(不建立连接 — 验证您的词表) python credattack.py ssh -t 192.168.1.100 -u admin -P wordlists/common_passwords.txt --dry-run # 真实 SSH 字典攻击 python credattack.py ssh -t 192.168.1.100 -u admin -P /path/to/rockyou.txt # 密码喷射(速率受限,锁定安全) python credattack.py spray -t 192.168.1.100 --protocol ssh -U users.txt -p "Summer2024!" --delay 30 # Smart 模式 — 根据用户名 + 公司生成模式 python credattack.py smart -t 192.168.1.100 --protocol ssh -u john.doe --company ACME # 尝试服务默认值 python credattack.py defaults -t 192.168.1.100 --protocol mysql # 多目标活动 python credattack.py multi --targets hosts.txt --protocol ssh -U users.txt -P passes.txt ``` ## 安装说明 ### 选项 A — pip + virtualenv(推荐) ``` python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install --upgrade pip pip install -r requirements.txt ``` ### 选项 B — Makefile 快捷方式 ``` make install # core deps make install-dev # + pytest-cov, ruff, mypy ``` ### 选项 C — pip install(可编辑模式或通过 wheel) ``` pip install -e . # core deps only pip install -e .[full] # + SMB/RDP/MySQL/MSSQL/Redis/MongoDB/WinRM/LDAP pip install -e .[dev] # + pytest/ruff/mypy credattack --version # console script, equivalent to `python credattack.py` ``` ### 选项 D — Docker ``` docker build -t credattack -f docker/Dockerfile . docker run --rm credattack --help # 挂载您的词表并收集输出 docker run --rm \ -v $(pwd)/wordlists:/app/wordlists:ro \ -v $(pwd)/output:/app/output \ credattack ssh -t 192.168.1.100 -u admin -P wordlists/common_passwords.txt ``` ## CLI 参考 ### 全局选项 ``` python credattack.py [OPTIONS] COMMAND [ARGS]... Options: -V, --version Show version and exit. --help Show help. ``` ### 通用标志(适用于所有协议命令) | 标志 | 简写 | 默认值 | 描述 | |------|-------|---------|-------------| | `--target` | `-t` | — | 目标主机 / IP | | `--port` | | 0(协议默认) | 覆盖 TCP 端口 | | `--username` | `-u` | — | 单个用户名 | | `--user-file` | `-U` | — | 换行符分隔的用户名文件 | | `--pass-file` | `-P` | — | 换行符分隔的密码文件 | | `--password` | `-p2` | — | 单个密码 | | `--threads` | `-n` | 10 | 并发工作线程 | | `--timeout` | `-T` | 5.0 | 单次尝试超时时间 (秒) | | `--delay` | `-d` | 0.0 | 固定的尝试间隔延迟 (秒) | | `--jitter` | | 0.0 | 最大随机抖动 (秒) | | `--stop-on-first` | | True | 命中后停止对该用户的尝试 | | `--proxy-file` | | None | HTTP/SOCKS5 代理列表 | | `--output-dir` | `-o` | `./output` | 结果目录 | | `--verbosity` | `-v` | 1 | 日志记录级别 (0-3) | | `--dry-run` | | False | 仅计算组合对而不进行连接 | ### 子命令 ``` # 特定协议(每个映射到专用的 attacker) python credattack.py ssh|ftp|smb|rdp|smtp|pop3|imap|mysql|mssql|redis|mongodb|winrm|ldap|telnet|vnc \ -t HOST -u USER -P passes.txt # HTTP(表单 / basic / digest) python credattack.py http -t http://target/login --mode form \ --form-user-field username --form-pass-field password --success-string "Dashboard" # Spray — 单个密码,多个用户,长延迟 python credattack.py spray -t HOST --protocol ssh -U users.txt -p "Password1" --delay 30 # Combo — 用户 × 密码的笛卡尔积 python credattack.py combo -t HOST --protocol smb -U users.txt -P passes.txt # Smart — 基于 OSINT 的生成 python credattack.py smart -t HOST --protocol ssh -u firstname.lastname --company TargetCorp # Defaults — 尝试厂商默认凭证 python credattack.py defaults -t HOST --protocol mysql # Multi — 跨多个主机的相同攻击 python credattack.py multi --targets hosts.txt --protocol ssh -U users.txt -P passes.txt # Full — 按顺序的所有协议 python credattack.py full -t HOST -U users.txt -P passes.txt ``` ## 密码变异引擎 `credattack/core/mutator.py` 中的 `PasswordMutator` 支持可组合的策略: | 策略 | 方法 | 示例输出 | |----------|--------|----------------| | Leet-speak | `leet_speak(word)` | `p@ssw0rd`, `p455w0rd` | | 字母大写 | `capitalise_variants(word)` | `PASSWORD`, `Password`, `pAsSwOrD` | | 后缀 | `suffix_append(word)` | `password123`, `password@2025` | | 前缀 | `prefix_append(word)` | `!password`, `mypassword` | | 键盘位移 | `keyboard_walk(word)` | `qassword` (a→q) | | 用户名模式 | `username_patterns(user, company)` | `john123`, `Doe1!`, `ACME2024!` | | **季节性** (v1.1) | `seasonal_patterns(company)` | `Summer2024!`, `Winter25` | | **特殊字符包裹** (v1.1) | `special_char_wrap(word)` | `!@Password`, `Password!@` | | 组合 | `combine(word, strategies)` | 串联以上任意策略 | | 智能(多合一) | `smart_generate(user, company)` | 去重、设上限的流 | ## 默认凭证数据库 `credattack/data/default_creds.json` 包含跨越以下平台的 **200+ 真实默认凭证对**: Cisco · F5 · Juniper · Palo Alto · VMware · Jenkins · GitLab · Tomcat · WordPress · MySQL · MSSQL · Redis · MongoDB · PostgreSQL · Elasticsearch · RabbitMQ · Splunk · Nagios · Zabbix · pfSense · MikroTik · Huawei · HP iLO · Dell iDRAC · IPMI ``` # 查看服务的所有默认值 python credattack.py defaults -t HOST --protocol mysql --dry-run # 针对 target 运行 python credattack.py defaults -t 10.0.0.1 --protocol ssh ``` ## 代理轮换 传入一个代理文件(每行一个代理,格式为 `host:port`): ``` # proxies.txt 192.168.1.10:1080 192.168.1.11:1080 socks5://10.0.0.5:9050 ``` ``` python credattack.py ssh -t TARGET -u admin -P passes.txt --proxy-file proxies.txt ``` `ProxyRotator` 会在启动时执行健康检查,并降低失败率超过阈值的代理的优先级。死掉的代理会被自动排除。 ## HTML 报告 在每次非预演(non-dry-run)攻击之后,HTML 报告会自动生成在 `./output/` 中: - **统计卡片**:总尝试次数,成功率,持续时间,尝试次数/秒 - **已发现的凭证表**:主机 · 协议 · 用户名 · 密码(支持复制到剪贴板) - **暗黑主题** Jinja2 模板 ``` # 运行结束后打开 start output/report_*.html # Windows open output/report_*.html # macOS ``` ## 配置与环境变量 `credattack/core/config.py` 中的所有设置都可以通过 `CREDATTACK_*` 环境变量进行覆盖: ``` export CREDATTACK_THREADS=20 export CREDATTACK_TIMEOUT=3.0 export CREDATTACK_DELAY=1.0 export CREDATTACK_JITTER=0.5 export CREDATTACK_LOCKOUT_THRESHOLD=3 export CREDATTACK_VERBOSITY=2 ``` 或者在 CLI 级别使用标准标志(`--threads`、`--timeout` 等)进行覆盖。 ## Docker ``` # 构建 image docker build -t credattack -f docker/Dockerfile . # 使用 Docker Compose 运行 cd docker docker compose run credattack ssh -t 192.168.1.100 -u admin -P /app/wordlists/common_passwords.txt # 通过环境设置 config docker run --rm \ -e CREDATTACK_THREADS=20 \ -e CREDATTACK_TIMEOUT=3 \ -v $(pwd)/output:/app/output \ credattack defaults -t 10.0.0.1 --protocol mysql ``` ## 测试 ``` # 运行所有测试 pytest -q # 带有 coverage pytest --cov=credattack --cov-report=term-missing -q # Makefile 快捷方式 make test-cov ``` **当前测试套件:50+ 个测试**,涵盖: | 领域 | 测试 | |------|-------| | 锁定检测器(滑动窗口,线程安全) | `test_lockout.py` | | 密码变异器策略 | `test_mutator.py` | | 新变异器策略(季节性,特殊字符) | `test_mutator_extended.py` | | 代理轮换器(健康检查,降级) | `test_proxy.py` | | Result & SessionReport dataclasses | `test_result.py` | | SSH 协议 mock | `test_protocols_ssh.py` | | FTP 协议 mock | `test_protocols_ftp.py` | | HTTP Basic & Digest mocks | `test_protocols_http.py` | ## 字典 ### 推荐来源 | 字典 | 大小 | 最适用途 | |----------|------|----------| | `rockyou.txt` | ~14 M | 通用字典 | | `SecLists/Passwords/` | 多种 | 特定协议 | | `kaonashi.txt` | ~64 M | 高级覆盖 | | OSINT 衍生 | 不定 | 定向攻击 | ``` # 使用任何外部词表 python credattack.py ssh -t TARGET -u admin -P /opt/wordlists/rockyou.txt ``` ## 项目结构 ``` credential-attacks-toolkit/ ├── credattack.py # Thin shim -> credattack.cli:app (source-checkout usage) ├── pyproject.toml # PEP 517/518 build & tool config ├── requirements.txt # Runtime deps ├── Makefile # Developer shortcuts ├── VERSION # Single source of version truth ├── CHANGELOG.md ├── SECURITY.md ├── .github/ │ └── workflows/ci.yml # GitHub Actions: lint + test matrix + mypy ├── docker/ │ ├── Dockerfile │ └── docker-compose.yml ├── credattack/ │ ├── cli.py # CLI (Typer) — packaged, backs the console script │ ├── core/ │ │ ├── config.py # Pydantic v2 Settings │ │ ├── engine.py # AttackEngine (ThreadPoolExecutor) │ │ ├── lockout.py # LockoutDetector (sliding window) │ │ ├── proxy.py # ProxyRotator │ │ ├── mutator.py # PasswordMutator │ │ ├── result.py # AttemptResult, SessionReport │ │ ├── report.py # HTML report generator │ │ └── logger.py # Rich logger + JSONL writer │ ├── protocols/ # 18 ProtocolAttacker implementations │ │ └── base.py # Abstract ProtocolAttacker │ └── data/ │ ├── default_creds.json # 200+ vendor defaults │ ├── smart_patterns.json # 140+ enterprise templates │ └── wordlists/ # Per-service starter lists ├── attacks/ # Standalone single-file tools (predate credattack/; │ └── *.py # kept for scripts not yet ported: JWT cracking, │ # WAF detection, timing-based user enumeration) ├── utils/ │ └── credential_utils.py # Shared helpers for the attacks/ scripts ├── tests/ │ ├── conftest.py # Shared fixtures │ ├── test_lockout.py │ ├── test_mutator.py │ ├── test_mutator_extended.py │ ├── test_proxy.py │ ├── test_result.py │ ├── test_protocols_ssh.py │ ├── test_protocols_ftp.py │ └── test_protocols_http.py ├── wordlists/ # Minimal smoke-test stubs └── output/ # Generated logs & reports (git-ignored) ``` ## 攻击成功率(参考指标) | 密码类型 | 字典 | Smart 模式 | Spray (常见) | |---------------|-----------|------------|----------------| | 4 个字符 | ~90% | ~95% | ~60% | | 6 个字符 | ~65% | ~75% | ~25% | | 8 个混合字符 | ~15% | ~25% | ~5% | | 10+ 个复杂字符 | <5% | <5% | <1% | ## 贡献指南 参见 [CONTRIBUTING.md](CONTRIBUTING.md)。 在提交大型 PR 之前,请先开启一个 issue。 所有贡献必须遵守 [SECURITY.md](SECURITY.md) 中的道德使用政策。 **负责任地使用。合乎道德地测试。保持合法。**
标签:PoC, Python, SNMP, SysWhispers, VEH, 字典攻击, 密码攻击, 无后门, 暴力破解, 请求拦截, 逆向工具