Created
May 8, 2023 19:10
-
-
Save tonusoo/3bb152e02ff03fffbcab6b7c3b8f9aab to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import multiprocessing | |
| from datetime import datetime | |
| from scapy.all import sniff, send, IP | |
| from scapy.contrib.igmp import IGMP | |
| def sniffer(): | |
| sniff(iface="ens3", filter="dst 239.3.5.3 and igmp", store=0, count=1) | |
| def handler(_pkt): | |
| p = multiprocessing.Process(target=sniffer) | |
| p.start() | |
| p.join(10) | |
| if p.is_alive(): | |
| print(f"{datetime.now().strftime('%H:%M:%S.%f')} - Timeout. Sending " | |
| "IGMPv2 Membership Report to 239.3.5.1") | |
| send(IP(src='192.168.0.50', dst='239.3.5.1')/IGMP(type=0x16, | |
| gaddr='239.3.5.1'), iface='ens3', verbose=0) | |
| p.terminate() | |
| p.join() | |
| sniff(iface="ens3", filter="dst 224.0.0.1 and igmp", prn=handler, store=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment