Sign in
Google apps
Main menu
Post a Comment On:
j4neiros
"Reading pcap files with Python"
No comments yet. -
1 – 0 of 0
#!/usr/bin/python
import sys
import pcapy
from impacket import ImpactDecoder, ImpactPacket
import re
def main(argv):
try:
cap = pcapy.open_offline(argv[1])
(header, payload) = cap.next()
while header:
(seconds, micros) = header.getts()
# Parse the Ethernet packet
decoder = ImpactDecoder.EthDecoder()
ether = decoder.decode(payload)
# Parse the IP packet inside the Ethernet packet
iphdr = ether.child()
# Parse the TCP packet inside the IP packet
tcphdr = iphdr.child()
# Get the source and destination IP addresses
src_ip = iphdr.get_ip_src()
dst_ip = iphdr.get_ip_dst()
if tcphdr.child() <> None:
body = tcphdr.child().get_packet()
isFIX = re.match('8=FIX', body)
if isFIX <> None:
print "%d.%06d %s" % (seconds, micros, body)
(header, payload) = cap.next()
except pcapy.PcapError:
pass
if __name__ == "__main__":
main(sys.argv)
posted by J. Ernesto Aneiros at
4:54 PM
on Jul 25, 2011
Leave your comment
You can use some HTML tags, such as
<b>, <i>, <a>
Choose an identity
Google Account
You will be asked to sign in after submitting your comment.
Name/URL
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Name
URL
Anonymous
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Please prove you're not a robot
"Reading pcap files with Python"
No comments yet. -