Last active
December 24, 2015 22:59
-
-
Save thepacketgeek/6876520 to your computer and use it in GitHub Desktop.
Run a custom function on every packet sniffed with scapy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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(filter="ip",prn=customAction) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment