zeroman-root/nexport
GitHub: zeroman-root/nexport
一款 AI 驱动的网络侦察框架,将 Nmap 扫描结果与实时 OSINT 威胁情报和 AI 安全分析深度整合,为安全分析师提供即时漏洞洞察。
Stars: 6 | Forks: 0
# ⚡ NEXPORT — 智能威胁分析套件
**NEXPORT** 是一款先进的高性能安全侦察和自动化工具,专为 **Kali Linux** 和安全操作量身定制。由网络安全专家 **Steven Osama (zeroman)** 设计和开发,它弥合了原始网络扫描与可操作的漏洞情报之间的差距。
NEXPORT 具备 **实时威胁情报** — 与 **Shodan API** 和 **CIRCL CVE API** 实时集成,通过外部视角数据、检测到的服务版本的实时 CVE 命中以及面向互联网的漏洞遥测数据,自动丰富每次扫描的内容。现在可以激活可选的 **AI 智能层**,以提供结构化的安全评估 — 由 OpenAI、Google 或 Anthropic 提供支持 — 这些评估会显示在原始数据之前,为 SOC 分析师和渗透测试人员提供对每次扫描的即时、分析师级别的解读。
NEXPORT 采用令人惊艳的高对比度 **赛博朋克 ANSI 霓虹界面**,确保在关键任务时间线下实现最大的数据可读性。
## ⚡ 核心功能
* 📦 **全系统自动集成:** 高级安装程序部署了一个原生包装器,授予从系统任何位置执行的全部权限。
* 🛠️ **严格的模块化架构:** 代码逻辑、UI 渲染、Nmap 引擎、数据库、实时 API 客户端和 AI 智能层严格分离在干净且自带说明的 `.sh` 文件中,实现 **零代码冗余**。
* 🗄️ **海量漏洞数据库:** 深度映射的目录将数千个端口链接到风险指数(高/中/低)、加密合规标志(`[CLR]`)以及已知的现实漏洞利用。
* 🔍 **智能实时 Nmap 解析器:** 将 Nmap 封装为 6 种专业部署模式(快速、标准、完全、隐蔽、漏洞、自定义),并实现自动化版本提取和查询集成。
* 🌐 **实时 Shodan 集成:** 扫描后自动为任何公共 IP 查询 Shodan API — 从 Shodan 的全网扫描视角获取开放端口、服务 banner、组织数据、ISP、地理位置和实时 CVE。
* 🛡️ **通过 CIRCL 进行实时 CVE 查询:** 从 nmap 输出中检测服务版本字符串,并向 `cve.circl.lu` 发送轻量级 HTTP 请求,为每个检测到的版本实时检索前 5 个最关键的实时 CVE ID。
* 🤖 **AI 智能层 *(新增)*:** 可选的 AI 驱动分析模块,提供结构化的安全洞察 — 威胁概述、关键发现、攻击面分析和加固建议 — 由您选择的 AI 提供商支持。默认处于休眠状态;仅在存在有效密钥时激活。
* 📊 **生产级报告:** 即时将扫描结果导出为 `JSON`、`CSV`、`Markdown (.md)` 或可搜索的 `HTML`,用于客户报告。
* 🎯 **游戏化培训引擎:** 交互式测验模式可培训初级 SOC 分析师和渗透测试人员掌握关键端口和威胁场景。
## 🤖 AI 智能层 — 架构
`modules/ai_intel.sh` 是 NEXPORT 中的可选智能层。它作为 **显示前分析流水线** 运行,在向操作员显示任何数据之前处理原始扫描输出。
### 系统协议
AI 模块强制执行四个硬性约束:
| 约束 | 实现 |
|---|---|
| **范围限制** | AI 仅限于分析输入的扫描数据。它被明确指示不得修改、重构或引用 NEXPORT 代码库。 |
| **品牌完整性** | 版权声明、项目品牌和署名始终保持不变。 |
| **数据完整性** | 该模型被指示绝不捏造或幻觉漏洞。如果数据模糊或不足以评估某个类别,它必须声明:*“数据不足以进行评估。”* |
| **可选激活** | 除非 `~/.nexport/config` 中存在经过验证的 API key,否则该模块保持休眠状态。没有 key = 标准模式,保持不变。 |
### 架构流程
```
[ nmap scan complete ]
│
▼
run_ai_intel_analysis() ← modules/ai_intel.sh (FIRST — if key active)
└── Structured assessment:
├── Threat Overview
├── Critical Findings
├── Attack Surface Analysis
└── Analyst Recommendations
│
▼
_summarize_nmap_output() ← Local database analysis
│
▼
run_live_threat_intel() ← modules/api_intel.sh
├── Shodan Host API ← External ports, banners, org, vulns
└── CIRCL CVE search API ← Live CVE IDs per detected version
```
**显示顺序:**
1. **AI 智能洞察** *(如果 key 处于活动状态)*
2. **原始扫描数据** — NexPort 数据库分析、Shodan、CVE 报告
**关键设计属性:**
- 优雅降级:如果未配置 key 或无法访问提供商,该层将被静默跳过 — 标准扫描输出完全不受影响。
- AI 接收扫描输出的截断、净化视图(最多 3,500 个字符),以防止 token 溢出。
- API key 以 `chmod 600` 权限存储在 `~/.nexport/config` 中 — 绝不会回显到终端。
- 所有三个受支持的提供商使用独立的 endpoint 和 header 格式,通过与 key 一起存储的 `NEXPORT_AI_PROVIDER` 标识符进行透明管理。
## 🔑 AI 智能层设置
### 交互式配置工作流
执行 `nexport intel set-ai-key ` 会触发交互式设置,该设置 **不会立即保存 key**。流程如下:
```
Step 1: Provider selection menu
┌─────────────────────────────────────────────────────────┐
│ 1) OpenAI — GPT-4o / GPT-4-Turbo │
│ 2) Google — Gemini 1.5 Pro / Flash │
│ 3) Anthropic — Claude 3.5 Sonnet │
└─────────────────────────────────────────────────────────┘
Step 2: Handshake validation
A lightweight API call verifies the key against the selected
provider before any data is written to disk.
Step 3: Contextual storage (only on validation success)
Both NEXPORT_AI_KEY and NEXPORT_AI_PROVIDER are written to
~/.nexport/config with chmod 600 permissions.
```
```
# 激活 AI Intelligence Layer(交互式 — 提示输入 provider):
nexport intel set-ai-key YOUR_API_KEY
# 停用(恢复至标准 mode):
nexport intel clear-ai-key
# 查看 AI layer 命令参考:
nexport intel ai-help
```
### 支持的提供商
| # | 提供商 | 使用的模型 | API Endpoint |
|---|----------|-------------|-------------|
| 1 | **OpenAI** | GPT-4o / GPT-4-Turbo | `api.openai.com/v1/chat/completions` |
| 2 | **Google** | Gemini 1.5 Pro / Flash | `generativelanguage.googleapis.com/v1beta` |
| 3 | **Anthropic** | Claude 3.5 Sonnet | `api.anthropic.com/v1/messages` |
### 💡 专业提示:终极免费且快速的设置(推荐)
为了在 **极端的推理能力、超快的响应速度和 100% 的免费访问** 之间取得绝对最佳平衡,我们强烈建议通过 **Groq** 激活使用 **Meta 的 Llama 3.3 (70B)** 的 AI 层。
* **为什么选择此配置?** Groq 的免费层级非常慷慨,其 LPU 架构可生成完整的安全摘要,并以接近零延迟(最多约 3-5 秒)将其流式传输到您的终端。
* **如何配置:**
1. 从 [Groq 控制台](https://console.groq.com/) 获取免费的 API key。
2. 运行 `nexport intel set-ai-key YOUR_GROQ_API_KEY`。
3. 从交互式菜单中选择 **选项 4 (自定义)**。
4. 在出现提示时提供以下值:
* **Base URL / Endpoint:** `https://api.groq.com/openai/v1/chat/completions`
* **模型名称:** `llama-3.3-70b-versatile`
## 🌐 实时威胁情报 — Shodan 集成
```
# 保存你的 Shodan API key(安全存储于 ~/.nexport/config)
nexport intel set-key YOUR_SHODAN_API_KEY
# 或者,仅为当前 session 导出它:
export SHODAN_API_KEY=YOUR_SHODAN_API_KEY
# 移除已保存的 key:
nexport intel clear-key
```
## 🛡️ 实时 CVE 查询 — CIRCL.LU
无需 API key。CIRCL 的 CVE API 是开放且免费的。
在任何标准、完全、隐蔽、漏洞或自定义扫描(包含 `-sV` 的模式)之后,NexPort 会自动从 nmap banner 中提取带版本的服务字符串:
```
22/tcp open ssh OpenSSH 8.4p1 Debian
80/tcp open http Apache httpd 2.4.49
3306/tcp open mysql MySQL 5.7.36-log
```
每个检测到的 ` ` 对都会触发对以下地址的查询:
```
https://cve.circl.lu/api/search//
```
前 5 个最严重的 CVE ID 会从 JSON 响应中提取出来,并内嵌显示在 **实时威胁情报** 部分。
## ⚙️ 系统安装与全局部署
```
# 1. Clone 官方 repository:
git clone https://github.com/zeroman-root/nexport.git
cd nexport
# 2. 授予执行 permissions:
chmod +x nexport/nexport
# 3. system-wide 安装(需要 root):
sudo ./nexport/nexport --install
# 4. 从任意位置全局运行:
nexport
# 5.(可选)安装后设置你的 Shodan API key:
nexport intel set-key YOUR_SHODAN_API_KEY
# 6.(可选)激活 AI Intelligence Layer:
nexport intel set-ai-key YOUR_AI_API_KEY
# ❌ 卸载:
sudo nexport --uninstall
```
## 📖 完整命令参考
### 🔎 查询
| 命令 | 描述 | 示例 |
|---------|-------------|---------|
| `-h ` | 端口的详细信息 | `-h 22`, `-h ssh`, `-h 443` |
| `-a`, `--all` | 按类别列出所有端口 | `-a` |
| `-t`, `--top` | 前 30 个最常受攻击的端口 | `-t` |
### 🔍 搜索与过滤
| 命令 | 描述 | 示例 |
|---------|-------------|---------|
| `-s ` | 搜索名称、协议、描述、CVE | `-s database` |
| `-c ` | 按类别过滤 | `-c web` |
| `-p ` | 按协议过滤 | `-p tcp` |
| `-e ` | 按加密过滤 | `-e no` |
| `-r ` | 按风险等级过滤 | `-r critical` |
| `--cve ` | 查找与 CVE 关联的端口 | `--cve CVE-2020-1938` |
### 📡 扫描与分析
| 命令 | 描述 |
|---------|-------------|
| `scan ` | 实时 nmap 扫描 + AI 洞察 + NexPort 数据库分析 + 实时威胁情报 |
| `paste` / `summarize` | 粘贴现有的 nmap 输出以获取 AI 洞察 + 数据库分析 |
**`scan ` 之后可用的扫描模式:**
| # | 模式 | 标志 | 注意事项 |
|---|------|-------|-------|
| 1 | Quick (快速) | `-T4 --open` | 无版本检测(约 10 秒) |
| 2 | Standard (标准) | `-T4 -sV --open` | 版本检测 — **启用 CVE 查询**(约 30 秒) |
| 3 | Full (完全) | `-T4 -sV -p- --open` | 所有 65535 个端口 + 版本(约 5-20 分钟) |
| 4 | Stealth (隐蔽) | `-T4 -sS -O -A --open` | 需要 root 权限 |
| 5 | Vuln (漏洞) | `-T4 -sV --script=vuln --open` | NSE 漏洞脚本,需要 root 权限 |
| 6 | Custom (自定义) | 用户自定义 | 输入您自己的 nmap 标志 |
### 🌐 实时威胁情报
| 命令 | 描述 |
|---------|-------------|
| `intel set-key ` | 将 Shodan API key 保存到 `~/.nexport/config` |
| `intel clear-key` | 删除已保存的 Shodan API key |
| `intel ` | 针对特定 IP 的按需 Shodan + CVE 查询 |
| `intel help` | 显示情报子命令参考 |
### 🤖 AI 智能层
| 命令 | 描述 |
|---------|-------------|
| `intel set-ai-key ` | 交互式提供商选择 + 握手验证 + key 存储 |
| `intel clear-ai-key` | 删除 AI API key(恢复为标准模式) |
| `intel ai-help` | 显示 AI 智能层命令参考 |
**AI 智能层输出示例:**
```
╔══════════════════════════════════════════════════════════════════════╗
║ ★ AI INTELLIGENCE INSIGHT ║
║ Powered by Anthropic Claude 3.5 Sonnet · Input-scoped analysis only ║
╚══════════════════════════════════════════════════════════════════════╝
────────────────────────────────────────────────────────────────────
1. THREAT OVERVIEW
The target presents a moderately elevated attack surface. Exposure
of SSH and an unencrypted HTTP service on port 80 constitutes the
primary risk. No encrypted web layer (443) was detected.
2. CRITICAL FINDINGS
Port 3306 (MySQL) is externally reachable. Database services
exposed directly to the internet represent a critical misconfiguration.
3. ATTACK SURFACE ANALYSIS
An adversary would prioritise the MySQL port for credential brute-force
and the SSH service for key-based exploitation if the server version
is unpatched. The HTTP service may expose web application attack vectors.
4. ANALYST RECOMMENDATIONS
[1] Immediately restrict port 3306 to localhost or a VPN interface.
[2] Deploy a TLS certificate and enforce HTTPS on port 443.
[3] Audit SSH configuration: disable PasswordAuthentication, enforce
key-based auth, and review authorised_keys for all accounts.
────────────── AI analysis complete · Raw data follows ──────────────
```
### ⚙️ 系统
| 命令 | 描述 |
|---------|-------------|
| `-q`, `--quiz` | 交互式端口知识测验 |
| `--install` | 安装到 `/usr/local/bin`(需要 sudo 权限) |
| `--uninstall` | 从系统中移除(需要 sudo 权限) |
| `--version` | 显示版本 |
| `--help` | 显示帮助 |
| `exit` / `quit` | 退出 NexPort |
## 🗂️ 项目结构
```
nexport/
├── nexport # Main entry point & dispatcher
├── lib/
│ ├── colors.sh # ANSI color variables, badges, risk icons
│ └── ui.sh # Banner, dividers, port info printers
├── data/
│ ├── ports_db.sh # Core port vulnerability database
│ ├── ports_db_ext1.sh # Extended database — batch 1
│ ├── ports_db_ext2.sh # Extended database — batch 2
│ └── ports_db_ext3.sh # Extended database — batch 3
└── modules/
├── lookup.sh # Port lookup and show-all logic
├── search.sh # Keyword search, protocol/risk/enc filters, CVE search
├── category.sh # Category listing and filtering
├── top_ports.sh # Top 30 most targeted ports
├── quiz.sh # Interactive training quiz
├── nmap_scan.sh # Live nmap scan engine
├── summarizer.sh # Nmap output parser & threat summary
├── export.sh # JSON / CSV / Markdown / HTML export
├── api_intel.sh # Shodan + CIRCL live threat intel
└── ai_intel.sh # ★ NEW — Optional AI Intelligence Layer
```
## 🔗 使用的 API Endpoint
| API | Endpoint | 认证 | 注意事项 |
|-----|----------|------|-------|
| Shodan Host Lookup | `https://api.shodan.io/shodan/host/{ip}?key={key}` | API Key | 视 Shodan 计划而定 |
| CIRCL CVE Search | `https://cve.circl.lu/api/search/{product}/{version}` | 无 | 开放,合理使用 |
| OpenAI Chat | `https://api.openai.com/v1/chat/completions` | Bearer token | GPT-4o |
| Google Gemini | `https://generativelanguage.googleapis.com/v1beta/...` | Query param | Gemini 1.5 Pro |
| Anthropic Messages | `https://api.anthropic.com/v1/messages` | `x-api-key` header | Claude 3.5 Sonnet |
## 🧪 jq 与 回退解析
NexPort 的 `api_intel.sh` 在运行时自动检测 `jq`:
| 功能 | 使用 `jq` | 不使用 `jq` |
|---------|-----------|--------------|
| Shodan 组织/ISP/国家 | ✅ 完整 | ✅ 完整 |
| Shodan 端口列表 | ✅ 完整 | ✅ 完整 |
| Shodan banner 详细信息 | ✅ 完整(按服务) | ⚠️ 基础(正则表达式,受限) |
| Shodan 漏洞 CVE ID | ✅ 完整 | ✅ 完整 |
| CIRCL CVE ID | ✅ 完整 | ✅ 完整 |
安装 `jq` 以获取最丰富的输出:
```
sudo apt install jq # Debian / Ubuntu / Kali
sudo dnf install jq # Fedora / RHEL
sudo pacman -S jq # Arch Linux
brew install jq # macOS
```
## ⚠️ 操作说明
* **CIRCL CVE 查询需要版本检测。** 快速扫描模式 (`-T4 --open`) 不调用 `-sV`,因此不会提取版本字符串,并且 CVE 查询部分会相应地为您提供建议。
* **Shodan 仅丰富公共 IP。** 私有 RFC1918 地址(`10.x`、`172.16-31.x`、`192.168.x`)、loopback、link-local 和多播范围会自动从外部 Shodan 查询中排除。
* **AI 分析受限于输入。** AI 模块仅分析传递给它的扫描数据。明确禁止其访问、修改或引用 NEXPORT 代码库。如果无法根据可用数据执行分析,它会明确声明。
* **API key 以 `chmod 600` 权限存储。** 位于 `~/.nexport/config` 的 key 文件仅限所有者访问。任何 key 值都不会被打印或记录到终端。
* **进行所有实时 API 调用都需要 curl。** 它预装在所有主要的 Linux 发行版中。
* 现有的本地扫描摘要和数据库查询流水线**完全不受** AI 层的影响。AI 智能部分位于其之前,绝不会干扰标准输出。
## 📜 许可证
```
Apache License
Version 2.0, January 2004
http://apache.org
Copyright 2026 Steven Osama (zeroman)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://apache.orgLICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
---
SPECIAL ATTRIBUTION REQUIREMENT:
Any derivative works, forks, or redistributions of this software MUST prominently display the original author's name "Steven Osama (zeroman)" and a link to the original repository (https://github.com) in the software's documentation, source code, and user interface.
```
*NEXPORT — 智能威胁分析套件*
*由 **Steven Osama (zeroman)** 开发 — https://github.com/zeroman-root/nexport.git*
标签:CTI, ESC4, OSINT, Petitpotam, Sysdig, XSS, 云存储安全, 威胁侦察, 实时处理, 应用安全, 插件系统, 漏洞情报, 网络扫描