Scapy Sniffing with Custom Actions, Part 1

Scapy has a sniff function that is great for getting packets off the wire, but there’s much more to show off how great this function really is! sniff has  an argument prn that allows you to pass a function that executes with each packet sniffed. The intended purpose of this function is to control how the packet prints out in the console allowing you to replace the default packet printing display with a format of your choice.

The prn argument is defined as:

prn: function to apply to each packet. If something is returned, it is displayed. For instance you can use prn = lambda x: x.summary().

Continue reading