Ejemplo n.º 1
0
def __download_profile(_config: IosAccountHelper, _profile: IosProfileInfo):
    ret = _config.post(
        "获取profile文件",
        "https://developer.apple.com/services-account/QH65B2/account/ios/profile/downloadProfileContent?teamId=",
        data={
            "provisioningProfileId": _profile.profile_id,
        },
        json_api=False,
        is_json=False,
        log=False,
        is_binary=True,
        method="GET",
    )
    profile = base64(ret)
    if profile != _profile.profile:
        _profile.profile = base64(ret)
        _profile.save()
        Log("更新profile文件[%s]" % _profile.sid)
Ejemplo n.º 2
0
def upload_cert_p12(account: str, file: bytes, password: str = "q1w2e3r4"):
    p12 = crypto.load_pkcs12(file, password)
    name = re.match(r"iPhone Developer: (.+) \([A-Z0-9]+\)",
                    p12.get_friendlyname().decode("utf8")).groups()
    Assert(len(name), "非法的p12文件")
    name = name[0]  # type: str
    _cert = IosCertInfo.objects.get(sid="%s:%s" % (account, name))
    _cert.cert_p12 = base64(file)
    _cert.save()
    return {
        "succ": True,
    }
Ejemplo n.º 3
0
    def post(self,
             title: str,
             url: str,
             data: Union[Dict, str] = None,
             is_json=True,
             log=True,
             cache: Union[bool, int] = False,
             csrf=False,
             json_api=True,
             method="POST",
             is_binary=False,
             ex_headers=None,
             status=200):
        if cache is True:
            expire = 3600 * 1000
        else:
            expire = cache

        if not self.is_login:
            self.__login()
        start = now()
        rsp_str = "#NODATA#"
        try:
            if "teamId=" in url:
                if "teamId=%s" % self.team_id not in url:
                    url = url.replace("teamId=", "teamId=%s" % self.team_id)
            if cache:
                rsp_str = _cache(url, data) or rsp_str
            headers = {
                'cookie':
                to_form_url({"myacinfo": self.cookie["myacinfo"]}, split=';'),
            }
            if csrf:
                headers.update({
                    'csrf': self.csrf,
                    'csrf_ts': self.csrf_ts,
                })
            if ex_headers:
                headers.update(ex_headers)
            if rsp_str == "#NODATA#":
                if method.upper() == "GET":
                    rsp = requests.get(url,
                                       params=data,
                                       headers=headers,
                                       timeout=3,
                                       verify=False)
                else:
                    rsp = requests.post(url,
                                        data=data,
                                        headers=headers,
                                        timeout=3,
                                        verify=False)

                rsp_str = rsp.text
                if rsp.headers.get("csrf"):
                    self.csrf = rsp.headers["csrf"]
                    self.csrf_ts = int(rsp.headers["csrf_ts"])
                Assert(rsp.status_code == status,
                       "请求[%s]异常[%s]" % (title, rsp.status_code))
                if json_api:
                    _data = str_json_i(rsp_str) or {}
                    if _data.get("resultCode") == 1100:
                        self.__logout()
                        raise Fail("登录[%s]过期了[%s][%s]" %
                                   (self.account, _data.get("resultString"),
                                    _data.get("userString")))
                    Assert(
                        _data.get("resultCode") == 0, "请求业务[%s]失败[%s][%s]" %
                        (title, _data.get("resultString"),
                         _data.get("userString")))
                if log:
                    Log("apple请求[%s][%s]发送[%r]成功[%r]" %
                        (title, now() - start, data, rsp_str))
                if is_binary:
                    rsp_str = base64(rsp.content)
                if cache:
                    _set_cache(url, data, rsp_str, expire=expire)
            if is_json:
                return str_json(rsp_str)
            elif is_binary:
                return base64decode(rsp_str)
            else:
                return rsp_str
        except Exception as e:
            if log:
                Log("apple请求[%s][%s]发送[%r]失败[%r]" %
                    (title, now() - start, data, rsp_str))
            raise e