from scapy.all import *

def packet_has_modbus_layer(packet):
    # Check if the packet has the TCP layer and destination port is 502
    if TCP in packet and packet[TCP].dport == 502:
        # Check if the packet has the Modbus layer
        if packet.haslayer(TCP):
            return True
    return False

def network_sniffing_local_storage(pkt):
   if(packet_has_modbus_layer(pkt)):
      print("yes")

sniff(prn=network_sniffing_local_storage)