![]() Key = tuple ( sorted (.src, packet.dst])) # Create tuple of Src/Dst in sorted order This script keeps a Counter with an A/Z pair of IP addresses, displays the total packet count with each packet print(), and then prints out the conversation counts at the end. Here's a simple example for keeping track of the number of packets sniffed This can be anything from incrementing a packet count somewhere in the program, to doing some advanced packet parsing or manipulation, or even shipping that packet off into some sort of storage (.pcap appending or API POSTing anyone?). ![]() ![]() This gives us the option to do some fun stuff (not just formatting) with each packet sniffed □įor example, we can now perform custom actions with each sniffed packet. In order for your program/script to format and return the packet info as you wish, the sniff function passes the packet object as the one and only argument into the function you specify in the sniff's prn argument. For instance you can use prn = lambda x: x.summary(). If something is returned, it is displayed. 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. ![]() 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |