admin.nomadro.com gets sidebar L1/L2 social ops (paginated lists + entity detail); API adds soft-delete archives/stats and shared nomadro_pb for social/coffee/notify/work. Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import time
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
import paramiko
|
|
|
|
US = ("108.174.50.68", "root", "Xiao4669805")
|
|
|
|
|
|
def http(url: str, **kw):
|
|
req = urllib.request.Request(url, **kw)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=20) as resp:
|
|
body = resp.read().decode("utf-8", "replace")
|
|
return resp.status, body
|
|
except urllib.error.HTTPError as e:
|
|
return e.code, e.read().decode("utf-8", "replace")
|
|
except Exception as e:
|
|
return 0, str(e)
|
|
|
|
|
|
def main() -> int:
|
|
time.sleep(2)
|
|
code, body = http("https://admin.nomadro.com/")
|
|
print("admin_com", code, "Nomadro" in body)
|
|
code, body = http(
|
|
"https://api.nomadro.com/api/admin/login",
|
|
data=json.dumps(
|
|
{"username": "hackrobot", "password": "Xiao4669805@"}
|
|
).encode(),
|
|
headers={"content-type": "application/json"},
|
|
method="POST",
|
|
)
|
|
print("login", code, body[:160])
|
|
token = ""
|
|
try:
|
|
token = json.loads(body).get("token") or ""
|
|
except Exception:
|
|
pass
|
|
if not token:
|
|
# remote curl fallback
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
h, u, p = US
|
|
c.connect(h, 22, u, p, timeout=40, allow_agent=False, look_for_keys=False)
|
|
_, o, e = c.exec_command(
|
|
r"""
|
|
systemctl is-active nomadmini-api
|
|
journalctl -u nomadmini-api -n 40 --no-pager
|
|
curl -sS -o /tmp/login.json -w 'login %{http_code}\n' --max-time 15 -X POST https://api.nomadro.com/api/admin/login \
|
|
-H 'content-type: application/json' \
|
|
-d '{"username":"hackrobot","password":"Xiao4669805@"}'
|
|
head -c 300 /tmp/login.json; echo
|
|
""",
|
|
timeout=60,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
print(e.read().decode("utf-8", "replace")[-1500:])
|
|
c.close()
|
|
return 1
|
|
headers = {"Authorization": f"Bearer {token}"}
|
|
for path in ("overview", "stats", "archives", "messages?limit=5", "roster?limit=5"):
|
|
c2, b2 = http(
|
|
f"https://api.nomadro.com/api/admin/social/ugc/{path}",
|
|
headers=headers,
|
|
)
|
|
print(f"ugc/{path}", c2, b2[:220].replace("\n", " "))
|
|
print("SMOKE_OK")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|