fix some bugs

super_signature
nineven 5 years ago
parent 789b9a0c58
commit de4285a46a
  1. 6
      fir_ser/api/models.py
  2. 2
      fir_ser/api/urls.py
  3. 29
      fir_ser/api/utils/app/iossignapi.py
  4. 6
      fir_ser/api/utils/app/shellcmds.py
  5. 11
      fir_ser/api/utils/app/supersignutils.py
  6. 9
      fir_ser/api/utils/storage/caches.py
  7. 35
      fir_ser/api/views/download.py
  8. 35
      fir_ser/api/views/receiveudids.py
  9. 2
      fir_ser/supersign/scripts/apple_api.rb

@ -180,11 +180,9 @@ class AppUDID(models.Model):
binary_file = models.CharField(max_length=128,blank=True,verbose_name="签名包名称",null=True)
class Meta:
verbose_name = '应用详情'
verbose_name_plural = "应用详情"
verbose_name = '设备详情'
verbose_name_plural = "设备详情"
unique_together = ('app_id', 'udid',)
def __str__(self):

@ -23,7 +23,7 @@ from api.views.apps import AppsView,AppInfoView,AppReleaseinfoView
from api.views.download import ShortDownloadView
from api.views.uploads import AppAnalyseView,UploadView
from api.views.storage import StorageView
from api.views.download import IosUDIDView
from api.views.receiveudids import IosUDIDView
# router=DefaultRouter()

@ -19,8 +19,11 @@ def exec_shell(cmd,remote=False):
print(result)
return result
else:
print(cmd)
result = shell_command(cmd)
print(result)
if result.get("exit_code") != 0 :
raise
return result
@ -41,40 +44,33 @@ class AppDeveloperApi(object):
file_format_path_name = os.path.join(cert_dir_path,cert_dir_name)
self.cmd=self.cmd + " cert add '%s'" %(file_format_path_name)
result = exec_shell(self.cmd)
print(result)
def get_profile(self,bundleId,app_id,device_udid,device_name,provisionName):
self.cmd=self.cmd + " profile add %s %s %s %s %s '%s'" %(bundleId,app_id,device_udid,device_name,self.certid,provisionName)
self.cmd=self.cmd + " profile add '%s' '%s' '%s' '%s' '%s' '%s'" %(bundleId,app_id,device_udid,device_name,self.certid,provisionName)
result = exec_shell(self.cmd)
print(result)
def del_profile(self,bundleId,app_id):
self.cmd=self.cmd + " profile del %s %s" %(bundleId,app_id)
self.cmd=self.cmd + " profile del '%s' '%s'" %(bundleId,app_id)
result = exec_shell(self.cmd)
print(result)
def set_device_status(self,status,device_udid):
if status == "enable":
self.cmd=self.cmd + " device enable %s" %(device_udid)
self.cmd=self.cmd + " device enable '%s'" %(device_udid)
else:
self.cmd=self.cmd + " device disable %s" %(device_udid)
self.cmd=self.cmd + " device disable '%s'" %(device_udid)
result = exec_shell(self.cmd)
print(result)
def add_device(self,device_udid,device_name):
self.cmd=self.cmd + " device add %s %s" %(device_udid,device_name)
self.cmd=self.cmd + " device add '%s' '%s'" %(device_udid,device_name)
result = exec_shell(self.cmd)
print(result)
def add_app(self,bundleId,app_id):
self.cmd=self.cmd + " app add %s %s" %(bundleId,app_id)
self.cmd=self.cmd + " app add '%s' '%s'" %(bundleId,app_id)
result = exec_shell(self.cmd)
print(result)
def del_app(self,bundleId):
self.cmd=self.cmd + " app del %s " %(bundleId)
self.cmd=self.cmd + " app del '%s' " %(bundleId)
result = exec_shell(self.cmd)
print(result)
# appdev = AppDeveloperApi("hehehuyu521@163.com","Hehehuyu123")
# appdev.create_cert()
@ -87,10 +83,9 @@ class ResignApp(object):
self.my_local_key=my_local_key
self.app_dev_pem = app_dev_pem
# script_path=os.path.join(SUPER_SIGN_ROOT,'scripts','apple_api.rb')
self.cmd = "isign -c %s -k %s " %(self.app_dev_pem,self.my_local_key)
self.cmd = "isign -c '%s' -k '%s' " %(self.app_dev_pem,self.my_local_key)
def sign(self,new_profile,org_ipa,new_ipa):
self.cmd = self.cmd + " -p %s -o %s %s" %(new_profile,new_ipa,org_ipa)
self.cmd = self.cmd + " -p '%s' -o '%s' '%s'" %(new_profile,new_ipa,org_ipa)
result = exec_shell(self.cmd)
print(result)

@ -87,11 +87,12 @@ class SSHConnection(object):
self._client.close()
def shell_command(cmdstrs):
cmdresult = re.split(r'\s+', cmdstrs)
# cmdresult = re.split(r'\s+', cmdstrs)
# print(cmdresult)
result = default_result()
result['return_info'] = ''
shell_start_time = time.time()
child = Popen(cmdresult, shell=True, stdout=PIPE, stderr=PIPE)
child = Popen(cmdstrs, shell=True, stdout=PIPE, stderr=PIPE)
out, err = child.communicate()
shell_end_time = time.time()
result['shell_run_time'] = shell_end_time - shell_start_time
@ -125,3 +126,4 @@ def use_user_pass(hostip,port,user,passwd,cmdstrs):
return result

