windows自带工具netsh trace 抓包

发布时间 2023-11-11 11:50:39作者: id404

 

简单实例

 

管理员模式运行

netsh trace start capture=yes report=disabled  protocol=TCP ipv4.address=192.168.0.40 tracefile=d:\a.etl

 

 

停止抓包

netsh trace stop

 

 

-------------------------------------------------------------

其它可选参数

 report=enabled 则还会额外输出系统的各类软硬件及系统诊断配置信息并打包为cab格式。disabled

persistent=yes 即使重启设备也会继续抓包,除非运行netsh trace stop 。默认是no

fielmode=single|circular|append  默认为circular

maxsize  默认为250MB,如果不限制抓包文件大小需要设置maxsize=0 同时需要设置 filemode=single

overwrite=yes|no 抓包文件是否覆盖原文件

correlation=yes: 不收集关联事件 默认yes

 

 

指定源地址

IPv4.SourceAddress=<x.x.x.x>

IPv4.DstinstionAddress=<x.x.x.x>

 

 

protocol=<protocol>

例如:

protocol=6

protocol=!(TCP,UDP)

protocol=(4-10)

后面填写协议名称或协议号,其中

ICMP 协议号1

IPv4 协议号4

TCP 协议号6

UDP 协议号17

IPv6 协议号41

IPv6  icmp协议号58

 

IPv4.address=<x.x.x.x>

 

CaptureInterface=<interface name 或 GUID>  使用命令netsh trace show interfaces可查看可用的接口

例子: 

CaptureInterface={716A7812-4AEE-4545-9D00-C10EFD223551}

CaptureInterface=!{716A7812-4AEE-4545-9D00-C10EFD223551}

CaptureInterface="Local Area Connection"

 

 

查询其它可用的过滤条件

netsh trace show capturefilterhelp

 

 

------------------------------------------------------------------------------------

将抓包文件转换为XML

netsh trace convert input=NetTrace-ICP.etl output=NetTrace-ICP.etl.xml dump=XML

 

 

生成的etl文件可用微软件的network monitor查看 ,需要提前在Tools> options >Parser Profiles > windows 设置为Set As Active 

Pasted Graphic.png

 

若需要转换为wireshark可查看的文件格式pcapng,需要使用到转换工具

 

etl文件转换转换工具下载地址

https://github.com/microsoft/etl2pcapng/releases

 

etl2pcapng.exe <infile><outfile>

 

例子

etl2pcapng.exe capture.etl out.pcapng