37 lines
979 B
Python
37 lines
979 B
Python
import socket
|
|
import time
|
|
|
|
TARGET_SUBNETS = ["202.114.4.255", "255.255.255.255"]
|
|
PORTS = [511, 1000, 2000, 5000, 8000, 8300, 9000, 10008, 12345]
|
|
|
|
# Common Contec discovery payloads
|
|
PAYLOADS = [
|
|
b"CMS",
|
|
b"CMS_SEARCH",
|
|
b"CMS_REGISTER",
|
|
b"CMS_HEARTBEAT",
|
|
b"\x55\xaa\x01\x00\x01", # sync header + command
|
|
b"\xaa\x55\x01\x00\x01",
|
|
b"\x00\x00\x00\x00",
|
|
b"\x01"
|
|
]
|
|
|
|
print("Sending UDP discovery heartbeats to trigger the monitor...")
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
|
|
|
for subnet in TARGET_SUBNETS:
|
|
for port in PORTS:
|
|
for payload in PAYLOADS:
|
|
try:
|
|
# Send broadcast packet
|
|
s.sendto(payload, (subnet, port))
|
|
print(f"Sent {len(payload)} bytes to {subnet}:{port}")
|
|
except Exception as e:
|
|
pass
|
|
time.sleep(0.01)
|
|
|
|
s.close()
|
|
print("Discovery heartbeats sent successfully.")
|