一个轻量级、教育性的 Python 工具包,用于自动化授权渗透测试中常见的侦察和枚举任务。作为网络安全 / 道德黑客实践的学习项目而构建。
本工具包执行主动扫描和枚举。对您不拥有或未获得明确书面许可进行测试的系统运行本工具,在大多数司法管辖区可能构成犯罪。
作者对任何滥用行为不承担任何责任。
| 命令 | 功能说明 |
|---|---|
portscan | 对主机进行并发 TCP connect 扫描 |
banner | 从开放端口抓取服务 banner |
dirscan | 从字典枚举 Web 路径 |
subdomains | 解析候选子域名 |
netscan | 发现 CIDR 范围内的存活主机 |
httpprobe | 检查 HTTP 响应(状态、头部、预览) |
logincheck | 仅限实验环境的弱口令/默认凭据风险演示(限速) |
从 v1 到 v2 的变化:模块化包结构、带子命令的 argparse CLI、多线程扫描器、由 rich 驱动的 UI(ASCII banner、实时进度条和结果表格)、输入验证、授权门控、单元测试以及 GitLab CI 流水线。
# install virtualenv and activate
python3 -m venv venv
. venv/bin/activate
# install packages
pip3 install -r requirements.txt
# run (always from the project root)
python3 main.py --help
python -m venv venv
. .\venv\Scripts\activate # (PowerShell)
. venv/scripts/activate # (Git Shell)
pip install -r requirements.txt
python main.py --help
始终从项目根目录通过 python main.py … 运行(src 包中包含名为 http 和 dir 的模块,因此在 src/ 内部运行脚本可能会遮蔽标准库)。
# Port scan with a custom port set / range
python main.py portscan 192.168.1.10 --ports 22,80,443
python main.py portscan 192.168.1.10 --ports 1-1024
# Banner grab
python main.py banner 192.168.1.10 22
# Directory enumeration (default or custom wordlist)
python main.py dirscan http://target.local
python main.py dirscan http://target.local --wordlist admin login backup api
# Subdomain discovery
python main.py subdomains example.com
# Live-host discovery on a subnet
python main.py netscan 192.168.1.0/24
# HTTP response inspection
python main.py httpprobe http://target.local
# Credential test against a lab login form (authorization required)
python main.py logincheck http://target.local/login \
--users admin user --passwords admin 1234 password
# Global options
python main.py --threads 100 --timeout 1.5 -v portscan 192.168.1.10
# Skip the interactive prompt in scripted, pre-scoped engagements
python main.py --i-am-authorized netscan 10.0.0.0/24
pip install -r requirements-dev.txt # runtime + pytest + ruff
pytest -v # run tests
ruff check . # lint
运行时依赖位于 requirements.txt;测试/代码检查工具位于 requirements-dev.txt(其中会引入运行时依赖),因此最终用户永远不会安装 pytest。
GitLab 流水线(.gitlab-ci.yml)在每次推送时运行代码检查和测试。
simple-pentesting/
├── main.py # entry point (run from here)
├── src/ # the package
│ ├── __init__.py
│ ├── cli.py # argparse CLI
│ ├── config.py # defaults & Settings
│ ├── utils.py # validation helpers
│ ├── ui.py # rich UI: banner, progress, tables, auth prompt
│ ├── port_scanner.py # one file per feature ↓
│ ├── banner.py
│ ├── dir.py
│ ├── subdomain.py
│ ├── netscan.py
│ ├── http.py
│ └── login_check.py
├── tests/ # offline unit tests
├── .gitlab-ci.yml
├── requirements.txt # runtime deps
├── requirements-dev.txt # + pytest, ruff
├── LICENSE
└── .gitignore