Implement patient vital signs monitoring system with Contec CMS7000PLUS integration and real-time dashboard
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import psutil
|
||||
import time
|
||||
|
||||
print("Monitoring TCP connections for traffic from 202.114.4.114 for 15 seconds...")
|
||||
monitor_ip = "202.114.4.114"
|
||||
start = time.time()
|
||||
found_any = False
|
||||
|
||||
while time.time() - start < 15:
|
||||
connections = psutil.net_connections(kind='tcp')
|
||||
for conn in connections:
|
||||
# Check if remote address matches the monitor IP
|
||||
if conn.raddr and conn.raddr.ip == monitor_ip:
|
||||
print(f"Connection detected: Local={conn.laddr.ip}:{conn.laddr.port}, Remote={conn.raddr.ip}:{conn.raddr.port}, Status={conn.status}")
|
||||
found_any = True
|
||||
time.sleep(0.5)
|
||||
|
||||
if not found_any:
|
||||
print("No TCP connections from 202.114.4.114 were detected during the 15-second window.")
|
||||
@@ -0,0 +1,50 @@
|
||||
import socket
|
||||
import sys
|
||||
|
||||
TARGET_IP = "202.114.4.114"
|
||||
COMMON_PORTS = [
|
||||
511, 515, 516, 517, 518, 519, 520, 1000, 2000, 3000, 4000, 5000,
|
||||
6060, 7000, 8000, 8001, 8002, 8080, 8300, 9000, 9100, 9200, 9500, 10008
|
||||
]
|
||||
|
||||
print(f"Scanning target monitor {TARGET_IP} for open TCP ports...")
|
||||
|
||||
open_ports = []
|
||||
|
||||
for port in COMMON_PORTS:
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(0.5)
|
||||
result = s.connect_ex((TARGET_IP, port))
|
||||
if result == 0:
|
||||
print(f" [OPEN] Port {port} is open!")
|
||||
open_ports.append(port)
|
||||
s.close()
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
# Also do a quick scan of port range 500-600 (very common for Contec)
|
||||
print("Scanning port range 500-600...")
|
||||
for port in range(500, 601):
|
||||
if port in COMMON_PORTS:
|
||||
continue
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(0.1)
|
||||
result = s.connect_ex((TARGET_IP, port))
|
||||
if result == 0:
|
||||
print(f" [OPEN] Port {port} is open!")
|
||||
open_ports.append(port)
|
||||
s.close()
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
print("\nScan complete.")
|
||||
if open_ports:
|
||||
print(f"Found open TCP ports on monitor: {open_ports}")
|
||||
else:
|
||||
print("No open TCP ports found on the monitor. It is not acting as a TCP server on these ports.")
|
||||
|
||||
with open("C:\\Users\\Dell\\.gemini\\antigravity-ide\\brain\\17f86d9d-29a1-4f54-b185-045db1a407b4\\scratch\\monitor_scan_results.txt", "w") as f:
|
||||
f.write(f"Monitor scan results for {TARGET_IP}:\n")
|
||||
f.write(f"Open ports: {open_ports}\n")
|
||||
@@ -0,0 +1,36 @@
|
||||
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.")
|
||||
@@ -0,0 +1,48 @@
|
||||
import socket
|
||||
import time
|
||||
|
||||
PORT_LIST = [511, 515, 516, 517, 518, 519, 520, 1000, 2000, 5000, 6060, 8000, 8300, 9000, 9200, 10008, 12345]
|
||||
TIMEOUT = 30.0 # seconds
|
||||
|
||||
print("Starting background UDP sniffer on ports:", PORT_LIST)
|
||||
print("Listening for 30 seconds...")
|
||||
|
||||
sockets = []
|
||||
for port in PORT_LIST:
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind(("0.0.0.0", port))
|
||||
s.setblocking(False)
|
||||
sockets.append((s, port))
|
||||
except Exception as e:
|
||||
print(f"Could not bind to UDP port {port}: {e}")
|
||||
|
||||
start_time = time.time()
|
||||
captured = []
|
||||
|
||||
while time.time() - start_time < TIMEOUT:
|
||||
for s, port in sockets:
|
||||
try:
|
||||
data, addr = s.recvfrom(4096)
|
||||
# Log from any sender that is not local loopback
|
||||
if addr[0] != "127.0.0.1":
|
||||
event = f"[UDP Port {port}] Received {len(data)} bytes from {addr[0]}:{addr[1]} - Hex: {data.hex()}"
|
||||
print(event)
|
||||
captured.append(event)
|
||||
except BlockingIOError:
|
||||
pass
|
||||
except Exception as e:
|
||||
pass
|
||||
time.sleep(0.01)
|
||||
|
||||
for s, port in sockets:
|
||||
s.close()
|
||||
|
||||
print("Finished UDP sniff.")
|
||||
with open("C:\\Users\\Dell\\.gemini\\antigravity-ide\\brain\\17f86d9d-29a1-4f54-b185-045db1a407b4\\scratch\\udp_sniff_now_results.txt", "w") as f:
|
||||
f.write("UDP Sniffing results:\n")
|
||||
if not captured:
|
||||
f.write("No UDP packets captured.\n")
|
||||
for event in captured:
|
||||
f.write(event + "\n")
|
||||
Reference in New Issue
Block a user