【问题标题】:Force TCPDump to write in PCAP instead of PCAP-NG format强制 TCPDump 以 PCAP 而非 PCAP-NG 格式写入
【发布时间】:2014-03-11 01:17:42
【问题描述】:

我在 Mac OS 上运行 tcpdump,我注意到它以 PCAP-NG 格式保存文件(前 4 个字节是 0A 0D 0D 0A)。有没有办法强制它使用旧的 PCAP?

软件版本:

tcpdump version 4.3.0 -- Apple version 56
libpcap version 1.3.0 - Apple version 41

ps。 我不确定这是否与 TCPDump 或 libpcap 有关。

【问题讨论】:

  • 当我在 10.9.2 虚拟机上执行 tcpdump -w /tmp/test.pcaptcpdump -i en0 /tmp/test.pcap 时,它会写入 pcap 文件。你在什么界面上抓拍的?
  • 天才!我没有选择接口。实际上,它为这种情况选择了不同的格式是有道理的。您能否将您的评论推广为答案?
  • 我的评论实际上可能是测试 tcpdump.org 的 tcpdump 而不是 OS X 的 tcpdump 的结果;我将发布一个单独的答案。

标签: libpcap tcpdump


【解决方案1】:

Mavericks 上的 tcpdump 手册页说:

   -i     Listen on interface.

          If  the  -D flag is supported, an interface number as printed by
          that flag can be used as the interface argument.

          On Darwin systems version 13 or later,  when  the  interface  is
          unspecified,  tcpdump  will  use  a  pseudo interface to capture
          packets  on  a  set  of  interfaces  determined  by  the  kernel
          (excludes by default loopback and tunnel interfaces).

          Alternatively,  to capture on more than one interface at a time,
          one may use "pktap" as the interface parameter  followed  by  an
          optional  list  of  comma  separated interface names to include.
          For example, to capture on the loopback and en0 interface:

                 tcpdump -i pktap,lo0,en0

          An interface argument of "all" or "pktap,all"  can  be  used  to
          capture packets from all interfaces, including loopback and tun-
          nel interfaces.

          A pktap pseudo interface provides for packet metadata using  the
          default  PKTAP data link type and files are written in the Pcap-
          ng file format.  The RAW data link type must be used to force to
          use  the legacy pcap-savefile(5) file format with a ptkap pseudo
          interface.  Note that captures on a ptkap pseudo interface  will
          not be done in promiscuous mode.

          An  interface argument of "iptap" can be used to capture packets
          from at the IP layer.  This capture packets as they  are  passed
          to  the  input and output routines of the IPv4 and IPv6 protocol
          handlers of the networking stack.  Note that captures  will  not
          be done in promiscuous mode.

所以你需要指定一个要捕获的接口。

请注意,可追溯到 Lion 的 OS X 版本、较新版本的 FreeBSD/NetBSD/DragonFly BSD 以及许多 Linux 发行版的较新版本都包含 libpcap 1.1.1 或更高版本,这意味着使用 libpcap 读取捕获文件的程序可以阅读许多 pcap-ng 文件。 Wireshark 还能够在多个版本中读取它们。

【讨论】:

    【解决方案2】:

    还有一个应用程序 CocoaPacketAnalyzer,它读取 pcap 文件,但 不是 pcap-NG 文件。有一个网页,https://pcapng.com,它将一个小的 pcap-NG 文件转换为旧格式。但是,如果您正在捕获密码或 Web 服务器交互,或者通常关心安全性,请注意在 Internet 上发布数据包捕获!

    【讨论】:

      猜你喜欢
      • 2013-08-02
      • 2019-06-28
      • 2013-09-06
      • 2013-08-05
      • 2016-02-17
      • 1970-01-01
      • 2014-07-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多