Advertisement
Guest User

Untitled

a guest
May 24th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. Code:
  2. ## Import Scapy module
  3. from scapy.all import *
  4. ## Create a Packet Count var
  5. packetCount = 0
  6. ## Define our Custom Action function
  7. def customAction(packet):
  8.     global packetCount
  9.     packetCount += 1
  10.     return "Packet #%s: %s ==> %s" % (packetCount, packet[0][1].src, packet[0][1].dst)
  11. ## Setup sniff, filtering for IP traffic
  12. sniff(10, filter="ip",prn=customAction)
  13.  
  14.  
  15.  
  16. Output:
  17. felix@felix-VirtualBox:~/share$ sudo python random.py
  18. WARNING: No route found for IPv6 destination :: (no default route?)
  19. Packet #1: 192.168.178.51 ==> 192.168.178.255
  20. Packet #2: 192.168.178.1 ==> 192.168.178.255
  21. Packet #3: 192.168.178.1 ==> 192.168.178.255
  22. Packet #4: 192.168.178.1 ==> 224.0.0.1
  23. Packet #5: 192.168.178.91 ==> 224.0.0.22
  24. Packet #6: 192.168.178.91 ==> 224.0.0.22
  25. Packet #7: 192.168.178.106 ==> 224.0.0.22
  26. Packet #8: 192.168.178.91 ==> 192.168.178.255
  27. Packet #9: 192.168.178.21 ==> 255.255.255.255
  28. Packet #10: 192.168.178.21 ==> 192.168.178.255
  29. Traceback (most recent call last):
  30.   File "random.py", line 2, in <module>
  31.     from scapy.all import *
  32.   File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in <module>
  33.     from base_classes import *
  34.   File "/usr/local/lib/python2.7/dist-packages/scapy/base_classes.py", line 14, in <module>
  35.     import re,random,socket
  36.   File "/home/felix/share/random.py", line 11, in <module>
  37.     sniff(10, filter="ip",prn=customAction)
  38. NameError: name 'sniff' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement