How to make packet listener tool using Python.

After being man-in-the-middle using solution from previous section it's time to build and use packet listener tool with Python, but don't forget to use it for ethical purpose like network administration and network security.
This solution itself is ready to use for HTTP sites, HTTPS sites has to be downgraded to HTTP using common tools, but this is another story that will not be covered here.
Below is a Python3 realisation of packet listener which can be executed from this command line:# python3

import scapy.all as scapy
from scapy_http import http

def listen_packets(interface):

    #prn = callback function

def analyze_packets(packet):
    if packet.haslayer(http.HTTPRequest):
        if packet.haslayer(scapy.Raw):


See also related topics: