Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Fix Umami admin password — escape bcrypt $ for shell."""
|
|
import json
|
|
import time
|
|
import paramiko
|
|
|
|
PASSWORD = "Xiao4669805@"
|
|
USER = "hackrobot"
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
|
|
|
|
def run(cmd, timeout=120):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
|
|
|
|
bcrypt_hash = run(
|
|
f"python3 -c \"import bcrypt; print(bcrypt.hashpw(b'{PASSWORD}', bcrypt.gensalt(rounds=10)).decode())\""
|
|
).strip().splitlines()[-1]
|
|
print("hash:", bcrypt_hash)
|
|
|
|
remote_sql = f"/tmp/umami_admin_{int(time.time())}.sql"
|
|
sql_body = (
|
|
f"UPDATE \"user\" SET username = '{USER}', password = '{bcrypt_hash}', updated_at = now() "
|
|
f"WHERE username IN ('admin', '{USER}');\n"
|
|
f"SELECT username, length(password) AS pw_len, left(password, 7) AS pw_prefix FROM \"user\";\n"
|
|
)
|
|
with sftp.file(remote_sql, "w") as f:
|
|
f.write(sql_body)
|
|
|
|
print(run(f"docker cp {remote_sql} umami-db-1:/tmp/umami_admin.sql"))
|
|
print(run("docker exec umami-db-1 psql -U umami -d umami -f /tmp/umami_admin.sql"))
|
|
print(run("docker restart umami-umami-1"))
|
|
time.sleep(8)
|
|
|
|
payload = json.dumps({"username": USER, "password": PASSWORD})
|
|
login = run(
|
|
f"curl -s -w '\\nHTTP:%{{http_code}}' -X POST http://127.0.0.1:3010/api/auth/login "
|
|
f"-H 'Content-Type: application/json' -d '{payload}'"
|
|
)
|
|
print("login:", login)
|
|
|
|
# verify hash length in db
|
|
print(
|
|
run(
|
|
'docker exec umami-db-1 psql -U umami -d umami -t -A -c '
|
|
'"SELECT length(password), password FROM \"user\" WHERE username=\'hackrobot\';"'
|
|
)
|
|
)
|
|
|
|
sftp.close()
|
|
c.close()
|