Esempio n. 1
0
async def get_sso_list() -> SsoServerResponse:
    """Do sso server list request and return the response.

    Note:
        Source: com.tencent.mobileqq.msf.core.a.f.run

    Returns:
        SsoServerResponse: Sso server list response

    Raises:
        SsoServerException: Get sso server list failed.
    """
    device = get_device()
    protocol = get_protocol()
    key = bytes([
        0xF0,
        0x44,
        0x1F,
        0x5F,
        0xF4,
        0x2D,
        0xA5,
        0x8F,
        0xDC,
        0xF7,
        0x94,
        0x9A,
        0xBA,
        0x62,
        0xD4,
        0x11,
    ])
    payload = SsoServerRequest.to_bytes(
        0, SsoServerRequest(app_id=protocol.app_id, imei=device.imei))
    req_packet = RequestPacketVersion3(
        servant_name="HttpServerListReq",
        func_name="HttpServerListReq",
        data=types.MAP(
            {types.STRING("HttpServerListReq"): types.BYTES(payload)}),
    ).encode(with_length=True)
    buffer: bytes = qqtea_encrypt(req_packet, key)
    async with connect("configsvr.msf.3g.qq.com", 443, ssl=True) as conn:
        query = (b"POST /configsvr/serverlist.jsp HTTP/1.1\r\n"
                 b"Host: configsvr.msf.3g.qq.com\r\n"
                 b"User-Agent: QQ/8.4.1.2703 CFNetwork/1126\r\n"
                 b"Net-Type: Wifi\r\n"
                 b"Accept: */*\r\n"
                 b"Connection: close\r\n"
                 b"Content-Type: application/octet-stream\r\n"
                 b"Content-Length: " + str(len(buffer)).encode() + b"\r\n"
                 b"\r\n" + buffer)
        conn.write(query)
        conn.write_eof()
        resp_bytes = await conn.read_all()
        response = http.client.HTTPResponse(
            _FakeSocket(resp_bytes)  # type: ignore
        )
        response.begin()

    if response.status != 200:
        raise SsoServerException(
            f"Get sso server list failed with response code {response.status}")
    data: bytes = qqtea_decrypt(response.read(), key)
    resp_packet = RequestPacketVersion3.decode(data)
    server_info = SsoServerResponse.decode(
        resp_packet.data["HttpServerListRes"][1:-1]  # type: ignore
    )
    return server_info
Esempio n. 2
0
    IncomingPacket,
)
from .command import (
    SvcRegisterResponse,
    RegisterSuccess,
    RegisterFail,
    MSFForceOfflineCommand,
    MSFForceOffline,
    MSFForceOfflineError,
)

if TYPE_CHECKING:
    from cai.client import Client

DEVICE = get_device()
APK_INFO = get_protocol()


class OnlineStatus(IntEnum):
    """
    Note:
        Source: mqq.app.AppRuntime
    """

    Unknown = 0
    """未知"""
    Online = 11
    """我在线上"""
    Offline = 21
    """离线"""
    Away = 31