Android和iOS包批量重簽名
本文實(shí)例為大家分享了Android和iOS包批量重簽名的具體代碼,供大家參考,具體內(nèi)容如下
Android篇
環(huán)境要求
1 安裝winrar,然后配置winrar的環(huán)境變量,要用到winrar指令
2 配置java的bin目錄到環(huán)境變量,要用到j(luò)arsigner指令
重簽名步驟說明:
1 從母包復(fù)制一個(gè)子包
2 刪除子包的簽名文件META-INFO
3 根據(jù)需要修改子包的文件,比如渠道號(hào)文件之類
4 重簽名子包
對(duì)應(yīng)的python腳本
import os
import sys
import shutil
import json
ORIGINAL_APK='母包.apk'
UNSIGN_APK='unsign.apk'
SIGNED_APK={"\"子包1.apk\"":1,"\"子包2.apk\"":2,"\"子包3.apk\"":3,"\"子包4.apk\"":4}
KEY_STORE='keystore文件.keystore'
KEY_PASS='key密碼'
STORE_PASS='store密碼'
def copy_apk(src_f,dst_f):
if not os.path.isfile(src_f):
print("%s not exist"%(src_f))
else:
fpath,fname=os.path.split(dst_f)
shutil.copyfile(src_f,dst_f)
print("copy %s -> %s"%(src_f,dst_f))
def zip_del_file(apk_f,del_f):
os.system("winrar d %s %s"%(apk_f,del_f))
print('zip_del_file:'+del_f)
def zip_add_file(apk_f,channel):
del_dir("assets")
os.makedirs("assets")
f=open("assets\\AppParamSetting.txt",'w')
f.write('{"channel":%s,"bundleIdentifier":""}'%(channel))
f.close()
os.system("winrar a -ad %s %s"%(apk_f,"assets\\AppParamSetting.txt"))
def del_file(f):
os.remove(f)
print('del_file:'+f)
def del_dir(f_dir):
if os.path.exists(f_dir):
shutil.rmtree(f_dir)
print("del_dir:"+f_dir)
def sign_app(unsigned_app, signed_app):
signcmd='jarsigner -verbose -keystore %s -keypass %s -storepass %s -signedjar %s -digestalg SHA1 -sigalg MD5withRSA %s sfish' % (KEY_STORE,KEY_PASS,STORE_PASS,signed_app,unsigned_app)
os.system(signcmd)
print(signcmd)
if __name__ == '__main__':
cur_dir=os.getcwd()
print('cur_dir'+cur_dir)
copy_apk(ORIGINAL_APK,"tmp_"+ORIGINAL_APK)
zip_del_file("tmp_"+ORIGINAL_APK,"META-INF")
for key in SIGNED_APK.keys():
channel=SIGNED_APK[key]
zip_add_file("tmp_"+ORIGINAL_APK,channel)
sign_app("tmp_"+ORIGINAL_APK,key)
del_dir("assets")
del_file("tmp_"+ORIGINAL_APK)
input("Done")
iOS篇
環(huán)境要求:
1 mac機(jī)子
2 證書文件,打開:Launchapd(火箭圖標(biāo))->其他 -> 鑰匙串訪問,就在那里
3 .mobileprovision文件
重簽名步驟說明:
1 從.mobileprovision文件生成entitlements.plist文件
2 解壓ipa,會(huì)得到一個(gè)Payload目錄,再往里是一個(gè)xxx.app,顯示包內(nèi)容可以看到里面的東西
3 刪除簽名文件,即:Payload/xxx.app/_CodeSignature目錄
4 根據(jù)需要修改文件,比如渠道文件
5 重簽名
6 壓縮ipa
對(duì)應(yīng)的python腳本
#!/usr/bin/python
import os
import sys
import json
ORIGINAL_IPA='母包.ipa'
SIGNED_APK={"\"子包1.ipa\"":1,"\"子包2.ipa\"":2,"\"子包3.ipa\"":3,"\"子包4.ipa\"":4}
CERT_FILE='證書文件'
MOBILE_PROVISION_UUID = 'mobileprovision的uuid'
def get_mobile_provision_dir():
return os.path.join(os.getenv('HOME'),'Library/MobileDevice/Provisioning Profiles/')
def get_mobile_provision_file(uuid):
return os.path.join(get_mobile_provision_dir(), uuid + ".mobileprovision")
def unzip_app():
os.system('unzip -qo ./%s -d ./'%(ORIGINAL_IPA))
print('unzip_app %s done!'%(ORIGINAL_IPA))
def del_code_signature():
os.system("rm -rf ./Payload/sfish.app/_CodeSignature")
print('del_code_signature done!')
def resign_app():
os.system('/usr/bin/codesign --continue -f -s "%s" --entitlements "%s" "%s"'%(CERT_FILE,'./entitlement.plist','./Payload/sfish.app'))
print('resign_app done!')
def zip_app(f_ipa):
os.system('zip -r %s ./Payload'%(f_ipa))
print('zip_app done!')
def del_payload():
os.system('rm -r ./Payload')
def gen_entitlements(uuid, out_file_name):
os.system('security cms -D -i "%s" > entitlement_full.plist '%(get_mobile_provision_file(uuid) ))
os.system('/usr/libexec/PlistBuddy -x -c \'Print:Entitlements\' entitlement_full.plist > "%s" '%( out_file_name))
def rep_emb_file(uuid):
os.system('cp "%s" ./Payload/sfish/embedded.mobileprovision' % (get_mobile_provision_file(uuid)))
def update_channel_file(channel):
f_channel='./Payload/xxx.app/Data/Raw/channel.txt'
fr=open(f_channel,'r')
txt=fr.read()
fr.close()
js=json.loads(txt)
js['channel_id']=channel
fw=open(f_channel,'w')
fw.write(json.dumps(js))
fw.close()
if __name__ == '__main__':
gen_entitlements( MOBILE_PROVISION_UUID, "entitlement.plist" )
unzip_app()
del_code_signature()
for key in SIGNED_APK.keys():
channel=SIGNED_APK[key]
update_channel_file(channel)
resign_app()
zip_app(key)
del_payload()
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- iOS實(shí)現(xiàn)電子簽名
- iOS mobileconfig配置文件進(jìn)行簽名的配置方法
- iOS 超級(jí)簽名之描述文件的實(shí)現(xiàn)過程
- iOS應(yīng)用腳本重簽名的實(shí)現(xiàn)方法
- iOS APP簽名機(jī)制原理詳解
- 詳解IOS微信上Vue單頁面應(yīng)用JSSDK簽名失敗解決方案
- iOS安全防護(hù)系列之重簽名防護(hù)與sysctl反調(diào)試詳解
- iOS 基于AFNetworking下自簽名證書配置的方法
- iOS中的ipa重簽名(逆向必備)
- iOS之Https自簽名證書認(rèn)證及數(shù)據(jù)請(qǐng)求的封裝原理
- IOS 簽名錯(cuò)誤codesign failed with exit code 1解決方法
- ios的簽名機(jī)制詳解
相關(guān)文章
flutter 自定義websocket路由的實(shí)現(xiàn)
這篇文章主要介紹了flutter 自定義websocket路由的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
Android基于hover組件實(shí)現(xiàn)監(jiān)控鼠標(biāo)移動(dòng)事件的方法
這篇文章主要介紹了Android基于hover組件實(shí)現(xiàn)監(jiān)控鼠標(biāo)移動(dòng)事件的方法,結(jié)合實(shí)例形式分析了hover組件監(jiān)控鼠標(biāo)光標(biāo)在view上變化的操作技巧,需要的朋友可以參考下2017-02-02
Android編程使用加速度傳感器實(shí)現(xiàn)搖一搖功能及優(yōu)化的方法詳解
這篇文章主要介紹了Android編程使用加速度傳感器實(shí)現(xiàn)搖一搖功能及優(yōu)化的方法,結(jié)合實(shí)例形式分析了Android傳感器的調(diào)用方法、參數(shù)含義及具體使用技巧,需要的朋友可以參考下2017-08-08
Android控件之ImageView用法實(shí)例分析
這篇文章主要介紹了Android控件之ImageView用法,以實(shí)例形式較為詳細(xì)的分析了ImageView控件用于顯示圖片的使用方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09
Java實(shí)現(xiàn)Andriod帶看括弧的計(jì)算器代碼
這篇文章主要介紹了Java實(shí)現(xiàn)Andriod帶看括弧的計(jì)算器代碼的相關(guān)資料,需要的朋友可以參考下2016-03-03

