-
-
Save iBug/7bf05b08521beda0004efbbf3d4ab332 to your computer and use it in GitHub Desktop.
Generate WARP client information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import base64 | |
import datetime | |
import json | |
import random | |
import requests | |
import string | |
import subprocess | |
def genstring(k): | |
return "".join(random.choices(string.ascii_lowercase + string.digits, k=k)) | |
def genkey(): | |
return subprocess.run(["wg", "genkey"], capture_output=True).stdout.decode().strip() | |
def pubkey(privkey): | |
return subprocess.run(["wg", "pubkey"], input=privkey.encode(), capture_output=True).stdout.decode().strip() | |
def reg(key): | |
url = "https://api.cloudflareclient.com/v0a977/reg" | |
headers = { | |
"User-Agent": "okhttp/3.12.1", | |
"Content-Type": "application/json; charset=UTF-8", | |
} | |
install_id = genstring(11) | |
payload = { | |
"key": key, | |
"install_id": install_id, | |
"fcm_token": f"{install_id}:APA91b{genstring(134)}", | |
"referer": "1.1.1.1", | |
"warp_enabled": True, | |
"tos": datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S+08:00"), | |
"model": "Xiaomi POCO X2", | |
"type": "Android", | |
"locale": "en_US", | |
} | |
r = requests.post(url, headers=headers, data=json.dumps(payload)) | |
return r.json() | |
k = genkey() | |
pk = pubkey(k) | |
r = reg(pk) | |
c = r['config'] | |
print("PrivateKey =", k) | |
print("PublicKey =", pk) | |
print("IPv4 =", c['interface']['addresses']['v4']) | |
print("IPv6 =", c['interface']['addresses']['v6']) | |
print("RoutingID =", list(base64.b64decode(c['client_id']))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"model": "pc-i440fx-6.1",
"type": "Linux",