probe_sms_endpoint_v3.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Targeted probe of pc-api.996hezi.com/sms/send with format-valid phones.
  2. The wide probe found 1 non-404 hit: this endpoint returned 500 'phone format
  3. invalid' for '00000000000'. Now try valid-format fake phones to see what
  4. the server does for an actual SMS send attempt.
  5. """
  6. import asyncio
  7. import json
  8. import sys
  9. from pathlib import Path
  10. _HERE = Path(__file__).resolve().parent
  11. sys.path.insert(0, str(_HERE.parent / "src"))
  12. from cq2_sdk.env_loader import load_env
  13. load_env(_HERE.parent / ".env")
  14. from cq2_sdk.login import Box996Login, ManualGeetestSolver
  15. HOST = "https://pc-api.996hezi.com"
  16. PATH = "/sms/send"
  17. # 用不同格式的假号探: 全 0 / 全 1 / 11 位 1 开头 / 13 位 +86
  18. TEST_PHONES = [
  19. ("00000000000", "全 0 (格式错, 基线)"),
  20. ("11111111111", "11 位 1 开头 (格式过, 但不存在)"),
  21. ("13800138000", "标准 11 位 138 开头 (格式过, 不存在)"),
  22. ("+8613800138000", "E.164 +86 格式"),
  23. ("17756576757", "用户真实号 (会真发短信! 跳过这行)"),
  24. ]
  25. async def try_phone(box, phone: str) -> dict:
  26. """Returns dict with status, code, msg."""
  27. try:
  28. r = await box._request("POST", HOST, PATH,
  29. json_body={"phone": phone,
  30. "channel_id": "",
  31. "game_id": "",
  32. "inviter_uid": "",
  33. "needConfirmLogin": True})
  34. return {"http": 200, "code": r.get("code", 0),
  35. "msg": r.get("msg", "")[:100],
  36. "data_keys": list(r.get("data", {}).keys()) if isinstance(r.get("data"), dict) else []}
  37. except Exception as e:
  38. from cq2_sdk.login.box_996 import Box996Error, CaptchaRequiredError
  39. msg = str(e)[:120]
  40. if "404" in msg:
  41. return {"http": 404, "code": 0, "msg": "404"}
  42. if isinstance(e, CaptchaRequiredError):
  43. return {"http": 200, "code": 101000, "msg": "geetest required"}
  44. if isinstance(e, Box996Error):
  45. return {"http": 200, "code": e.code, "msg": e.msg[:100]}
  46. return {"http": 0, "code": 0, "msg": msg}
  47. async def main() -> int:
  48. box = Box996Login(geetest=ManualGeetestSolver(), device_id="00:15:5d:0a:04:00")
  49. print(f"Probing {HOST}{PATH} with format-valid fake phones:\n")
  50. for phone, desc in TEST_PHONES:
  51. if phone == "17756576757":
  52. print(f" [SKIP] 真实号, 跳过避免真发短信")
  53. continue
  54. r = await try_phone(box, phone)
  55. print(f" phone={phone:<15} {desc:<30} http={r['http']} code={r.get('code', 0):>4} {r.get('msg', '')}")
  56. return 0
  57. if __name__ == "__main__":
  58. sys.exit(asyncio.run(main()))