48 lines
2.4 KiB
Python
48 lines
2.4 KiB
Python
import paramiko
|
|
import time
|
|
import socket
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
|
|
def run_ssh_cmd(host, user, cmd, timeout=10):
|
|
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 from nutserver (14.4.4.44, VLAN 50 Smart Home) ===")
|
|
|
|
# Test DNS resolution to Aerodrome VIP (140.44.4.36)
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "dig @140.44.4.36 snarfhome.snarfnet.net +short +time=2 +tries=1")
|
|
print(f"DNS query to 140.44.4.36: {'SUCCESS: ' + out.strip() if ok and out.strip() else 'FAILED: ' + err}")
|
|
|
|
# Test DNS resolution to Spaceport VIP (140.44.4.65)
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "dig @140.44.4.65 snarfhome.snarfnet.net +short +time=2 +tries=1")
|
|
print(f"DNS query to 140.44.4.65: {'SUCCESS: ' + out.strip() if ok and out.strip() else 'FAILED: ' + err}")
|
|
|
|
# Test NTP connectivity to Aerodrome Master (140.44.4.11)
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "chronyc sources -v 2>&1")
|
|
print(f"NTP query to 140.44.4.11:\n{out.strip()[:300]}")
|
|
|
|
# Test BLOCKING: nutserver (VLAN 50) -> Compute (140.44.4.11:22)
|
|
print("\n=== 2. Testing Firewall Drop: Smart Home (14.4.4.44) -> Compute (140.44.4.11:22) ===")
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "nc -z -w 3 140.44.4.11 22; echo ExitCode=$?")
|
|
print(f"Connection test 140.44.4.11:22: {out.strip() or err.strip()}")
|
|
|
|
# Test BLOCKING: nutserver (VLAN 50) -> Compute (140.44.4.71:22)
|
|
print("=== 3. Testing Firewall Drop: Smart Home (14.4.4.44) -> Compute (140.44.4.71:22) ===")
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "nc -z -w 3 140.44.4.71 22; echo ExitCode=$?")
|
|
print(f"Connection test 140.44.4.71:22: {out.strip() or err.strip()}")
|
|
|
|
# Test ALLOW: nutserver (VLAN 50) -> OpenCanary Honeypot (14.4.4.99:22) (Intra-VLAN 50)
|
|
print("\n=== 4. Testing Honeypot reachable from Smart Home: 14.4.4.44 -> 14.4.4.99:22 ===")
|
|
ok, out, err = run_ssh_cmd("14.4.4.44", "root", "nc -z -w 3 14.4.4.99 22; echo ExitCode=$?")
|
|
print(f"Honeypot reachability test: {out.strip() or err.strip()}")
|