Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code:
- ## Import Scapy module
- from scapy.all import *
- ## Create a Packet Count var
- packetCount = 0
- ## Define our Custom Action function
- def customAction(packet):
- global packetCount
- packetCount += 1
- return "Packet #%s: %s ==> %s" % (packetCount, packet[0][1].src, packet[0][1].dst)
- ## Setup sniff, filtering for IP traffic
- sniff(10, filter="ip",prn=customAction)
- Output:
- felix@felix-VirtualBox:~/share$ sudo python random.py
- WARNING: No route found for IPv6 destination :: (no default route?)
- Packet #1: 192.168.178.51 ==> 192.168.178.255
- Packet #2: 192.168.178.1 ==> 192.168.178.255
- Packet #3: 192.168.178.1 ==> 192.168.178.255
- Packet #4: 192.168.178.1 ==> 224.0.0.1
- Packet #5: 192.168.178.91 ==> 224.0.0.22
- Packet #6: 192.168.178.91 ==> 224.0.0.22
- Packet #7: 192.168.178.106 ==> 224.0.0.22
- Packet #8: 192.168.178.91 ==> 192.168.178.255
- Packet #9: 192.168.178.21 ==> 255.255.255.255
- Packet #10: 192.168.178.21 ==> 192.168.178.255
- Traceback (most recent call last):
- File "random.py", line 2, in <module>
- from scapy.all import *
- File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 10, in <module>
- from base_classes import *
- File "/usr/local/lib/python2.7/dist-packages/scapy/base_classes.py", line 14, in <module>
- import re,random,socket
- File "/home/felix/share/random.py", line 11, in <module>
- sniff(10, filter="ip",prn=customAction)
- NameError: name 'sniff' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement