فهرست منبع

Stop using /qe/sync for login

Tulir Asokan 2 سال پیش
والد
کامیت
bef9e88398
4فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
  1. 1 0
      mauigpapi/http/base.py
  2. 14 0
      mauigpapi/http/login.py
  3. 2 0
      mauigpapi/state/device.py
  4. 1 1
      mautrix_instagram/commands/auth.py

+ 1 - 0
mauigpapi/http/base.py

@@ -123,6 +123,7 @@ class BaseAndroidAPI:
             "x-ig-timezone-offset": self.state.device.timezone_offset,
             # "x-messenger": "1",
             "x-ig-device-id": self.state.device.uuid,
+            "x-ig-family-device-id": self.state.device.fdid,
             "x-ig-android-id": self.state.device.id,
             "x-ig-connection-type": self.state.device.connection_type,
             "x-fb-connection-type": self.state.device.connection_type,

+ 14 - 0
mauigpapi/http/login.py

@@ -20,6 +20,7 @@ import io
 import json
 import struct
 import time
+import uuid
 
 from Crypto.Cipher import AES, PKCS1_v1_5
 from Crypto.PublicKey import RSA
@@ -30,6 +31,19 @@ from .base import BaseAndroidAPI
 
 
 class LoginAPI(BaseAndroidAPI):
+    async def get_mobile_config(self) -> None:
+        req = {
+            "bool_opt_policy": "0",
+            "mobileconfigsessionless": "",
+            "api_version": "3",
+            "unit_type": "1",
+            "query_hash": "dae17f1d3276207ebfe78f7a67cc9a04d4b88ff8c88dfc17e148fafb3f655b8e",
+            "device_id": self.state.device.id,
+            "fetch_type": "ASYNC_FULL",
+            "family_device_id": self.state.device.fdid.upper(),
+        }
+        await self.std_http_post("/api/v1/launcher/mobileconfig/", data=req)
+
     async def login(
         self,
         username: str,

+ 2 - 0
mauigpapi/state/device.py

@@ -32,6 +32,7 @@ class AndroidDevice(SerializableAttrs):
     id: Optional[str] = None
     descriptor: Optional[str] = None
     uuid: Optional[str] = None
+    fdid: Optional[str] = None
     phone_id: Optional[str] = attr.ib(default=None, metadata={"json": "phoneId"})
     # Google Play advertising ID
     adid: Optional[str] = None
@@ -78,3 +79,4 @@ class AndroidDevice(SerializableAttrs):
             ]
         )
         self.uuid = str(UUID(int=rand.getrandbits(128), version=4))
+        self.fdid = str(UUID(int=rand.getrandbits(128), version=4))

+ 1 - 1
mautrix_instagram/commands/auth.py

@@ -46,7 +46,7 @@ async def get_login_state(user: u.User, seed: str) -> tuple[AndroidAPI, AndroidS
         seed = hmac.new(seed.encode("utf-8"), user.mxid.encode("utf-8"), hashlib.sha256).digest()
         state.device.generate(seed)
         api = AndroidAPI(state, log=user.api_log, proxy_handler=user.proxy_handler)
-        await api.qe_sync_login_experiments()
+        await api.get_mobile_config()
         user.command_status = {
             "action": "Login",
             "state": state,