Wireshark 用户使用手册 ———— 命令行控制 Wireshark

参数介绍

 你可以从命令行启动 Wireshark,但也可以从大多数窗口管理器启动它。 在本节中,我们将看看从命令行启动它。 Wireshark 支持大量的命令行参数。 要查看它们是什么,只需输入命令wireshark -h 并且应该打印Wireshark 提供的帮助信息(或类似的东西)中显示的帮助信息。cmd窗口的需要在C盘中的安装路径下打开,即 C:\Windows\System32\cmd.exe。

Capture interface:
  -i <interface>, --interface <interface>
                           name or idx of interface (def: first non-loopback)
  -f <capture filter>      packet filter in libpcap filter syntax
  -s <snaplen>, --snapshot-length <snaplen>
                           packet snapshot length (def: appropriate maximum)
  -p, --no-promiscuous-mode
                           don't capture in promiscuous mode
  -k                       start capturing immediately (def: do nothing)
  -S                       update packet display when new packets are captured
  -l                       turn on automatic scrolling while -S is in use
  -I, --monitor-mode       capture in monitor mode, if available
  -B <buffer size>, --buffer-size <buffer size>
                           size of kernel buffer (def: 2MB)
  -y <link type>, --linktype <link type>
                           link layer type (def: first appropriate)
  --time-stamp-type <type> timestamp method for interface
  -D, --list-interfaces    print list of interfaces and exit
  -L, --list-data-link-types
                           print list of link-layer types of iface and exit
  --list-time-stamp-types  print list of timestamp types for iface and exit

Capture stop conditions:
  -c <packet count>        stop after n packets (def: infinite)
  -a <autostop cond.> ..., --autostop <autostop cond.> ...
                           duration:NUM - stop after NUM seconds
                           filesize:NUM - stop this file after NUM KB
                              files:NUM - stop after NUM files
                            packets:NUM - stop after NUM packets
Capture output:
  -b <ringbuffer opt.> ..., --ring-buffer <ringbuffer opt.>
                           duration:NUM - switch to next file after NUM secs
                           filesize:NUM - switch to next file after NUM KB
                              files:NUM - ringbuffer: replace after NUM files
                            packets:NUM - switch to next file after NUM packets
                           interval:NUM - switch to next file when the time is
                                          an exact multiple of NUM secs
RPCAP options:
  -A <user>:<password>     use RPCAP password authentication
Input file:
  -r <infile>, --read-file <infile>
                           set the filename to read from (no pipes or stdin!)

Processing:
  -R <read filter>, --read-filter <read filter>
                           packet filter in Wireshark display filter syntax
  -n                       disable all name resolutions (def: all enabled)
  -N <name resolve flags>  enable specific name resolution(s): "mnNtdv"
  -d <layer_type>==<selector>,<decode_as_protocol> ...
                           "Decode As", see the man page for details
                           Example: tcp.port==8888,http
  --enable-protocol <proto_name>
                           enable dissection of proto_name
  --disable-protocol <proto_name>
                           disable dissection of proto_name
  --enable-heuristic <short_name>
                           enable dissection of heuristic protocol
  --disable-heuristic <short_name>
                           disable dissection of heuristic protocol

User interface:
  -C <config profile>      start with specified configuration profile
  -H                       hide the capture info dialog during packet capture
  -Y <display filter>, --display-filter <display filter>
                           start with the given display filter
  -g <packet number>       go to specified packet number after "-r"
  -J <jump filter>         jump to the first packet matching the (display)
                           filter
  -j                       search backwards for a matching packet after "-J"
  -t a|ad|adoy|d|dd|e|r|u|ud|udoy
                           format of time stamps (def: r: rel. to first)
  -u s|hms                 output format of seconds (def: s: seconds)
  -X <key>:<value>         eXtension options, see man page for details
  -z <statistics>          show various statistics, see man page for details

