48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
import paramiko
|
|
import sys
|
|
import time
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
|
|
|
|
print("--- 1. Probing OpenCanary from Spaceport (140.44.4.41) ---")
|
|
sp = paramiko.SSHClient()
|
|
sp.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
sp.connect("140.44.4.41", username="root", key_filename=key_path, timeout=10)
|
|
|
|
def sp_run(cmd):
|
|
stdin, stdout, stderr = sp.exec_command(cmd)
|
|
return stdout.read().decode('utf-8', errors='ignore').strip()
|
|
|
|
# Probe 1: HTTP hit
|
|
print("HTTP probe:", sp_run("curl -s -i http://14.4.4.99/test-probe | head -n 5"))
|
|
|
|
# Probe 2: Telnet probe
|
|
print("Telnet probe:", sp_run("curl -s telnet://14.4.4.99:23 --max-time 2 2>&1 | head -n 3"))
|
|
|
|
# Probe 3: SSH probe with fake credentials
|
|
print("SSH probe:", sp_run("sshpass -p 'HoneypotSecret123!' ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 admin@14.4.4.99 2>&1 || echo 'SSH auth attempted'"))
|
|
|
|
sp.close()
|
|
|
|
time.sleep(2)
|
|
|
|
print("\n--- 2. Checking OpenCanary Log on 140.44.4.71 ---")
|
|
sw = paramiko.SSHClient()
|
|
sw.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
sw.connect("140.44.4.71", username="root", key_filename=key_path, timeout=10)
|
|
|
|
stdin, stdout, stderr = sw.exec_command("tail -n 5 /opt/opencanary/logs/opencanary.log")
|
|
print(stdout.read().decode('utf-8', errors='ignore'))
|
|
|
|
print("\n--- 3. Checking Watcher Journal Output ---")
|
|
stdin, stdout, stderr = sw.exec_command("journalctl -u opencanary-watcher.service -n 10 --no-pager")
|
|
print(stdout.read().decode('utf-8', errors='ignore'))
|
|
|
|
print("\n--- 4. Checking Messages in Gotify Database ---")
|
|
stdin, stdout, stderr = sw.exec_command("sqlite3 /var/lib/docker/volumes/gotify_gotify_data/_data/gotify.db 'SELECT id, appid, title, message, date FROM messages ORDER BY id DESC LIMIT 5;'")
|
|
print(stdout.read().decode('utf-8', errors='ignore'))
|
|
|
|
sw.close()
|
|
|