New issue 81 by rrpo...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81
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 <module>
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
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.