Created
July 13, 2023 22:03
-
-
Save linuxkidd/adf150adc25014d45d0629fb382ce7aa to your computer and use it in GitHub Desktop.
Python 3 SQM-LE Finder
This file contains 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/python | |
import socket, time, signal, sys | |
def signal_handler(signal, frame): | |
print('\nCtrl-C received from keyboard - script exiting') | |
sys.exit(0) | |
signal.signal(signal.SIGINT, signal_handler) | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.setblocking(False) | |
if hasattr(socket,'SO_BROADCAST'): | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
s.sendto(b'\x00\x00\x00\xf6', ("255.255.255.255", 30718)) | |
buf='' | |
starttime = time.time() | |
print("Looking for replies; press Ctrl-C to stop.") | |
while True: | |
try: | |
( buf, addr ) = s.recvfrom(30) | |
except: | |
#Timeout in seconds. Allow all devices time to respond | |
if time.time()-starttime > 3: | |
break | |
pass | |
else: | |
if buf[3]==0xF7: | |
print("Received from %s: MAC: %s" % (addr, ":".join("{0:02X}".format(x) for x in buf[24:30]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment