33 lines
1006 B
Python
33 lines
1006 B
Python
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.75", username="root", key_filename=key_path, timeout=10)
|
|
|
|
py_code = """
|
|
import sqlite3, glob
|
|
db_files = glob.glob('/var/lib/docker/volumes/*heimdall*/_data/www/app.sqlite')
|
|
if not db_files:
|
|
print('No db found on host, searching...')
|
|
db_files = glob.glob('/var/lib/docker/volumes/**/app.sqlite', recursive=True)
|
|
print('Found:', db_files)
|
|
if db_files:
|
|
conn = sqlite3.connect(db_files[0])
|
|
cur = conn.cursor()
|
|
cur.execute('SELECT id, title, url, config FROM items')
|
|
for row in cur.fetchall():
|
|
if any(w in row[1].lower() for w in ['home', 'assist', 'snarf']):
|
|
print(row)
|
|
"""
|
|
stdin, stdout, stderr = c.exec_command(f'python3 -c "{py_code}"')
|
|
print(stdout.read().decode())
|
|
err = stderr.read().decode()
|
|
if err: print("Stderr:", err)
|
|
|
|
c.close()
|
|
|