Skip to content

Instantly share code, notes, and snippets.

@Williangalvani
Last active October 2, 2019 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Williangalvani/1382c32b9e072113ba7a90ecce625954 to your computer and use it in GitHub Desktop.
Save Williangalvani/1382c32b9e072113ba7a90ecce625954 to your computer and use it in GitHub Desktop.
script to find
#!/usr/bin/env python3
"""
Scan with ./findPing360.py [current IP of the interface to scan]
"""
import socket
import time
import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('ip', type=str, help='IP address of the interface to discover')
args = parser.parse_args()
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# Set a timeout so the socket does not block
# indefinitely when trying to receive data.
server.settimeout(0.2)
server.bind((args.ip, 30303))
message = b"Discovery"
print("Looking for Ping360...")
while True:
server.sendto(message, ('255.255.255.255', 30303))
print("Discovery message sent...")
time.sleep(1)
try:
data, client = server.recvfrom(1048)
print("Got reply:")
print(data.decode("utf8"))
except socket.timeout as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment