Python-分析Pcap文件并提取中断的连接

时间:2019-06-11 08:08:20

标签: python pcap

我正在尝试执行以下步骤:

  1. 读取pcap文件
  2. 分析数据包并显示未正确设置的连接

是否可以提取这样的信息?

我编写了Python类来提取Packet Header,Packet的Ethernet,Packet IP,Packet TCP信息。我需要可以提取这样的信息的指导吗? hva_pcao.pyhva_pckt

    rdr = pcap.open_offline('xsupport.pcap')
i = 0
for hdr, data in rdr:
    if i ==2:

        print(hdr)
        eth = Eth.decode(data)
        if eth is None: continue
        print(str(eth))
        ip = Ip.decode(eth.pl)
        if ip is None: continue
        print(str(ip))
        tcp = Tcp.decode(ip.pl)
        if tcp is None: continue
        print(str(tcp))
        print((repr(tcp.flags) + " - " + repr(tcp.kFlags_FIN) + " * " + repr(tcp.kFlags_ACK)))
        # break

我的预期输出是:分析数据包并显示未正确设置的连接

0 个答案:

没有答案