1

Linux网络流量安全审计的神器

 1 year ago
source link: https://www.51cto.com/article/719659.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux网络流量安全审计的神器

作者:入门小站 2022-09-26 14:24:18
该工具能够捕获网络流量中的数据包流并将其转换为系统可以识别的审计记录。生成的审计记录可以保存在单独的硬盘上,也可以通过网络将结果传到另外的服务器保存。
d5a91e739db3ada7359076bdb4dbcf12bec6ee.jpg

Netcap (NETwork CAPture) 是一个基于命令行的工具,用于对网络流量进行数据包数据分析。

Netcap:安全和可扩展的网络流量分析工具

  • Netcap 在通过网络流量收集数据包方面非常有效,数据包可以从离线PCAP-NG或PCAP转储文件等输入源收集,其它数据包可以通过实时界面访问和收集。
  • Netcap 使用 Google 的 Protocol Buffers 对其输出进行编码,解析很方便。也可以通过逗号分隔的CSV格式传输。为了不让系统中的数据占用太多空间,Netcap 将其所有数据压缩为gzip格式_._
  • Netcap 可以使用转储工具查看可用的审计记录,net.dump然后将审计记录转换为支持的文件格式,例如 CSV 和 JSON。由格式错误的数据包导致的日志错误记录在该errors.log部分中。
  • PCAP 和 PCAP-NG 支持
  • 支持 USB 捕捉
  • 允许实时捕捉
  • CLI命令行界面
  • 可以从分布式来源收集网络数据包
  • 对取证数据分析非常有用
  • net.capture(实时捕获审计记录或从转储文件中捕获)
  • net.dump(转储各种格式的审计记录)
  • net.label(用于从 netcap 数据创建带标签的 CSV 数据集的工具)
  • net.collect(分布式收集的收集服务器)
  • net.agent(分布式收集的传感器代理)
  • net.proxy(用于从 Web 服务捕获流量的 http 反向代理)
  • net.util(用于验证审计记录和转换时间戳的实用工具)
  • net.export(prometheus 指标的导出器)

支持的平台

  • Windows, Linux, OS X

Netcap的安装

使用Go Get

$ go get -u github.com/dreadl0ck/netcap/...
  • 要安装命令行(使用 Development Build),请运行:
$ go build -o $(go env GOPATH)/bin/netcap -i github.com/dreadl0ck/netcap/cmd
  • S使用brew安装
$ brew tap dreadl0ck/formulas  
$ brew install netcap
  • 安装Netcap后,执行如下命令检查所有单元是否正常运行:
$ go test -v -bench=. ./...

Netcap使用

/ |  
 _______    ______   _10 |_     _______   ______    ______
/     / \\  /    / \\ / 01/  |   /     / | /    / \\  /    / \\
0010100 /|/011010 /|101010/   /0101010/  001010  |/100110  |
01 |  00 |00    00 |  10 | __ 00 |       /    10 |00 |  01 |
10 |  01 |01001010/   00 |/  |01 \\_____ /0101000 |00 |__10/|
10 |  00 |00/    / |  10  00/ 00/    / |00    00 |00/   00/
00/   10/  0101000/    0010/   0010010/  0010100/ 1010100/
                                                  00 |
Network Protocol Analysis Framework               00 |
created by Philipp Mieden, 2018                   00/
v5
 +---------------+--------+                                                                                                                                                                                                              
 |   Setting     | Value  |                                                                                                                                                                                                              
 +---------------+--------+                                                                                                                                                                                                              
 | Workers       | 1000   |                                                                                                                                                                                                              
 | MemBuffer     | true   |                                                                                                                                                                                                              
 | Compression   | true   |                                                                                                                                                                                                              
 | PacketBuffer  | 100    |                                                                                                                                                                                                              
 +---------------+--------+                                                                                                                                                                                                              
 spawned 1000 workers                                                                                                                                                                                                                    
 initialized 29 layer encoders | buffer size: 4096                                                                                                                                                                                      
 initialized 7 custom encoders | buffer size: 4096                                                                                                                                                                                      
 running since 535785474s, captured 13000 packets…
  • 要查看 Netcap 所支持的所有编码器,加上–encoders参数,根据你要执行的操作,你可以使用这些标志来排除-exclude或包含-include编码器 。
  • 从网卡读取流量:
$ net.capture -iface eth0
  • 使用 Ctrl-C (SIGINT) 停止捕获。
  • PCAP 从和PCAP-NG转储文件中读取流量:
$ net.capture -r traffic.pcap
  • 读取转储文件并打印stdout 为 csv格式
$ net.dump -r TCP.ncap.gz
  • 将 CSV 输出保存到文件:
$ net.dump -r TCP.ncap.gz -select Timestamp,SrcPort,DstPort > tcp.csv
  • 还可以通过grafana实时展示网络数据
责任编辑:庞桂玉 来源: Linux学习

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK