Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement batch resignature in Android and iOS packages

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to achieve batch resignature in Android and iOS packages". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to achieve batch resignature in Android and iOS packages".

Android

Environmental requirements

1 install winrar, and then configure the environment variables of winrar, using the winrar directive

2 configure the bin directory of java to the environment variable, using the jarsigner instruction

Steps for resigning:

1 copy a child package from the master package

2 delete the signature file META-INFO of the subpackage

3 modify the files of the subpackage as needed, such as the channel number file

4-re-signed subpackage

Corresponding python script

Import osimport sysimport shutilimport json ORIGINAL_APK=' master package. Apk'UNSIGN_APK='unsign.apk'SIGNED_APK= {"\" subpackage 1.apk\ ": 1,"\ "subpackage 2.apk\": 2, "\" subpackage 3.apk\ "": 3, "\" subpackage 4.apk\ ": 4} KEY_STORE='keystore file. Keystore'KEY_PASS='key password 'STORE_PASS='store password' 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

Environmental requirements:

1 mac machine

2 certificate file, open: Launchapd (rocket icon)-> other-> keychain access, right there

3. Mobilization document

Steps for resigning:

1 generate an entitlements.plist file from a .Mobilization file

2 decompress ipa, you will get a Payload directory, and then there is a xxx.app, which shows the contents of the package and you can see the contents inside.

3 delete the signature file, that is, the Payload/xxx.app/_CodeSignature directory

4 modify files as needed, such as channel files

5 resignatures

6 compressed ipa

Corresponding python script

#! / usr/bin/python import osimport sysimport json ORIGINAL_IPA=' master package. Ipa'SIGNED_APK= {"\" subpackage 1.ipa\ "": 1, "\" subpackage 2.ipa\ "": 2, "\" subpackage 3.ipa\ ": 3,"\ "subpackage 4.ipa\": 4} CERT_FILE=' certificate 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 + ".Mobilization") def unzip_app (): os.system ('unzip-qo. /% s-d. /'% (ORIGINAL_IPA)) print ('unzip_app% s financing percent (ORIGINAL_IPA)) def del_code_signature (): os.system ("rm-rf. / Payload/sfish.app/_CodeSignature") print (' del_code_signature contacts') 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 subscription') Def zip_app (f_ipa): os.system ('zip-r% s. / Payload'% (f_ipa)) print (' zip_app subscription') 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): favored channelboat fr=open. 'r') txt=fr.read () fr.close () js=json.loads (txt) js ['channel_id'] = channel fw=open (faded channel _ js) 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 () so far I believe you have a deeper understanding of "how to achieve batch resignatures in Android and iOS packages", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report