Output:
  -w <outfile|->           set the output filename (or '-' for stdout)
  --capture-comment <comment>
                           set the capture file comment, if supported

Miscellaneous:
  -h, --help               display this help and exit
  -v, --version            display version info and exit
  -P <key>:<path>          persconf:path - personal configuration files
                           persdata:path - personal data files
  -o <name>:<value> ...    override preference or recent setting
  -K <keytab>              keytab file to use for kerberos decryption
  --fullscreen             start Wireshark in full screen

参数解析

 首先要注意的是,单独发出命令wireshark 将调出Wireshark。 但是,可以根据需要包含任意数量的命令行参数。

捕获停止

  -c <packet count>        stop after n packets (def: infinite)
  -a <autostop cond.> ..., --autostop <autostop cond.> ...
                           duration:NUM - stop after NUM seconds
                           filesize:NUM - stop this file after NUM KB
                           files:NUM - stop after NUM files
                           packets:NUM - stop after NUM packets

-a / --autostop

 指定一个标准,用于指定 Wireshark 何时停止写入捕获文件。 标准的形式为 test:value,其中 test 是以下之一:
  1. duration:value: 秒值过后停止写入捕获文件。
  2. filesize:value: 在达到值 KB 的大小后停止写入捕获文件(其中 KB 是 1000 字节,而不是 1024 字节)。 如果此选项与 -b 选项一起使用,Wireshark 将停止写入当前捕获文件并在达到文件大小时切换到下一个。
  **3. files:value:**写入文件数量后停止写入捕获文件。
  **4. packets:value:**写入数据包数量值后停止写入捕获文件。

-c [capture packet count]

 此选项指定捕获实时数据时要捕获的最大数据包数。 它将与 -k 选项结合使用。

–capture-comment [comment]

 如果文件格式支持,将注释字符串添加到捕获文件中

捕获输出

  -b <ringbuffer opt.> ..., --ring-buffer <ringbuffer opt.>
                           duration:NUM - switch to next file after NUM secs
                           filesize:NUM - switch to next file after NUM KB
                              files:NUM - ringbuffer: replace after NUM files
                            packets:NUM - switch to next file after NUM packets
                           interval:NUM - switch to next file when the time is an exact multiple of NUM secs

-b [ringbuffer opt.] …, --ring-buffer

 如果指定了最大捕获文件大小,则此选项会导致 Wireshark 以“环形缓冲区”模式运行,并具有指定的文件数量。 在“环形缓冲区”模式下,Wireshark 将写入多个捕获文件。 它们的名称基于文件编号以及创建日期和时间。当第一个捕获文件填满时,Wireshark 将切换到写入下一个文件,依此类推。 使用文件选项还可以形成“环形缓冲区”。 这将填充新文件直到指定的文件数,此时第一个文件中的数据将被丢弃,以便可以写入新文件。如果指定了可选的持续时间,即使当前文件没有完全填满,
Wireshark 也会在指定的秒数过后切换到下一个文件。
  1. duration:value: 即使当前文件没有完全填满,也在 value 秒后切换到下一个文件。
  2. filesize:value: 在达到值千字节(其中千字节是 1000 字节,而不是 1024 字节)后切换到下一个文件。
  3. files:value: 在写入文件数量(形成环形缓冲区)后,再次从第一个文件开始。
  4. packets:value: 写入值 number of packet 后切换到下一个文件,即使当前文件没有完全填满。
  5. interval:value: 当时间是 value 秒的精确倍数时,切换到下一个文件。

