weixin_39602005 2020-11-22 03:36
浏览 0

PCAP paser error

From rrpo....com on November 03, 2011 13:12:57

What steps will reproduce the problem? 1. running pcap parser 2. #!/usr/bin/env python2

import dpkt # Framework for parsing packets, use python 2.6 import sys

try: file = open(sys.argv[1], 'rb') #print sys.argv[1] pcap = dpkt.pcap.Reader(file) #print pcap lines = 0 for ts, buf in pcap: #print pkts, len(buf) eth = dpkt.ethernet.Ethernet(buf) ip = eth.data tcp = ip.data lines = lines +1 print lines if tcp.dport == 80 and len(tcp.data) > 0: http = dpkt.http.Request(tcp.data) print http.uri


file.close()

except ValueError: print "Could not open file!" What is the expected output? What do you see instead? Traceback (most recent call last): File "pcapParser.py", line 17, in tcp = ip.data AttributeError: 'str' object has no attribute 'data' What version of the product are you using? On what operating system? 1.7 Please provide any additional information below. n/a

Original issue: http://code.google.com/p/dpkt/issues/detail?id=81

该提问来源于开源项目:kbandla/dpkt

  • 写回答

6条回答 默认 最新

  • weixin_39602005 2020-11-22 03:36
    关注

    From rrpo....com on November 03, 2011 12:26:19

    Ok, figures this one out. Now I'm just trying to print all known attributes of tcp or udp. It keeps failing because it finds a none IP based packet. I need a one liner that prints everything except arp.

    评论

报告相同问题?