使用pyshark筛选并选择第一个GET数据包

使用pyshark筛选并选择第一个GET数据包,pyshark,Pyshark,我正在使用pyshark筛选保存的pcap文件。 我使用的过滤器是: http.request.method == GET && !ip.ttl==180 && ip.src==100.100.19.42 (最后有一个链接,指向使用此过滤器后pcap文件的屏幕截图。) 我的问题是,如何获取并打印get数据包的HTTP层内容(如屏幕截图所示,位于第二行) 使用python代码。 有没有办法搜索第一个GET数据包并找到它?您可以使用scapy from scapy.

我正在使用pyshark筛选保存的pcap文件。 我使用的过滤器是:

http.request.method == GET && !ip.ttl==180 && ip.src==100.100.19.42
(最后有一个链接,指向使用此过滤器后pcap文件的屏幕截图。) 我的问题是,如何获取并打印get数据包的HTTP层内容(如屏幕截图所示,位于第二行) 使用python代码。
有没有办法搜索第一个GET数据包并找到它?

您可以使用scapy

from scapy.all import *
packets = rdpcap('your_capture.pcap')
for packet in packets:
    if packet['IP'].ttl != 180 and packet['IP'].src == '100.100.19.42':
        try:
            if 'GET' in packet['Raw'].load:
                print 'GET:',packet['Raw'].load
                return packet
        except:
            pass

任何人在这方面我真的需要帮助。。。