33 lines
949 B
Python
33 lines
949 B
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 json
|
|
|
|
db = '/var/lib/docker/volumes/nginx-proxy-manager_data/_data/database.sqlite'
|
|
# Check if file exists there or where npm data is
|
|
import glob
|
|
files = glob.glob('/var/lib/docker/**/database.sqlite', recursive=True)
|
|
print('NPM DB files found:', files)
|
|
if files:
|
|
con = sqlite3.connect(files[0])
|
|
cur = con.cursor()
|
|
for row in cur.execute('SELECT id, domain_names, forward_host, forward_port FROM proxy_host WHERE id=4').fetchall():
|
|
print('Host 4:', row)
|
|
"""
|
|
|
|
stdin, stdout, stderr = c.exec_command("cat > /tmp/find_npm_db.py")
|
|
stdin.write(py_code)
|
|
stdin.close()
|
|
stdout.channel.recv_exit_status()
|
|
|
|
_, o, _ = c.exec_command("echo Katzir476! | sudo -S python3 /tmp/find_npm_db.py")
|
|
print(o.read().decode())
|
|
|
|
c.close()
|
|
|