python 获取安装包apk, ipa 信息
# -*- coding:utf-8 -*- import re import os import zipfile from biplist import * from androguard.core.bytecodes import apk class AnalyzePackage: def get_android_data(self, package_file): try: apkobj = apk.APK(package_file) except Exception as err: print(err) else: if apkobj.is_valid_APK(): versioncode = apkobj.get_androidversion_code() bundle_id = apkobj.get_package() labelname = apkobj.get_app_name() versioname = apkobj.get_androidversion_name() sdk_version = apkobj.get_target_sdk_version() return labelname, bundle_id, versioncode, versioname, sdk_version def get_ios_data(self, ios_file): if zipfile.is_zipfile(ios_file): ipaobj = zipfile.ZipFile(ios_file) info_path = self.get_ios_info_path(ipaobj) if info_path: plist_data = ipaobj.read(info_path) plist_root = readPlistFromString(plist_data) labelname = plist_root['CFBundleDisplayName'] versioncode = plist_root['CFBundleVersion'] bundle_id = plist_root['CFBundleIdentifier'] return labelname, bundle_id, versioncode def get_ios_info_path(self, ipaobj): infopath_re = re.compile(r'.*.app/Info.plist') for i in ipaobj.namelist(): m = infopath_re.match(i) if m is not None: return m.group() def get_package_size(self,package_path): fsize = os.path.getsize(package_path) fsize = fsize / float(1024 * 1024) return round(fsize, 2)