import paramiko import sys sys.stdout.reconfigure(encoding='utf-8') key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet' c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("140.44.4.71", username="root", key_filename=key_path, timeout=10) py_script = """ import sqlite3 conn = sqlite3.connect('/var/lib/docker/volumes/gotify_gotify_data/_data/gotify.db') cur = conn.cursor() cur.execute("SELECT id FROM applications WHERE token = 'A9oPeNcAnArYhOnEyPoT'") if not cur.fetchone(): cur.execute('''INSERT INTO applications (id, token, user_id, name, description, internal, default_priority) VALUES (6, 'A9oPeNcAnArYhOnEyPoT', 1, 'OpenCanary Honeypot', 'OpenCanary decoy honeypot probes and unauthorized access detections', 0, 8)''') conn.commit() print('Inserted OpenCanary app (ID 6)') else: print('OpenCanary app already exists') cur.execute("SELECT id, token, name, description FROM applications WHERE id = 6") print(cur.fetchall()) conn.close() """ c.exec_command("cat << 'EOF' > /tmp/setup_oc_gotify.py\n" + py_script + "\nEOF\n") stdin, stdout, stderr = c.exec_command("python3 /tmp/setup_oc_gotify.py") print(stdout.read().decode()) # Test sending a message to Gotify with this token print("\nTesting Gotify message dispatch with new token:") stdin, stdout, stderr = c.exec_command(""" curl -s -X POST "http://127.0.0.1:8090/message?token=A9oPeNcAnArYhOnEyPoT" \ -H "Content-Type: application/json" \ -d '{"title": "OpenCanary Initialized", "message": "Honeypot monitoring armed on VLAN 50 decoy IP 14.4.4.99", "priority": 5}' """) print(stdout.read().decode()) c.close()