Advertisement
rfmonk

dpkt_parse.py

Nov 30th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. import dpkt
  4. import socket
  5. def printPcap(pcap):
  6.     for (ts, buf) in pcap:
  7.         try:
  8.             eth = dpkt.ethernet.Ethernet(buf)
  9.             ip = eth.data
  10.             src = socket.inet_ntoa(ip.src)
  11.             dst = socket.inet_ntoa(ip.dst)
  12.             print '[+] Src: ' + src + ' --> Dst: ' + dst
  13.         except:
  14.             pass
  15. def main():
  16.     f = open('geotest.pcap')
  17.     pcap = dpkt.pcap.Reader(f)
  18.     printPcap(pcap)
  19. if __name__ == '__main__':
  20.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement