AxthonyV/WhoKnocks

GitHub: AxthonyV/WhoKnocks

实时监控终端入站连接,识别来源 IP、威胁等级并记录日志的零配置仪表盘。

Stars: 0 | Forks: 0


``` ██╗ ██╗██╗ ██╗ ██████╗ ██╗ ██╗███╗ ██╗ ██████╗ ██████╗██╗ ██╗███████╗ ██║ ██║██║ ██║██╔═══██╗██║ ██╔╝████╗ ██║██╔═══██╗██╔════╝██║ ██╔╝██╔════╝ ██║ █╗ ██║███████║██║ ██║█████╔╝ ██╔██╗ ██║██║ ██║██║ █████╔╝ ███████╗ ██║███╗██║██╔══██║██║ ██║██╔═██╗ ██║╚██╗██║██║ ██║██║ ██╔═██╗ ╚════██║ ╚███╔███╔╝██║ ██║╚██████╔╝██║ ██╗██║ ╚████║╚██████╔╝╚██████╗██║ ██╗███████║ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ``` **实时监控终端入站连接。** *精准识别访问你机器的每个“敲门者”及其目的。*
[![Python](https://img.shields.io/badge/Python-3.8%2B-C8934A?style=flat-square&logo=python&logoColor=white)](https://python.org) [![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux%20%7C%20macOS-C8934A?style=flat-square)](https://github.com/AxthonyV/WhoKnocks) [![License](https://img.shields.io/badge/License-MIT-C8934A?style=flat-square)](LICENSE)
## What is WhoKnocks? WhoKnocks 是一个实时终端仪表板,展示 **你本机** 上所有活跃的网络连接——包括来源 IP、所在国家、发起进程以及端口是否可疑。 你是否曾好奇 *“我的浏览器究竟连接到了哪里?”* 或 *“为什么 445 端口有监听?”* ——WhoKnocks 能实时回答这些问题,提供地理位置、威胁评估,并自动记录 JSON 日志。无需配置,一条命令即可运行。 ## Features - **实时连接表** — 显示活跃连接的远程 IP、端口、城市、国家、进程名与威胁等级 - **地理位置解析** — 后台将外部 IP 解析为对应的国家与城市 - **国家旗帜标记** — 一目了然识别来源国家 - **威胁评估** — 标记可疑端口的连接(如 SSH、RDP、SMB、VNC、Metasploit 等) - **来源国家排行** — 以柱状图展示连接最多的国家 - **可疑端口面板** — 专门展示高危端口活动 - **按进程统计** — 查看哪些应用拥有最活跃的连接 - **自动 JSON 日志** — 每几秒将快照保存至 `whoknocks_log.json` - **跨平台支持** — Windows、Linux、macOS - **零配置** — 克隆、安装、运行即可 ## Preview ``` ╭──────────────────────────────────────────────────────────────────────────────╮ │ WhoKnocks · watching your connections · Sun Apr 20 14:55:03 · 12 IPs │ ╰──────────────────────────────────────────────────────────────────────────────╯ ┌─ Active Connections [14] ───────────────────────────────────────────────────┐ │ Time Remote IP Port Country Process Threat │ │ 14:55:01 142.250.80.46 443 🇺🇸 United States chrome LOW │ │ 14:55:01 185.125.188.55 443 🇬🇧 United Kingdom snapd LOW │ │ 14:55:02 31.13.72.36 443 🇺🇸 United States chrome LOW │ │ 14:55:03 192.168.1.1 22 Local Network ssh LOCAL │ └─────────────────────────────────────────────────────────────────────────────┘ ┌─ Stats ──────┐ ┌─ Top Origins ───────────┐ ┌─ ⚠ Suspicious Ports ───────┐ │ Established 9│ │ 🇺🇸 United States ████ 7│ │ ✓ No suspicious ports │ │ Listening 3│ │ 🇬🇧 United Kingdom ██ 2│ │ detected │ │ External 11│ │ 🇩🇪 Germany █ 1│ └─────────────────────────────┘ │ ⚠ High 0 │ └─────────────────────────┘ └─────────────┘ ``` preview ## Getting Started ### Requirements - Python 3.8+ - pip ### Installation ``` # Clone the repository git clone https://github.com/AxthonyV/WhoKnocks.git cd WhoKnocks ``` **Linux / macOS** ``` bash install.sh ``` **Windows** ``` install.bat ``` **手动安装** ``` pip install -r requirements.txt ``` ### Run ``` # Linux / macOS (recommended: sudo for full process visibility) sudo python3 whoknocks.py # Without sudo (works, some process names may show as "?") python3 whoknocks.py # Windows (run as Administrator for best results) python whoknocks.py ``` ## Understanding Threat Levels | Level | Color | Meaning | |-------|-------|---------| | `HIGH` | 🔴 Red | 连接位于已知高危端口(RDP、SMB、VNC 等) | | `MED` | 🟡 Amber | 来自外部的连接,目标为特权端口(<1024) | | `LOW` | 🔵 Teal | 来自外部的连接,目标为标准端口 | | `LOCAL` | 🟢 Green | 同一局域网内的连接 | ## Monitored Suspicious Ports | Port | Service | Port | Service | |------|---------|------|---------| | 22 | SSH | 3389 | RDP | | 23 | Telnet | 5900 | VNC | | 445 | SMB | 1433 | MSSQL | | 3306 | MySQL | 6379 | Redis | | 27017 | MongoDB | 9200 | Elasticsearch | | 4444 | Metasploit | 1337 | Backdoor/Leet | ## Log Output WhoKnocks 会自动每隔几秒保存一次 JSON 快照: ``` [ { "time": "14:55:03", "remote_ip": "142.250.80.46", "remote_port": 443, "country": "United States", "city": "Mountain View", "process": "chrome", "threat": "LOW", "status": "ESTABLISHED" } ] ``` ## Dependencies | Package | Version | Purpose | |---------|---------|---------| | `psutil` | ≥ 6.1.0 | 网络连接与进程信息 | | `rich` | ≥ 13.9.4 | 终端 UI 渲染 | | `requests` | ≥ 2.32.3 | IP 地理位置查询 | ## Compatibility | OS | Status | |----|--------| | Windows 10 / 11 | ✅ 完全支持 | | Ubuntu / Debian | ✅ 完全支持 | | Arch Linux | ✅ 完全支持 | | macOS 12+ | ✅ 完全支持 | | Raspberry Pi OS | ✅ 完全支持 | ## Project Structure ``` WhoKnocks/ ├── whoknocks.py # Main application ├── requirements.txt # Dependencies ├── install.sh # Linux/macOS installer ├── install.bat # Windows installer ├── whoknocks_log.json # Auto-generated connection log ├── LICENSE └── README.md ``` ## Educational Use WhoKnocks 旨在作为网络工程与计算机科学学生的学习工具,演示: - 使用 `psutil` 实时监控套接字 - 通过公共 API 进行 IP 地理位置查询 - 基于知名端口注册表的威胁启发式规则 - 使用 Python 线程进行异步后台数据获取 - Rich 终端 UI 设计 ## License MIT License — see [LICENSE](LICENSE) for details.
标签:Cloudflare, IP定位, MITRE ATT&CK, Python, WhoKnocks, 地理定位, 威胁情报, 威胁评估, 安全可视化, 工具集, 开发者工具, 开源安全工具, 无后门, 监控仪表盘, 终端仪表盘, 网络连接监控, 进程识别, 连接追踪, 逆向工具, 逆向工程平台, 零配置