Пример #1
0
def extracticon(apk_path):
    apk_dir = os.path.splitext(apk_path)[0]
    retcode, msg = star.runcmd2(
        [PathManager.get_aapt_path(), 'dump', 'badging', apk_path])
    if retcode == 0:
        icons = star.findall("icon.*?'(.+?)'", msg)
        icons = list(set(icons))
        # icons匹配出来的字符串可能不是图片格式,这里过滤删除下
        for i in range(len(icons) - 1, -1, -1):
            if not (icons[i].endswith('.png') or icons[i].endswith('.jpg') or
                    icons[i].endswith('.jpeg') or icons[i].endswith('.bmp')):
                icons.remove(icons[i])

        zfile = zipfile.ZipFile(apk_path,
                                'r',
                                compression=zipfile.ZIP_DEFLATED)

        for icon in icons:
            icon_name = '_' + os.path.splitext(os.path.basename(icon))[0]
            icon_file = apk_dir + '_temp.png'
            file(icon_file, 'wb').write(zfile.read(icon))
            image = Image.open(icon_file)
            image_size = '_' + str(image.size[0])
            image.close()  # 一定要调用close否则下面的rename会出现异常
            new_icon_file = apk_dir + icon_name + image_size + '.png'
            if not os.path.exists(new_icon_file):
                os.rename(icon_file, new_icon_file)
            else:  # 如果当前目录下已存在提取后重新命名的文件,则删除临时文件而不是重命名
                os.remove(icon_file)
        print(u'不同分辨率的图标已经提取完成,路径位于和apk同级目录下')
    return retcode, msg
Пример #2
0
def viewapk(apk_path):
    infoFile = os.path.splitext(apk_path)[0] + '_apkinfo.txt'
    retcode, msg = star.runcmd2(
        [PathManager.get_aapt_path(), 'dump', 'badging', apk_path])
    if retcode == 0:
        package = star.find("package: name='(.*?)'", msg)
        versionCode = star.find("versionCode='(.*?)'", msg)
        versionName = star.find("versionName='(.*?)'", msg)
        appName = star.find("application-label:'(.*?)'", msg)
        activity = star.find("launchable-activity: name='(.*?)'", msg)
        print(package)
        print(versionCode)
        print(versionName)
        print(appName)
        print(activity)
        # APK类型探测
        app_type, is_game_app = detectApk(apk_path)
        if is_game_app:
            info = '软件名称: {0}\n软件包名: {1}\n软件版本: {2} ( {3} )\n启动Activity: {4}\n该apk为游戏类型app,使用的游戏引擎为: {5}\n'.format(
                appName, package, versionName, versionCode, activity,
                ''.join(app_type))
        else:
            info = '软件名称: {0}\n软件包名: {1}\n软件版本: {2} ( {3} )\n启动Activity: {4}\n'.format(
                appName, package, versionName, versionCode, activity)
        star.log(info, infoFile)

        # 打开日志文件
        if os.path.exists(infoFile):
            star.run_cmd_asyn(['notepad', infoFile])
    return retcode, msg
Пример #3
0
def viewwrapper(file_path):
    dict = {'apkPath': file_path, 'aaptPath': PathManager.get_aapt_path()}
    apk_detect = ApkDetect(dict)
    apk_detect.getXmlInfo()
    apk_detect.getWrapperSdk()
    if apk_detect.is_netease_protect:  # 如果是网易加固,提示使用插件获取
        print(apk_detect.wrapperSdk)
        print(u'要查看网易加固版本号,您可使用插件“网易加固版本号”获取')
    else:
        print(apk_detect.wrapperSdk)
    return apk_detect.wrapperSdk, None
Пример #4
0
def plug_get_neprotect_ver(apk_path):
    version = None
    try:
        import NEProtectVerManager
        version = NEProtectVerManager.get_version(apk_path,
                                                  PathManager.get_aapt_path())
    except Exception as e:
        print(traceback.format_exc())
        os.system('pause')
        return None, None
    if version:
        print(u'当前apk使用的网易易盾加密的版本号为: ' + version)
        return version, None
    else:
        return None, None
Пример #5
0
def get_package(f):
    retcode, msg = star.runcmd2(
        [PathManager.get_aapt_path(), 'dump', 'badging', f])
    if retcode == 0:
        package = star.find("package: name='(.*?)'", msg)
    return package