47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.71", username="snarf", password="Katzir476!", timeout=10)
|
|
|
|
py_code = '''
|
|
import sqlite3
|
|
import shutil
|
|
import time
|
|
|
|
db_path = '/var/lib/docker-data/heimdall/config/www/app.sqlite'
|
|
backup_name = db_path + '.backup_live_' + str(int(time.time()))
|
|
shutil.copyfile(db_path, backup_name)
|
|
print('Backup created:', backup_name)
|
|
|
|
con = sqlite3.connect(db_path)
|
|
cur = con.cursor()
|
|
|
|
print('=== USERS ===')
|
|
for r in cur.execute('SELECT * FROM users').fetchall():
|
|
print('User:', r)
|
|
|
|
print('\\n=== ITEMS ===')
|
|
rows = cur.execute('SELECT id, title, url, pinned, user_id, apporder FROM items').fetchall()
|
|
print('Total items in DB:', len(rows))
|
|
for r in rows:
|
|
print('Item:', r)
|
|
|
|
print('\\n=== SETTINGS ===')
|
|
for r in cur.execute('SELECT * FROM settings').fetchall():
|
|
print('Setting:', r)
|
|
'''
|
|
|
|
stdin, stdout, stderr = c.exec_command("cat > /tmp/inspect_heimdall_real.py")
|
|
stdin.write(py_code)
|
|
stdin.close()
|
|
stdout.channel.recv_exit_status()
|
|
|
|
_, o, e = c.exec_command("echo Katzir476! | sudo -S python3 /tmp/inspect_heimdall_real.py")
|
|
print(o.read().decode())
|
|
if e.read().decode():
|
|
print("ERR:", e.read().decode())
|
|
|
|
c.close()
|
|
|