@ -129,14 +129,15 @@ class IosUtils(object):
def get_profile_full_path(self):
cert_dir_name = make_app_uuid(self.user_obj,self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name)
file_format_path_name = os.path.join(cert_dir_path,cert_dir_name,"profile")
if not os.path.isdir(file_format_path_name):
os.makedirs(file_format_path_name)
provisionName = os.path.join(file_format_path_name,self.app_obj.app_id)
cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name,"profile")
if not os.path.isdir(cert_dir_path):
os.makedirs(cert_dir_path)
provisionName = os.path.join(cert_dir_path,self.app_obj.app_id)
return provisionName+ '.mobileprovision'
def resign(self):
if AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).first().is_signed:
return
self.download_profile()
cert_dir_name = make_app_uuid(self.app_obj.user_id,self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name)

@ -5,8 +5,8 @@
# date: 2020/4/7
from django.core.cache import cache
from api.models import Apps,UserInfo,AppReleaseInfo,AppStorage
import time,os,base64,json
from api.models import Apps,UserInfo,AppReleaseInfo,AppUDID
import time,os
from django.utils import timezone
from fir_ser.settings import CACHE_KEY_TEMPLATE
from api.utils.storage.storage import Storage,LocalStorage
@ -21,6 +21,11 @@ def get_download_url_by_cache(app_obj, filename, limit, isdownload=True,key='',u
if not udid:
if app_obj.get('issupersign',None):
download_url_type = 'mobileconifg'
else:
appudid_obj = AppUDID.objects.filter(app_id_id=app_obj.get("pk"),udid=udid,is_signed=True).first()
if appudid_obj:
filename=appudid_obj.binary_file+'.ipa'
return local_storage.get_download_url(filename, limit)
return local_storage.get_download_url(filename, limit, download_url_type)
down_key = "_".join([key.lower(), CACHE_KEY_TEMPLATE.get('download_url_key'), filename])
download_val = cache.get(down_key)

@ -10,13 +10,13 @@ from fir_ser import settings
from api.utils.TokenManager import DownloadToken
from api.utils.app.randomstrings import make_random_uuid
from api.utils.app.apputils import make_resigned
from api.utils.app.supersignutils import make_udid_mobileconfig,udid_bytes_to_dict,get_post_udid_url,get_redirect_server_domain,IosUtils
from api.utils.app.supersignutils import make_udid_mobileconfig,get_post_udid_url
from api.utils.storage.storage import Storage
from api.utils.storage.caches import get_app_instance_by_cache,get_download_url_by_cache,set_app_download_by_cache,del_cache_response_by_short
import os
from rest_framework_extensions.cache.decorators import cache_response
from api.utils.serializer import AppsShortSerializer
from api.models import Apps,AppReleaseInfo,AppUDID
from api.models import Apps,AppReleaseInfo
from django.http import FileResponse
class DownloadView(APIView):
'''
@ -155,34 +155,3 @@ class InstallView(APIView):
return Response(res.dict)
from django.views import View
from django.http import HttpResponsePermanentRedirect,Http404
class IosUDIDView(View):
def post(self,request,short):
stream_f = str(request.body)
format_udid_info = udid_bytes_to_dict(stream_f)
print(format_udid_info,short)
try:
app_info=Apps.objects.filter(short=short).values("pk",'issupersign').first()
if app_info :
if app_info.get('issupersign'):
AppUDID.objects.update_or_create(app_id_id= app_info.get('pk'),**format_udid_info,defaults={'udid':format_udid_info.get('udid')})
ios_obj = IosUtils(format_udid_info,app_info)
ios_obj.resign()
else:
return Http404
else:
return Http404
except Exception as e:
print(e)
server_domain = get_redirect_server_domain(request)
return HttpResponsePermanentRedirect("%s/%s?udid=%s"%(server_domain,short,format_udid_info.get("udid")))

@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 3月
# author: liuyu
# date: 2020/3/6
from api.utils.app.supersignutils import udid_bytes_to_dict,get_redirect_server_domain,IosUtils
from api.models import Apps,AppUDID
from django.views import View
from django.http import HttpResponsePermanentRedirect,Http404
class IosUDIDView(View):
def post(self,request,short):
stream_f = str(request.body)
format_udid_info = udid_bytes_to_dict(stream_f)
try:
app_info=Apps.objects.filter(short=short).first()
if app_info :
if app_info.issupersign:
AppUDID.objects.update_or_create(app_id=app_info,**format_udid_info,defaults={'udid':format_udid_info.get('udid')})
ios_obj = IosUtils(format_udid_info,app_info)
ios_obj.resign()
else:
return Http404
else:
return Http404
except Exception as e:
print(e)
server_domain = get_redirect_server_domain(request)
return HttpResponsePermanentRedirect("%s/%s?udid=%s"%(server_domain,short,format_udid_info.get("udid")))

@ -56,7 +56,7 @@ class DevelopPortalHandle
#没有找到就创建,找到就下载
File.write(provisionName, profile.download)
return provisionFileName
return provisionName
end
def delete_profile(provisioningClass,appid)

Loading…
Cancel
Save