捕捉界面

 -i <interface>, --interface <interface>
                           name or idx of interface (def: first non-loopback)
  -f <capture filter>      packet filter in libpcap filter syntax
  -s <snaplen>, --snapshot-length <snaplen>
                           packet snapshot length (def: appropriate maximum)
  -p, --no-promiscuous-mode
                           don't capture in promiscuous mode
  -k                       start capturing immediately (def: do nothing)
  -S                       update packet display when new packets are captured
  -l                       turn on automatic scrolling while -S is in use
  -I, --monitor-mode       capture in monitor mode, if available
  -B <buffer size>, --buffer-size <buffer size>
                           size of kernel buffer (def: 2MB)
  -y <link type>, --linktype <link type>
                           link layer type (def: first appropriate)
  --time-stamp-type <type> timestamp method for interface
  -D, --list-interfaces    print list of interfaces and exit
  -L, --list-data-link-types
                           print list of link-layer types of iface and exit
  --list-time-stamp-types  print list of timestamp types for iface and exit

-i [interface], --interface [interface]

 设置用于实时数据包捕获的网络接口或管道的名称。网络接口名称应与 wireshark -D 中列出的名称之一匹配。 也可以使用由wireshark -D 报告的数字。如果没有指定接口,则Wireshark查找接口列表,如果有非环回接口,则选择第一个非环回接口,如果没有非环回接口,则选择第一个环回接口; 如果没有接口,Wireshark 会报错,不开始抓包。 管道名称应该是 FIFO(命名管道)的名称或“-”以从标准输入读取数据。 从管道读取的数据必须是标准的 libpcap 格式。

wireshark -i 2 
wireshark -interface 2   // 将捕获接口指定为 2

-f [capture filter]

 此选项设置捕获数据包时要使用的初始捕获过滤器表达式。

-s [snaplen], --snapshot-length [snaplen]

 此选项指定捕获数据包时要使用的快照长度。 Wireshark 只会为每个数据包捕获 snaplen 字节的数据。

-p, --no-promiscuous-mode

 不要将界面置于混杂模式。 请注意,由于某些其他原因,接口可能处于混杂模式。 因此,-p 不能用于确保捕获的唯一流量是发送到或来自运行 Wireshark 的机器的流量、广播流量和多播流量到该机器接收的地址。

-k

 -k 选项指定 Wireshark 应立即开始捕获数据包。 此选项需要使用 -i 参数来指定将发生数据包捕获的接口。

wireshark -k -i 2 // 立即捕获接口编号为2的数据

-S

 此选项指定 Wireshark 将在捕获数据包时显示它们。 这是通过在一个进程中捕获并在单独的进程中显示它们来完成的。 这与“捕获选项”对话框中的“实时更新数据包列表”相同。

-l

 如果数据包列表窗格在捕获期间到达时自动更新数据包列表窗格(由 -S 标志指定),则此选项打开自动滚动。

-I, --monitor-mode

 如果可用,在监控模式下捕获无线数据包。

