Files
SnarfCode/scripts/test_storage_isolation.py

37 lines
1.5 KiB
Python

import paramiko
import socket
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
def run_ssh_cmd(host, user, cmd, timeout=5):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(host, username=user, key_filename=SSH_KEY, timeout=timeout)
stdin, stdout, stderr = client.exec_command(cmd, timeout=timeout)
out = stdout.read().decode('utf-8', errors='replace')
err = stderr.read().decode('utf-8', errors='replace')
client.close()
return True, out, err
except Exception as e:
return False, "", str(e)
print("=== 1. Testing Storage Drop from Smart Home (14.4.4.44 -> 14.10.10.71:5001) ===")
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "nc -z -w 3 14.10.10.71 5001; echo ExitCode=$?")
print(f"Smart Home to NAS 1: {out.strip() or err.strip()}")
print("\n=== 2. Testing Storage Drop from Smart Home (14.4.4.44 -> 14.10.10.72:5001) ===")
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "nc -z -w 3 14.10.10.72 5001; echo ExitCode=$?")
print(f"Smart Home to NAS 2: {out.strip() or err.strip()}")
print("\n=== 3. Testing Storage Access from LAN (Workstation 14.44.4.108 -> 14.10.10.71:5001) ===")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(3)
try:
s.connect(("14.10.10.71", 5001))
print("Workstation to NAS 1: SUCCESS (Port 5001 open)")
s.close()
except Exception as e:
print(f"Workstation to NAS 1: FAILED ({e})")