saurlax/netvigil

GitHub: saurlax/netvigil

基于网络流量捕获与多源威胁情报比对的局域网威胁检测与可视化监控中心。

Stars: 2 | Forks: 4

# NetVigil ![](https://img.shields.io/badge/Go-blue) ![](https://img.shields.io/badge/SQLite-blue) ![](https://img.shields.io/badge/Vue-green) ![](https://img.shields.io/badge/ElementPlus-blue) ![](https://img.shields.io/badge/ECharts-darkred) 基于网络流量监控与分析的本地威胁情报中心 ## 如何运行 为了正确运行程序,您需要在根目录下创建一个 `config.toml` 文件,其内容应如下所示: ``` # 威胁检查周期 check_period = '10s' # Web 界面的 URL # 如果不想使用 Web 界面,请将其留空 web = '127.0.0.1:8080' # 捕获流量的选项,默认值为 false capture = true # Web 界面的登录凭证 username = 'username' password = 'password' [[tic]] type = 'local' [[tic]] type = 'netvigil' server = 'example.com:8080' apikey = 'your-api-key' [[tic]] type = 'threatbook' apikey = 'your-api-key' # 您可以在此处添加更多 TIC ``` 以下是您可以使用所有 TIC: - `local`:本地威胁情报中心(IP 黑名单数据库) - `ai-local`:使用 ONNX 模型的**基于 AI 的异常检测**(新增!) - `netvigil`:NetVigil,通常用于本地网络 - `threatbook`:[微步在线](https://x.threatbook.cn/) - `virustotal`:[VirusTotal](https://www.virustotal.com/) 此外,您还需要在根目录下提供一份 `GeoLite2-City.mmdb` 文件,您可以在 [GeoLite2 官网](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) 找到它。 之后,构建前端资源 ``` # 如果尚未安装,请先安装 pnpm:npm i -g pnpm cd frontend pnpm i pnpm run build ``` 然后,运行 go 项目 ``` cd .. go get go build . ``` ## 工作流程 ``` graph BT subgraph LAN client(NetVigil Client) server(NetVigil Server) client--if out-of-dated or not existed-->server server--Emergency broadcast-->client server--Ban the client if malicious IP found-->client end server--if out-of-dated or not existed-->public subgraph public [Public Threat Intelligence Center] Threatbook Netvigil ... end ``` ## APIs | 路径 | 方法 | 请求 | 响应 | 描述 | | ---------------------- | ------ | --------------------- | ----------- | ---------------------------------- | | `/api/login` | POST | `{username, password}` | Token | 登录页面 | | `/api/netstats` | GET | `?limit&page` | Netstat[] | 获取网络数据,需要身份验证 | | `/api/threats` | GET | `?limit&page` | Threat[] | 获取威胁 IP,需要身份验证 | | `/api/threats` | POST | `{ip}` | Error or Ok | 添加威胁 IP,需要身份验证 | | `/api/threats/:ip` | DELETE | `/ip` | | 删除威胁 IP,需要身份验证 | | `/api/clients` | GET | | Client[] | 获取用户信息,需要身份验证 | | `/api/clients` | POST | `{name}` | Error or Ok | 添加用户,需要身份验证 | | `/api/clients/:apikey` | DELETE | `/apikey` | Error or Ok | 删除用户,需要身份验证 | | `/api/config` | GET | | Config | 获取配置,需要身份验证 | | `/api/config` | POST | Config | | 修改配置,需要身份验证 | | `/api/check` | POST | `{apikey, ips}` | Threat[] | 检查 IP 信誉 | | `/api/stats` | GET | | Index Data | 获取用于展示的首页数据,需要身份验证 | ### 类型 ``` type Netstat struct { ID int64 Time int64 `json:"time"` LocalIP string `json:"localIP"` LocalPort uint16 `json:"localPort"` RemoteIP string `json:"remoteIP"` RemotePort uint16 `json:"remotePort"` Executable string `json:"executable"` Location string `json:"location"` } ``` ``` type Threat struct { ID int64 Time int64 `json:"time"` IP string `json:"ip"` TIC string `json:"tic"` Reason string `json:"reason"` Risk RiskLevel `json:"risk"` Credibility CredibilityLevel `json:"credibility"` } ``` ``` type Client struct { Name string `json:"name"` // Apikey is used in netvigil tic of `config.toml` Apikey string `json:"apikey"` } ``` ``` type Statistics struct { Time time.Time RiskUnknownCount int64 `json:"risk_unknown_count"` RiskSafeCount int64 `json:"risk_safe_count"` RiskNormalCount int64 `json:"risk_normal_count"` RiskSuspiciousCount int64 `json:"risk_suspicious_count"` RiskMaliciousCount int64 `json:"risk_malicious_count"` CredibilityLowCount int64 `json:"credibility_low_count"` CredibilityMediumCount int64 `json:"credibility_medium_count"` CredibilityHighCount int64 `json:"credibility_high_count"` } ``` ## 常见问题 - `invalid go version '1.21.6': must match format 1.23` 将您的 `go` 版本升级至至少 `1.21.6` - `Binary was compiled with 'CGO ENABLED=0', go-sqlite3 requires cgo to work. This is a stub` 在您的用户环境变量中添加 `CGO_ENABLED=1`。如果环境变量设置正确,您将通过以下命令看到 `set CGO_ENABLED=1` $ go env - `cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%` 安装 `gcc` 来修复此问题 - `# github.com/google/gopacket/pcap` `../go/pkg/mod/github.com/google/gopacket@v1.1.19/pcap/pcap_unix.go:34:10: fatal error: pcap.h: No such file or directory` 运行 `apt-get install libpcap-dev` 来解决此问题。
标签:CNCF毕业项目, EVTX分析, 日志审计