-B [buffer size], --buffer-size [buffer size

 设置捕获缓冲区大小(以 MB 为单位,默认为 2MB)。 捕获驱动程序使用它来缓冲数据包数据,直到该数据可以写入磁盘。 如果在捕获时遇到数据包丢失,尝试增加此大小。

-y [link type], --linktype [link type]

 如果使用 -k 从命令行开始捕获,请设置捕获数据包时要使用的数据链接类型。 -L 报告的值是可以使用的值。

–time-stamp-type

 如果使用 -k 从命令行开始捕获,请设置捕获数据包时要使用的时间戳类型。 --list-time-stamp-types 报告的值是可以使用的值。

-D, --list-interfaces

 打印 Wireshark 可以捕获的接口列表,然后退出。 对于每个网络接口,会打印一个编号和一个接口名称,可能后跟该接口的文本描述。 可以将接口名称或编号提供给 -i 标志以指定要在其上捕获的接口。这对于没有列出它们的命令的系统很有用。 该数字在 Windows 上特别有用,其中接口名称是 GUID。 “可以捕获”意味着 Wireshark 能够打开该设备进行实时捕获。 如果在您的系统上,执行网络捕获的程序必须从具有特殊权限的帐户运行,那么,如果 Wireshark 使用 -D 标志运行并且不是从此类帐户运行,则它不会列出任何接口。

-L, --list-data-link-types

 列出接口支持的数据链路类型并退出。

–list-time-stamp-types

 列出接口可配置的时间戳类型并退出。

RPCAP

-A <user>:<password>     use RPCAP password authentication

-A [user]:[password]

 使用 RPCAP 密码认证

文件输入

  -r <infile>, --read-file <infile>

-r [infile], --read-file [infile]

 此选项为 Wireshark 提供要读取和显示的捕获文件的名称。 此捕获文件可以采用 Wireshark 理解的格式之一。

进程

 -R <read filter>, --read-filter <read filter>
                           packet filter in Wireshark display filter syntax
  -n                       disable all name resolutions (def: all enabled)
  -N <name resolve flags>  enable specific name resolution(s): "mnNtdv"
  -d <layer_type>==<selector>,<decode_as_protocol> ...
                           "Decode As", see the man page for details
                           Example: tcp.port==8888,http
  --enable-protocol <proto_name>
                           enable dissection of proto_name
  --disable-protocol <proto_name>
                           disable dissection of proto_name
  --enable-heuristic <short_name>
                           enable dissection of heuristic protocol
  --disable-heuristic <short_name>
                           disable dissection of heuristic protocol

-R [read filter], --read-filter [read filter]

 此选项指定从捕获文件读取数据包时要应用的显示过滤器。 此过滤器的语法是在查看时过滤数据包中讨论的显示过滤器的语法。 与过滤器不匹配的数据包将被丢弃。

-n

 禁用网络对象名称解析(例如主机名、TCP 和 UDP 端口名称)。

-N [name resolve flags]

 为特定类型的地址和端口号打开名称解析。 参数是一个字符串,可能包含以下字母:
  1. N: 使用外部名称解析器。
  2. d: 从捕获的 DNS 数据包启用名称解析。
  3. m: 启用 MAC 地址解析。
  4. n: 启用网络地址解析。
  5. t: 启用传输层端口号解析。
  6. v: 启用 VLAN ID 解析。

-d [layer_type]==[selector],[decode_as_protocol] …

–enable-protocol <proto_name>

 启用协议的解剖。

–disable-protocol <proto_name>

 启用和禁用协议的解剖。

–enable-heuristic <short_name>

 启用启发式协议的剖析。

–disable-heuristic <short_name>

 禁用启发式协议的剖析。

用户界面

  -C <config profile>      start with specified configuration profile
  -H                       hide the capture info dialog during packet capture
  -Y <display filter>, --display-filter <display filter>
                           start with the given display filter
  -g <packet number>       go to specified packet number after "-r"
  -J <jump filter>         jump to the first packet matching the (display)
                           filter
  -j                       search backwards for a matching packet after "-J"
  -t a|ad|adoy|d|dd|e|r|u|ud|udoy
                           format of time stamps (def: r: rel. to first)
  -u s|hms                 output format of seconds (def: s: seconds)
  -X <key>:<value>         eXtension options, see man page for details
  -z <statistics>          show various statistics, see man page for details

-C [config profile]

 从指定的配置文件开始。

-H

 在实时数据包捕获期间隐藏捕获信息对话框。

-Y [display filter], --display-filter [display filter]

 从给定的显示过滤器开始。

-g [packet number]

 使用 -r 标志读入捕获文件后,转到给定的数据包编号。

-J [jump filter]

 使用 -r 标志读入捕获文件后,跳转到与过滤器表达式匹配的第一个数据包。 过滤器表达式采用显示过滤器格式。 如果无法找到精确匹配,则选择之后的第一个数据包。

-j

 在 -J 选项之后使用此选项可向后搜索要转到的第一个数据包。

-t [time stamp format]

 此选项设置在数据包列表窗口中显示的数据包时间戳的格式。格式可以是以下之一:
  1. r: 相对,它指定相对于捕获的第一个数据包显示时间戳。
  2. a: 绝对,指定显示所有数据包的实际时间。
  3. ad: 绝对日期,指定显示所有数据包的实际日期和时间。
  4. adoy: 带有的绝对 YYYY/DOY 日期,它指定所有显示的实际日期和时间数据包。
  5. d: Delta,它指定时间戳是相对于前一个数据包的。
  6. dd: Delta,指定时间戳是相对于之前显示的数据包而言的。
  7. e: Epoch,它指定时间戳是自纪元(1970 年 1 月 1 日 00:00:00)以来的秒数。
  8. u: Absolute,指定以 UTC 格式显示所有数据包的实际时间。
  9. ud: 带日期的绝对值,指定以 UTC 格式显示所有数据包的实际日期和时间。
  10. udoy: 带有 YYYY/DOY 日期的 Absolute,它指定所有显示的实际日期和时间
UTC 中的数据包。

-u s|hms

 将时间显示为秒(“s”,默认值)或小时、分钟和秒(“hms”)。

-X [key]:[value]

 指定要传递给 Wireshark/Tshark 模块的选项。 eXtension 选项的格式为 extension_key:value,其中 extension_key 可以是:
  **1. lua_script:[lua_script_filename] ** 除了默认的 Lua 脚本外,还告诉 Wireshark 加载给定的脚本。
  **2. lua_script[num]:argument ** 告诉 Wireshark 将给定的参数传递给由 num 标识的 lua 脚本,这是 lua_script 命令的编号索引顺序。
  **3. read_format:[file_type] ** 告诉 Wireshark 使用特定的输入文件类型,而不是自动确定它。
  **4. stdin_descr:[description] ** 定义标准输入接口的描述,而不是默认值(标准输入)。

-z [statistics]

 获取 Wireshark 收集各种类型的统计信息,并将结果显示在半实时更新的窗口中。

输出

  -w <outfile|->           set the output filename (or '-' for stdout)
  --capture-comment <comment>
                           set the capture file comment, if supported

-w [outfile|-]

 此选项设置用于保存捕获的数据包的文件的名称。 对于标准输出,这可以是“-”。

其他

  -h, --help               display this help and exit
  -v, --version            display version info and exit
  -P <key>:<path>          persconf:path - personal configuration files
                           persdata:path - personal data files
  -o <name>:<value> ...    override preference or recent setting
  -K <keytab>              keytab file to use for kerberos decryption
  --fullscreen             start Wireshark in full screen

-h, --help

 此选项要求 Wireshark 打印其版本和使用说明并退出。

-v, --version

 此选项要求 Wireshark 打印出其版本信息并退出。

-P [key]:[path]

 特殊路径设置通常会自动检测。 这用于特殊情况,例如 从 U 盘上的已知位置启动 Wireshark。 标准的格式为 key:path,其中 key 是以下之一:
  **1. persconf:path ** 个人配置文件的路径,如首选项文件。
  **2. persdata:path ** 个人数据文件的路径,是最初打开的文件夹。 初始化后,最近的文件将保留上次使用的文件夹。

-o [name]:[value]

 设置首选项或最近的值,覆盖默认值和从首选项或最近的文件中读取的任何值。 标志的参数是一个格式为 prefname:value 的字符串,其中 prefname 是首选项的名称(与首选项或最近的文件中出现的名称相同),而 value 是它应该成为的值 放。 -o <preference settings> 的多个实例可以在单个命令行上给出。 设置单个首选项的示例是:

wireshark -o mgcp.display_dissect_tree:TRUE

 设置多个首选项的示例是:

wireshark -o mgcp.display_dissect_tree:TRUE -o mgcp.udp.callagent_port:2627

-K [keytab]

 -k 选项指定 Wireshark 应立即开始捕获数据包。 此选项需要使用 -i 参数来指定将发生数据包捕获的接口。

–fullscreen

 全屏启动 Wireshark

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小趴菜_自动驾驶搬砖人

谢谢大爷赏饭吃

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值