Guest User

Untitled

a guest
Jul 6th, 2026
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. ##run this in your vps
  2.  
  3. #WARNING: THIS SCRIPT WAS MADE BY AN AI AND NOT BY ME
  4.  
  5. #!/usr/bin/env python3
  6. import json
  7. import subprocess
  8. import urllib.request
  9. from urllib.parse import urlencode, quote
  10.  
  11. CONFIG = "/usr/local/etc/xray/config.json"
  12. XRAY = "/usr/local/bin/xray"
  13.  
  14. with open(CONFIG) as f:
  15.     cfg = json.load(f)
  16.  
  17. inbound = next(i for i in cfg["inbounds"] if i.get("protocol") == "vless")
  18.  
  19. uuid = inbound["settings"]["clients"][0]["id"]
  20. flow = inbound["settings"]["clients"][0].get("flow", "xtls-rprx-vision")
  21. port = inbound["port"]
  22.  
  23. reality = inbound["streamSettings"]["realitySettings"]
  24. sni = reality["serverNames"][0]
  25. short_id = reality["shortIds"][0]
  26. private_key = reality["privateKey"]
  27.  
  28. result = subprocess.run(
  29.     [XRAY, "x25519", "-i", private_key],
  30.     text=True,
  31.     capture_output=True
  32. )
  33.  
  34. output = (result.stdout + "\n" + result.stderr).strip()
  35.  
  36. public_key = None
  37.  
  38. for line in output.splitlines():
  39.     lower = line.lower()
  40.     if ("publickey" in lower or "public key" in lower or "password" in lower) and ":" in line:
  41.         public_key = line.split(":", 1)[1].strip()
  42.         break
  43.  
  44. if not public_key:
  45.     lines = [line.strip() for line in output.splitlines() if line.strip()]
  46.     if len(lines) == 1:
  47.         public_key = lines[0]
  48.  
  49. if not public_key:
  50.     print("Could not automatically find the public key.")
  51.     print("\nRaw xray output was:\n")
  52.     print(output)
  53.     raise SystemExit(1)
  54.  
  55. vps_ip = urllib.request.urlopen("https://api.ipify.org").read().decode().strip()
  56.  
  57. params = {
  58.     "encryption": "none",
  59.     "flow": flow,
  60.     "security": "reality",
  61.     "sni": sni,
  62.     "fp": "chrome",
  63.     "pbk": public_key,
  64.     "sid": short_id,
  65.     "type": "tcp",
  66.     "packetEncoding": "xudp"
  67. }
  68.  
  69. link = f"vless://{uuid}@{vps_ip}:{port}?{urlencode(params)}#{quote('vless-reality')}"
  70.  
  71. print("\nYour VLESS client link:\n")
  72. print(link)
Advertisement
Add Comment
Please, Sign In to add comment