gogs13.py 1.1 KB

123456789101112131415
  1. import paramiko, base64
  2. c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  3. c.connect(hostname="139.159.253.131", username="root", password="bofang666.", timeout=25)
  4. sql = """SELECT id, name, lower_name, is_admin, is_active FROM "user" WHERE lower_name IN ('fmode','xadmin') ORDER BY id;"""
  5. b64 = base64.b64encode(sql.encode()).decode()
  6. cmd = f'echo {b64} | base64 -d > /tmp/q.sql && PGPASSWORD=666 psql -h 127.0.0.1 -p 5433 -U dev -d gogs -At -f /tmp/q.sql; rm -f /tmp/q.sql'
  7. _,o,e = c.exec_command(cmd, timeout=45)
  8. print(o.read().decode()[:800]); print("ERR", e.read().decode()[:200])
  9. # 找 hardware 相关仓库
  10. sql2 = "SELECT id, lower_name, is_private FROM repository WHERE lower_name ILIKE '%hardware%' OR lower_name ILIKE '%xianti%' OR lower_name ILIKE '%壳%' LIMIT 10;"
  11. b2 = base64.b64encode(sql2.encode()).decode()
  12. cmd2 = f'echo {b2} | base64 -d > /tmp/q2.sql && PGPASSWORD=666 psql -h 127.0.0.1 -p 5433 -U dev -d gogs -At -f /tmp/q2.sql; rm -f /tmp/q2.sql'
  13. _,o,e = c.exec_command(cmd2, timeout=45)
  14. print("=== 现有 hardware 仓 ==="); print(o.read().decode()[:500])
  15. c.close()