【问题标题】:Associating HTTP Requests with Responses in large packet capture将 HTTP 请求与大型数据包捕获中的响应相关联
【发布时间】:2012-07-10 13:02:53
【问题描述】:

我正在尝试处理以 pdml 格式输出的来自 wireshark 的大型数据包捕获。然后使用 lxml 库将这些捕获加载到 python 中以遍历它们。我遇到的问题是我可以提取有关单个 HTTP 响应数据包的信息,然后我需要一种方法将其与它的 HTTP 请求数据包相关联。

我正在考虑实施的当前解决方案是搜索作为响应的同一 TCP 流的一部分的 HTTP 请求数据包,但这似乎是解决问题的低效解决方案,必须不断分离出 TCP 流和然后在它们中搜索请求包。

有没有一种简单的方法可以将响应数据包与我丢失的请求关联起来?

【问题讨论】:

    标签: python http capture packet wireshark


    【解决方案1】:

    到目前为止,我想出的最佳解决方案是在每个 TCP 连接仅包含一个请求/响应对的假设下使用 xpath。

    #Get the stream index from the packet
    streamIndex = packet.xpath('proto/field[@name="tcp.stream"]')[0].attrib['show']
    #Use that stream index to get the matching response packet
    return packet.xpath('/pdml/packet[proto/field[@name="tcp.stream" and @show="' + streamIndex + '"] and proto/field[@name="http.request.full_uri"]]')[0]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-08
      • 2018-02-19
      • 1970-01-01
      • 2017-11-04
      • 2018-12-10
      • 2021-07-08
      相关资源
      最近更新 更多