From fe880b27b752e4d2bc9b4a25195451ebb8c44db7 Mon Sep 17 00:00:00 2001 From: nineven Date: Wed, 13 Apr 2022 22:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_client/src/components/FirDownload.vue | 11 +++++++++-- fir_client/src/components/ShortDownload.vue | 11 +++++++++-- .../src/components/apps/FirAppInfossecurity.vue | 7 ++----- fir_ser/common/utils/download.py | 7 ++++--- fir_ser/xsign/views/download.py | 9 ++++++--- fir_ser/xsign/views/receiveudids.py | 13 +++++++++---- 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/fir_client/src/components/FirDownload.vue b/fir_client/src/components/FirDownload.vue index a6010c0..2f8db9d 100644 --- a/fir_client/src/components/FirDownload.vue +++ b/fir_client/src/components/FirDownload.vue @@ -609,7 +609,10 @@ export default { if (this.$route.query.password && !this.err_password) { this.currentappinfo.need_password = false this.password = this.$route.query.password; - this.download() + // eslint-disable-next-line no-unused-vars + this.timer = setTimeout(data => { + this.download(); + }, 1000); } } else { if (this.$route.query.udid && this.$route.query.task_token) { @@ -678,7 +681,11 @@ export default { } else { if (this.agent !== '') { this.downloadurl = res.data.download_url; - window.location.href = this.downloadurl; + let pwd = '' + if(res.data.password && res.data.password.length>4){ + pwd = '&password=' + encodeURIComponent(res.data.password) + } + window.location.href = this.downloadurl + pwd; if (res.data.extra_url !== "") { // eslint-disable-next-line no-unused-vars this.timer = setTimeout(data => { diff --git a/fir_client/src/components/ShortDownload.vue b/fir_client/src/components/ShortDownload.vue index 0362c8c..0d26a49 100644 --- a/fir_client/src/components/ShortDownload.vue +++ b/fir_client/src/components/ShortDownload.vue @@ -574,7 +574,10 @@ export default { if (this.$route.query.password && !this.err_password) { this.currentappinfo.need_password = false this.password = this.$route.query.password; - this.download() + // eslint-disable-next-line no-unused-vars + this.timer = setTimeout(data => { + this.download(); + }, 1000); } } else { if (this.$route.query.udid && this.$route.query.task_token) { @@ -643,7 +646,11 @@ export default { } else { if (this.agent !== '') { this.downloadurl = res.data.download_url; - window.location.href = this.downloadurl; + let pwd = '' + if(res.data.password && res.data.password.length>4){ + pwd = '&password=' + encodeURIComponent(res.data.password) + } + window.location.href = this.downloadurl + pwd; if (res.data.extra_url !== "") { // eslint-disable-next-line no-unused-vars this.timer = setTimeout(data => { diff --git a/fir_client/src/components/apps/FirAppInfossecurity.vue b/fir_client/src/components/apps/FirAppInfossecurity.vue index 2cacfbe..e334e34 100644 --- a/fir_client/src/components/apps/FirAppInfossecurity.vue +++ b/fir_client/src/components/apps/FirAppInfossecurity.vue @@ -325,11 +325,7 @@ export default { methods: { format_copy_text(token) { let short_full_url = this.currentapp.preview_url + "/" + this.currentapp.short; - if (this.currentapp.type === 1 && this.currentapp.issupersign) { - return "应用下载链接:" + short_full_url + " 下载授权码:" + token - } else { - return "应用下载链接:" + short_full_url + "?password=" + token - } + return short_full_url + "?password=" + token }, copy_success() { this.$message.success('复制剪切板成功'); @@ -421,6 +417,7 @@ export default { }, tokenHandleSizeChange(val) { this.pagination.pagesize = val; + this.pagination.currentPage=1; this.showDownloadBase(); }, tokenHandleCurrentChange(val) { diff --git a/fir_ser/common/utils/download.py b/fir_ser/common/utils/download.py index 4ed310e..db86ca7 100644 --- a/fir_ser/common/utils/download.py +++ b/fir_ser/common/utils/download.py @@ -11,7 +11,7 @@ import time from api.models import Apps, UserInfo from api.utils.modelutils import get_app_d_count_by_app_id, add_remote_info_from_request, check_app_access_token from api.utils.signalutils import run_xsign_app_download_url -from common.base.baseutils import get_real_ip_address +from common.base.baseutils import get_real_ip_address, AesBaseCrypt from common.cache.storage import AppDownloadTodayTimesCache, AppDownloadTimesCache, DownloadUrlCache, AppInstanceCache from common.core.sysconfig import Config from common.utils.caches import consume_user_download_times @@ -117,8 +117,9 @@ def get_app_download_url(request, res, app_id, short, password, release_id, is_d app_type = '.ipa' download_url, extra_url = get_download_url_by_cache(app_obj, release_id + app_type, 600, is_download, udid=udid) - - res.data = {"download_url": download_url, "extra_url": extra_url} + encrypt_password = AesBaseCrypt().get_encrypt_uid(password) + res.data = {"download_url": download_url, "extra_url": extra_url, "password": encrypt_password} + logger.info(f'app download url :{res.data}') if download_url != "" and "mobileconifg" not in download_url: if not check_app_download_token(app_obj.get("need_password"), is_download, app_id, password): diff --git a/fir_ser/xsign/views/download.py b/fir_ser/xsign/views/download.py index 63705fa..6cfd780 100644 --- a/fir_ser/xsign/views/download.py +++ b/fir_ser/xsign/views/download.py @@ -24,10 +24,12 @@ from xsign.utils.supersignutils import make_sign_udid_mobile_config logger = logging.getLogger(__name__) -def get_post_udid_url(request, app_obj): +def get_post_udid_url(request, app_obj, pwd): server_domain = get_server_domain_from_request(request, Config.POST_UDID_DOMAIN) p_token = make_token(app_obj.app_id, time_limit=120, key='post_udid', force_new=True) - token = f'{p_token}{"".join(random.sample(p_token, 3))}{app_obj.app_id}{"".join(random.sample(p_token, 3))}' + token = f'{p_token}{"".join(random.sample(p_token, 3))}{app_obj.app_id}{"".join(random.sample(p_token, 3))}{pwd}' + logger.info(f'p_token:{p_token} app_id:{app_obj.app_id} pwd:{pwd}') + logger.info(f'token:{token}') return f'{server_domain}{reverse("xudid", kwargs={"short": app_obj.short})}?p={token}' @@ -38,6 +40,7 @@ class XsignDownloadView(APIView): def get(self, request, filename): down_token = request.query_params.get(settings.DATA_DOWNLOAD_KEY, None) + password = request.query_params.get('password', '') f_type = filename.split(".")[-1] flag = True storage_obj = get_local_storage() @@ -72,7 +75,7 @@ class XsignDownloadView(APIView): release_obj = AppReleaseInfo.objects.filter(release_id=filename.split('.')[0]).first() if release_obj: app_obj = release_obj.app_id - udid_url = get_post_udid_url(request, app_obj) + udid_url = get_post_udid_url(request, app_obj, password) ios_udid_mobile_config = make_sign_udid_mobile_config(udid_url, app_obj.bundle_id, app_obj.name) return file_response(ios_udid_mobile_config, make_random_uuid() + '.mobileconfig', "application/x-apple-aspen-config") diff --git a/fir_ser/xsign/views/receiveudids.py b/fir_ser/xsign/views/receiveudids.py index efd1c27..e05593a 100644 --- a/fir_ser/xsign/views/receiveudids.py +++ b/fir_ser/xsign/views/receiveudids.py @@ -37,11 +37,13 @@ class IosUDIDView(APIView): def post(self, request, short): p_info = request.query_params.get('p') - p_token = app_id = '' + p_token = app_id = pwd = '' + token_length = 52 + app_id_length = 32 if p_info: - p_token = p_info[:52] - app_id = p_info[55:len(p_info) - 3] - + p_token = p_info[:token_length] + app_id = p_info[token_length + 3:token_length + 3 + app_id_length] + pwd = p_info[token_length + app_id_length + 3 + 3:] if not p_token or not app_id: return HttpResponsePermanentRedirect(Config.WEB_DOMAIN) stream_f = str(request.body) @@ -78,6 +80,9 @@ class IosUDIDView(APIView): bind_udid=format_udid_info.get('udid')).first() if token_obj: msg = f"{msg}&password={token_obj.token}" + elif pwd: + msg = f"{msg}&password={AesBaseCrypt().get_decrypt_uid(pwd)}" + logger.info(f"msg:{msg}") else: return HttpResponsePermanentRedirect(f"{server_domain}/{short}") else: