Sebastian294/ctf-toolkit

GitHub: Sebastian294/ctf-toolkit

一个Python脚本集合,自动化CTF中的信息收集、目录扫描、哈希破解等常见任务,提升渗透测试效率。

Stars: 0 | Forks: 0

# CTF 工具包 ## 结构 ``` ctf-toolkit/ ├── recon/ │ └── nmap_scan.py # Nmap wrapper with scan profiles ├── web/ │ └── dir_fuzz.py # Gobuster / ffuf wrapper ├── utils/ │ └── port_parser.py # Parse Nmap XML → clean report + CTF hints ├── output/ # Auto-created — scan results saved here └── requirements.txt ``` ## 脚本 ### `recon/nmap_scan.py` — Nmap 封装脚本 预定义的 CTF 场景扫描配置。 ``` # 快速扫描(默认) python3 recon/nmap_scan.py 10.10.10.5 # 完整端口扫描,保存输出 python3 recon/nmap_scan.py 10.10.10.5 -p full -s # 漏洞脚本 python3 recon/nmap_scan.py 10.10.10.5 -p vuln # 列出所有配置文件 python3 recon/nmap_scan.py --list-profiles ``` | 配置 | 描述 | | --------- | -------------------------------- | | `quick` | Top 1000 端口,-sV,T4 | | `full` | 所有 65535 端口,--min-rate=5000 | | `stealth` | SYN 扫描 T2(需要 root 权限) | | `vuln` | NSE 漏洞脚本 | | `udp` | Top 200 UDP 端口 | | `os` | 操作系统检测 + 路由追踪 | ### `web/dir_fuzz.py` — 目录模糊测试工具 封装 gobuster 和 ffuf,提供 CTF 适用的字典预设。 ``` # 默认(gobuster,通用字典) python3 web/dir_fuzz.py http://10.10.10.5 # 使用 ffuf 中等字典,保存结果 python3 web/dir_fuzz.py http://10.10.10.5 -t ffuf -w medium -s # 自定义扩展名 python3 web/dir_fuzz.py http://10.10.10.5 -x php,txt,bak # 列出可用字典预设 python3 web/dir_fuzz.py --list-wordlists ``` | 预设 | 字典文件 | | ---------- | ----------------------------------------- | | `common` | dirb/common.txt | | `medium` | dirbuster/directory-list-2.3-medium.txt | | `big` | dirbuster/directory-list-2.3-big.txt | | `raft-med` | seclists/raft-medium-directories.txt | ### `utils/port_parser.py` — Nmap XML 解析器 将 Nmap `-oX` 输出解析为清晰的表格,并为每个服务提供 CTF 攻击提示。 ``` # 解析并显示 python3 utils/port_parser.py output/scan.xml # 每个端口的攻击提示 python3 utils/port_parser.py output/scan.xml --hints # 保存解析报告 python3 utils/port_parser.py output/scan.xml --hints -s ``` **使用 `--hints` 时的示例输出:** ``` PORT PROTO SERVICE VERSION -------------------------------------------------------- 22 tcp ssh OpenSSH 7.9 └─ 💡 SSH — check version, try default creds or key-based auth 80 tcp http Apache httpd 2.4.38 └─ 💡 HTTP — run dir_fuzz.py, check source, headers, robots.txt 445 tcp microsoft-ds └─ 💡 SMB — smbclient -L // | crackmapexec smb ``` ## 依赖项 ``` # 系统工具 sudo apt install nmap gobuster ffuf # 字典 sudo apt install wordlists seclists sudo gunzip /usr/share/wordlists/rockyou.txt.gz ``` 无 Python 依赖项 — 仅使用标准库。 ## 典型 CTF 工作流程 ``` # 1. 快速侦察 python3 recon/nmap_scan.py 10.10.10.5 -p quick -s # 2. 带提示解析结果 python3 utils/port_parser.py output/10_10_10_5_quick_*.xml --hints # 3. 如发现 HTTP — 目录模糊测试 python3 web/dir_fuzz.py http://10.10.10.5 -w medium -s # 4. 后台全端口扫描 python3 recon/nmap_scan.py 10.10.10.5 -p full -s ``` ### `utils/hash_id.py` — 哈希识别与破解工具 通过正则表达式识别哈希类型,并自动启动 hashcat 或 john。 ``` # 仅识别 python3 utils/hash_id.py 5f4dcc3b5aa765d61d8327deb882cf99 # 识别 + 使用 hashcat 破解(rockyou 默认) python3 utils/hash_id.py --crack # 改用 john python3 utils/hash_id.py --crack --tool john # 强制 hashcat 模式 + 自定义字典 python3 utils/hash_id.py --crack --mode 1800 --wordlist /path/to/list.txt # 使用规则 python3 utils/hash_id.py --crack --rules /usr/share/hashcat/rules/best64.rule ``` 支持:MD5、SHA-1/256/512、bcrypt、MD5-Crypt、SHA-Crypt、NTLM、WordPress(phpass)、MySQL、Django、LM、DES、Apache MD5 等。 ### `utils/reverse_shell_gen.py` — 反向 shell 生成器 生成可直接粘贴使用的反向 shell 一行命令 + 监听命令 + shell 升级技巧。 ``` # 默认(bash-tcp) python3 utils/reverse_shell_gen.py 10.10.14.5 4444 # 特定 shell 类型 python3 utils/reverse_shell_gen.py 10.10.14.5 4444 -s nc-mkfifo python3 utils/reverse_shell_gen.py 10.10.14.5 4444 -s powershell python3 utils/reverse_shell_gen.py 10.10.14.5 4444 -s python3-b64 # 一次性生成所有 shell python3 utils/reverse_shell_gen.py 10.10.14.5 4444 -s all # 列出可用 shell 类型 python3 utils/reverse_shell_gen.py --list ``` | Shell 类型 | 描述 | | ------------------ | ------------------------------ | | `bash-tcp` | Bash /dev/tcp 重定向 | | `bash-udp` | Bash /dev/udp 重定向 | | `nc-mkfifo` | Netcat + mkfifo(兼容性最佳) | | `nc-e` | 带 -e 参数的 Netcat | | `python3` | Python 3 socket | | `python3-b64` | Python 3 base64 编码 | | `php-exec` | PHP exec() | | `php-passthru` | PHP passthru()(exec 被禁用) | | `powershell` | PowerShell 编码(Windows) | | `powershell-plain` | PowerShell 明文 | | `ruby` | Ruby TCP | | `perl` | Perl socket | | `socat` | Socat 完全交互式 PTY | | `awk` | AWK /inet | | `lua` | Lua socket | 同时自动输出监听命令(nc、rlwrap、socat、pwncat)和 shell 升级技巧。 ### `web/lfi_tester.py` — LFI / 路径穿越模糊测试工具 ``` # 扫描 python3 web/lfi_tester.py http://10.10.10.5/page.php -p file # 保存输出 python3 web/lfi_tester.py http://10.10.10.5/page.php -p file -o windows -s # 包含 PHP 包装器(php://, file://, data://) python3 web/lfi_tester.py http://10.10.10.5/page.php -p file --wrappers # 使用会话 cookie 测试特定文件 python3 web/lfi_tester.py http://10.10.10.5 -p file -f /etc/shadow -c 'PHPSESSID=abc123' # POST 方法自定义头部 python3 web/lfi_tester.py http://10.10.10.5 -p file -m post -H 'X-Forwarded-For: 127.0.0.1' ``` 覆盖:15+ 种路径穿越编码方式(`../`、`%2e%2e%2f`、双重 URL、UTF-8 超长编码...)、26 个 Linux 文件 + 11 个 Windows 文件、PHP 包装器以及基于内容的自动命中检测。 ### `recon/subdomain_enum.py` — 子域名枚举工具 三种模式:纯 DNS 暴力破解(无需外部工具)、ffuf vhost 模糊测试和被动 amass 收集。 | 模式 | 依赖项 | 用途 | | ------- | --------------- | ----------------------------- | | `dns` | 仅 Python | HTB/THM | | `ffuf` | 已安装 ffuf | Vhost 模糊测试 | | `amass` | 已安装 amass | 真实域名,被动 OSINT |
标签:CTF工具, CTI, ffuf, GitHub, Nmap, Python, reconnaissance, Web安全, 云存储安全, 实时处理, 密码管理, 工具集, 扫描工具, 插件系统, 数据统计, 无后门, 漏洞搜索, 目录枚举, 移动安全, 端口扫描, 网络安全, 网络安全审计, 网络扫描, 网络连接监控, 蓝队分析, 虚拟驱动器, 逆向工具, 隐私保护