Advertisement
Tevronis

pcapy

May 5th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import pcapy
  2. from impacket.ImpactDecoder import *
  3.  
  4. # list all the network devices
  5. pcapy.findalldevs()
  6.  
  7. max_bytes = 16384
  8. promiscuous = False
  9.  
  10. read_timeout = 100 # in milliseconds
  11. pc = pcapy.open_live("any", max_bytes,
  12.     promiscuous, read_timeout)
  13.  
  14. pc.setfilter('tcp')
  15.  
  16. # callback for received packets
  17. out_file = open('output.txt', 'w')
  18. def recv_pkts(hdr, data):
  19.     #try:
  20.         packet = EthDecoder().decode(data)
  21.         #print packet
  22.         out_file.write(str(packet))
  23.     #except:
  24.      #   pass
  25.  
  26. packet_limit = 1000 # infinite
  27. pc.loop(packet_limit, recv_pkts) # capture packets
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement