32 lines
916 B
Python
32 lines
916 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('140.44.4.71', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
script = '''
|
|
import sqlite3
|
|
|
|
con = sqlite3.connect('/mnt/nfs_shares/heimdall/www/app.sqlite')
|
|
cur = con.cursor()
|
|
print("=== USERS ===")
|
|
for u in cur.execute("SELECT * FROM users").fetchall():
|
|
print(u)
|
|
|
|
print("\\n=== ITEMS (Total %d) ===" % cur.execute("SELECT count(*) FROM items").fetchone()[0])
|
|
for r in cur.execute("SELECT id, user_id, title, url, pinned, [order], deleted_at FROM items ORDER BY id").fetchall():
|
|
print(r)
|
|
'''
|
|
|
|
sftp = c.open_sftp()
|
|
with sftp.file('/tmp/inspect_heimdall.py', 'w') as f:
|
|
f.write(script)
|
|
sftp.close()
|
|
|
|
_, stdout, _ = c.exec_command('python3 /tmp/inspect_heimdall.py')
|
|
print(stdout.read().decode())
|
|
c.close()
|
|
|