Преглед изворни кода

新增脚本 蛋仔派对酷派

dongguoliang@kuaifazs.com пре 3 година
родитељ
комит
45c52291f6

+ 137 - 0
元气骑士酷派/script.py

@@ -0,0 +1,137 @@
+# coding:utf8
+
+__author__ = 'dong'
+
+import os
+import logging
+import xml.dom.minidom
+import re
+import shutil
+import glob
+from xml.etree.ElementTree import ElementTree, Element
+import distutils.dir_util
+import gw_file_system
+import gw_data_center
+import gw_apk_tool
+
+
+def script_init(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    return
+
+
+def script_first(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    return
+
+
+def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    # logging.info('------------SDK:'+SDK)
+    # logging.info('------------decompileDir:'+decompileDir)
+    # logging.info('------------channelSdkInfo:'+str(channelSdkInfo))
+    # logging.info('------------new_game_channel_info:'+str(new_game_channel_info))
+    # logging.info('------------gameInfo:'+str(gameInfo))
+    # logging.info("------rm baidu smali------")
+    # restdir = decompileDir+"/"+"smali_classes2/com/baidu/gamesdk"
+    # if os.path.exists(restdir):
+    # shutil.rmtree(restdir)
+
+    return
+
+
+def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    sdk_id = channelSdkInfo['id']
+    if sdk_id == "549":
+        f_idx = 2
+        while True:
+            tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+            tmp = tmp.replace('\\', '/')
+            tmp = re.sub('/+', '/', tmp)
+            androidx = tmp + '/bitter'
+
+            if os.path.exists(androidx):
+                new_dex_dir = create_mutil_smali(decompileDir)
+                move_package(tmp, new_dex_dir, ["bitter","cn"])
+                break
+
+            if not os.path.exists(tmp):
+                break
+
+            f_idx += 1
+    return
+
+
+def create_mutil_smali(decompileDir):
+    f_idx = 2
+    while True:
+        tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+        tmp = tmp.replace('\\', '/')
+        tmp = re.sub('/+', '/', tmp)
+        if os.path.exists(tmp):
+            f_idx += 1
+        else:
+            smali_classes2_dir = tmp
+            break
+    # endwhile
+    os.mkdir(smali_classes2_dir)
+    return smali_classes2_dir
+
+
+def move_package(s1, s3, list_package):
+    for d in list_package:
+        src = os.path.join(s1, d)
+        if os.path.exists(src):
+            dst = os.path.join(s3, d)
+            distutils.dir_util.copy_tree(src, dst)
+            distutils.dir_util.remove_tree(src)
+
+
+def is_reverse_qihoo(file):
+    with open(file, 'r+') as f:
+        file_str = f.read()
+        if 'KFSDK' in file_str:
+            return True
+        else:
+            return False
+
+
+def replace_init_code(decompileDir):
+    smali_files = glob.glob(os.path.join(decompileDir, 'smali*/com/qihoo/'))
+    if len(smali_files) >= 1:
+        iter_smali = iter(smali_files)
+        while True:
+            try:
+                qihoo_file_path = iter_smali.next()
+                file = os.path.join(qihoo_file_path, 'gamecenter/sdk/matrix/Matrix.smali')
+                if os.path.exists(file):
+                    logging.info('Matrix exits in %s' % qihoo_file_path)
+                    if is_reverse_qihoo(file):
+                        with open(file, 'r+') as f:
+                            cont = f.read()
+                            change_str = '0x82c'
+                            str = '0x82b'
+                            cont = cont.replace(change_str, str)
+                            logging.info('replace_str: ' + cont)
+                        with open(file, 'w+') as tf:
+                            tf.write(cont)
+
+            except StopIteration:
+                break
+
+
+def replace_application(extract_dir):
+    goal_file = os.path.join(extract_dir, 'smali_classes3/com/lilithgame/sgame/wxapi/QihooApplication.smali')
+    print(os.path.isfile(goal_file))
+    if os.path.isfile(goal_file):
+        logging.info('method_proceed: ' + 'goal_file')
+        print(goal_file)
+        with open(goal_file, 'r+') as f:
+            cont = f.read()
+            change_str = 'Landroid/support/multidex/MultiDexApplication'
+            str = 'Lcom/kf/framework/KFApplication'
+            cont = cont.replace(change_str, str)
+            logging.info('replace_str: ' + cont)
+        with open(goal_file, 'w+') as tf:
+            tf.write(cont)
+
+
+if __name__ == '__main__':
+    replace_init_code("D:\work\lyjymb")

+ 139 - 0
斗罗大陆酷派/script.py

@@ -0,0 +1,139 @@
+# coding:utf8
+
+__author__ = 'dong'
+
+import os
+import logging
+import xml.dom.minidom
+import re
+import shutil
+import glob
+from xml.etree.ElementTree import ElementTree, Element
+import distutils.dir_util
+from xml.etree import ElementTree as ET
+import gw_file_system
+
+ANDROID_NS = 'http://schemas.android.com/apk/res/android'
+
+
+def script_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
+    logging.info('script_second: ' + str(channel_sdk_info))
+    # 逆向渠道id
+    public_xml = os.path.join(extract_dir, "res/values/public.xml")
+    handle_public_xml(public_xml, "attr-private")
+    # handle_public_xml(public_xml, "sobot_fileEndingExcel")
+    # handle_public_xml(public_xml, "sobot_fileEndingImage")
+    # handle_public_xml(public_xml, "sobot_fileEndingPPT")
+    # handle_public_xml(public_xml, "sobot_fileEndingPackage")
+    # handle_public_xml(public_xml, "sobot_fileEndingPdf")
+    # handle_public_xml(public_xml, "sobot_fileEndingText")
+    # handle_public_xml(public_xml, "sobot_fileEndingVideo")
+    # handle_public_xml(public_xml, "sobot_fileEndingWord")
+
+    return
+
+
+def handle_public_xml(public_xml_path, remove_node):
+    if not os.path.exists(public_xml_path):
+        logging.info('public_xml is null: ' + public_xml_path)
+        return
+    new_lines = []
+    with open(public_xml_path, 'r+') as f:
+        for line in f.readlines():
+            # l = line.strip()
+            if line.find(remove_node) > -1:
+                continue
+            new_lines.append(line)
+        f.seek(0)
+        f.truncate()
+        f.writelines(new_lines)
+    return
+
+
+def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    logging.info("-----debug-----")
+
+
+def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    return
+
+
+def create_mutil_smali(decompileDir):
+    f_idx = 2
+    while True:
+        tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+        tmp = tmp.replace('\\', '/')
+        tmp = re.sub('/+', '/', tmp)
+        if os.path.exists(tmp):
+            f_idx += 1
+        else:
+            smali_classes2_dir = tmp
+            break
+    # endwhile
+    os.mkdir(smali_classes2_dir)
+    return smali_classes2_dir
+
+
+def move_package(s1, s3, list_package):
+    for d in list_package:
+        src = os.path.join(s1, d)
+        if os.path.exists(src):
+            dst = os.path.join(s3, d)
+            distutils.dir_util.copy_tree(src, dst)
+            distutils.dir_util.remove_tree(src)
+
+
+def move_package_one(src, dst):
+    if os.path.exists(src):
+        distutils.dir_util.copy_tree(src, dst)
+        distutils.dir_util.remove_tree(src)
+
+
+change_map = {".super Landroid/app/Application;": ".super Lcom/kf/framework/KFApplication;",
+              "invoke-direct {p0}, Landroid/app/Application;-><init>()V": "invoke-direct {p0}, Lcom/kf/framework/KFApplication;-><init>()V",
+              "invoke-super {p0, p1}, Landroid/app/Application;->attachBaseContext(Landroid/content/Context;)V": "invoke-super {p0, p1}, Lcom/kf/framework/KFApplication;->attachBaseContext(Landroid/content/Context;)V",
+              "invoke-super {p0}, Landroid/app/Application;->onCreate()V": "invoke-super {p0}, Lcom/kf/framework/KFApplication;->onCreate()V", }
+
+
+def replace_super_application(decompileDir):
+    smali_files = glob.glob(
+        os.path.join(decompileDir, 'smali*/com/radical/huangshangjixiang/qh360/CoronaApplication.smali'))
+    if len(smali_files) == 1:
+        game_application_file = smali_files[0];
+        print game_application_file
+        if os.path.isfile(game_application_file):
+            with open(game_application_file, "r+") as f:
+                file_str = f.read()
+                for k, v in change_map.items():
+                    file_str = file_str.replace(k, v)
+            with open(game_application_file, "w+") as f:
+                f.write(file_str)
+
+
+def modify_manifest(decompileDir, removeKey):
+    ET.register_namespace('android', ANDROID_NS)
+    xmlparse = os.path.join(decompileDir, 'AndroidManifest.xml')
+    root_node = ET.parse(xmlparse)
+    root = root_node.getroot()
+    name = '{' + ANDROID_NS + '}name'
+    authorities = '{' + ANDROID_NS + '}' + removeKey
+    package_name = root.attrib.get('package')
+    if package_name == None:
+        return
+    providers = root.findall('./application')
+    if providers != None:
+        for provider in providers:
+            # providerName = provider.attrib.get(name)
+            # if 'com.netease.ntunisdk.CcMomentRecordingForegroundService' == providerName:
+            # 使用try 主要是为了 防止此属性不在时,导致的错误,而程序终止
+            try:
+                del provider.attrib[authorities]
+            except:
+                ""
+
+    root_node.write(xmlparse, 'utf-8')
+
+
+if __name__ == '__main__':
+    # replace_super_application("D:\work\wzdq")
+    modify_manifest("E:\\apk\\youhua\\youhua.zip.out", "requestLegacyExternalStorage")

+ 35 - 0
率土之滨酷派/script.py

@@ -24,6 +24,7 @@ def script_init(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameIn
         gw_data_center.pack_small = False
         gw_apk_tool.__apk_tool__ = 'apktool_2.6.0.jar'
 
+
 def script_first(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
     return
 
@@ -43,6 +44,40 @@ def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
 
 
 def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    sdk_id = channelSdkInfo['id']
+    if sdk_id == "597":
+        f_idx = 2
+        while True:
+            tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+            tmp = tmp.replace('\\', '/')
+            tmp = re.sub('/+', '/', tmp)
+            androidx = tmp + '/androidx'
+
+            if os.path.exists(androidx):
+                new_dex_dir = create_mutil_smali(decompileDir)
+                move_package(tmp, new_dex_dir, ["androidx"])
+            if not os.path.exists(tmp):
+                break
+
+            f_idx += 1
+        # endwhile
+    if sdk_id == "549":
+        f_idx = 5
+        # while True:
+        tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+        tmp = tmp.replace('\\', '/')
+        tmp = re.sub('/+', '/', tmp)
+        androidx = tmp + '/com/netease'
+
+        if os.path.exists(androidx):
+            new_dex_dir = create_mutil_smali(decompileDir)
+            dst = new_dex_dir + '/com/netease'
+            move_package(androidx, dst, ["pharos", "stzb", "unisdk"])
+            # break
+
+        # if not os.path.exists(tmp):
+        # break
+
     return
 
 

BIN
率土之滨酷派/script.pyc


BIN
率土之滨酷派/率土之滨酷派.zip


+ 90 - 0
芒果斗地主酷派/script.py

@@ -0,0 +1,90 @@
+# coding:utf8
+
+__author__ = 'dong'
+
+import os
+import logging
+import xml.dom.minidom
+import re
+import shutil
+import glob
+import distutils.dir_util
+import os
+# import gw_apk_tool
+from xml.etree import ElementTree as ET
+
+ANDROID_NS = 'http://schemas.android.com/apk/res/android'
+
+
+def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
+    if channelSdkInfo['id'] == '597':
+        logging.info("remove_navigate")
+        remove_navigate(decompileDir)
+
+        public_xml = os.path.join(decompileDir, "res/layout/activity_live_login.xml")
+        handle_public_xml(public_xml, "navGraph")
+        handle_public_xml(public_xml, "nav_main")
+
+        # android_manifest_xml = os.path.join(decompileDir, "AndroidManifest.xml")
+        # handle_public_xml(android_manifest_xml, "allowNativeHeapPointerTagging")
+
+        # modify_manifest_common(decompileDir, "allowNativeHeapPointerTagging")
+
+
+def remove_navigate(decompileDir):
+    tmp_res = os.path.join(decompileDir, "res", "navigation")
+    tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
+    if os.path.exists(tmp_res):
+        distutils.dir_util.remove_tree(tmp_res)
+    if os.path.exists(tmp_public_xml):
+        os.remove(tmp_public_xml)
+
+
+def handle_public_xml(public_xml_path, remove_node):
+    if not os.path.exists(public_xml_path):
+        logging.info('public_xml is null: ' + public_xml_path)
+        return
+    new_lines = []
+    with open(public_xml_path, 'r+') as f:
+        for line in f.readlines():
+            # l = line.strip()
+            if line.find(remove_node) > -1:
+                continue
+            new_lines.append(line)
+        f.seek(0)
+        f.truncate()
+        f.writelines(new_lines)
+    return
+
+
+def modify_manifest_common(decompileDir, removeKey):
+    ET.register_namespace('android', ANDROID_NS)
+    xmlparse = os.path.join(decompileDir, 'AndroidManifest.xml')
+    logging.info(xmlparse)
+    root_node = ET.parse(xmlparse)
+    root = root_node.getroot()
+    name = '{' + ANDROID_NS + '}name'
+    authorities = '{' + ANDROID_NS + '}' + removeKey
+    package_name = root.attrib.get('package')
+    if package_name == None:
+        return
+    providers = root.findall('./application')
+    if providers != None:
+        for provider in providers:
+            # providerName = provider.attrib.get(name)
+            # if 'com.netease.ntunisdk.CcMomentRecordingForegroundService' == providerName:
+            # 使用try 主要是为了 防止此属性不在时,导致的错误,而程序终止
+            try:
+                del provider.attrib[authorities]
+            except:
+                ""
+
+    root_node.write(xmlparse, 'utf-8')
+
+
+if __name__ == '__main__':
+    # del_qihoo("C:\\Users\\Administrator\\Desktop\\zt")
+    # remove_navigate("G:\\autopack2.0_kuaifa\\tool\\workspace\\lrs360\\13651\\extract")
+    modify_manifest_common("E:\\apk\\youhua\\HXHLGKzX7ZgyxZ0RcZ61RDnnhVCPpfxG",
+                           "allowNativeHeapPointerTagging")

+ 152 - 0
蛋仔派对酷派/script.py

@@ -0,0 +1,152 @@
+# coding:utf8
+
+__author__ = 'dong'
+
+import os
+import logging
+import xml.dom.minidom
+import re
+import shutil
+import glob
+from xml.etree.ElementTree import ElementTree, Element
+import distutils.dir_util
+import gw_file_system
+import gw_data_center
+import gw_apk_tool
+
+
+def script_init(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    return
+
+
+def script_first(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    return
+
+
+def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    # logging.info('------------SDK:'+SDK)
+    # logging.info('------------decompileDir:'+decompileDir)
+    # logging.info('------------channelSdkInfo:'+str(channelSdkInfo))
+    # logging.info('------------new_game_channel_info:'+str(new_game_channel_info))
+    # logging.info('------------gameInfo:'+str(gameInfo))
+    # logging.info("------rm baidu smali------")
+    # restdir = decompileDir+"/"+"smali_classes2/com/baidu/gamesdk"
+    # if os.path.exists(restdir):
+    # shutil.rmtree(restdir)
+
+    return
+
+
+def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    sdk_name = channelSdkInfo['sdk_name']
+    if sdk_name == "reverseforachannel_ydzs":
+        s1 = os.path.join(decompileDir, "smali_classes4")
+        if os.path.exists(s1):
+            smali_classes2_dir = create_mutil_smali(decompileDir)
+            s3 = smali_classes2_dir
+            if not os.path.exists(s3):
+                distutils.dir_util.mkpath(s3)
+            move_package(s1, s3, ["androidx", "android"])
+
+        s1 = os.path.join(decompileDir, "smali_classes4", "com")
+        if os.path.exists(s1):
+            smali_classes2_dir = create_mutil_smali(decompileDir)
+            s3 = os.path.join(smali_classes2_dir, "com")
+            if not os.path.exists(s3):
+                distutils.dir_util.mkpath(s3)
+            move_package_one(s1, s3)
+
+    return
+
+
+def create_mutil_smali(decompileDir):
+    f_idx = 2
+    while True:
+        tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
+        tmp = tmp.replace('\\', '/')
+        tmp = re.sub('/+', '/', tmp)
+        if os.path.exists(tmp):
+            f_idx += 1
+        else:
+            smali_classes2_dir = tmp
+            break
+    # endwhile
+    os.mkdir(smali_classes2_dir)
+    return smali_classes2_dir
+
+
+def move_package(s1, s3, list_package):
+    for d in list_package:
+        src = os.path.join(s1, d)
+        if os.path.exists(src):
+            dst = os.path.join(s3, d)
+            distutils.dir_util.copy_tree(src, dst)
+            distutils.dir_util.remove_tree(src)
+
+
+def is_reverse_qihoo(file):
+    with open(file, 'r+') as f:
+        file_str = f.read()
+        if 'KFSDK' in file_str:
+            return True
+        else:
+            return False
+
+
+def replace_init_code(decompileDir):
+    smali_files = glob.glob(os.path.join(decompileDir, 'smali*/com/qihoo/'))
+    if len(smali_files) >= 1:
+        iter_smali = iter(smali_files)
+        while True:
+            try:
+                qihoo_file_path = iter_smali.next()
+                file = os.path.join(qihoo_file_path, 'gamecenter/sdk/matrix/Matrix.smali')
+                if os.path.exists(file):
+                    logging.info('Matrix exits in %s' % qihoo_file_path)
+                    if is_reverse_qihoo(file):
+                        with open(file, 'r+') as f:
+                            cont = f.read()
+                            change_str = '0x82c'
+                            str = '0x82b'
+                            cont = cont.replace(change_str, str)
+                            logging.info('replace_str: ' + cont)
+                        with open(file, 'w+') as tf:
+                            tf.write(cont)
+
+            except StopIteration:
+                break
+
+
+def replace_application(extract_dir):
+    goal_file = os.path.join(extract_dir, 'smali_classes3/com/lilithgame/sgame/wxapi/QihooApplication.smali')
+    print(os.path.isfile(goal_file))
+    if os.path.isfile(goal_file):
+        logging.info('method_proceed: ' + 'goal_file')
+        print(goal_file)
+        with open(goal_file, 'r+') as f:
+            cont = f.read()
+            change_str = 'Landroid/support/multidex/MultiDexApplication'
+            str = 'Lcom/kf/framework/KFApplication'
+            cont = cont.replace(change_str, str)
+            logging.info('replace_str: ' + cont)
+        with open(goal_file, 'w+') as tf:
+            tf.write(cont)
+
+
+def move_package(s1, s3, list_package):
+    for d in list_package:
+        src = os.path.join(s1, d)
+        if os.path.exists(src):
+            dst = os.path.join(s3, d)
+            distutils.dir_util.copy_tree(src, dst)
+            distutils.dir_util.remove_tree(src)
+
+
+def move_package_one(src, dst):
+    if os.path.exists(src):
+        distutils.dir_util.copy_tree(src, dst)
+        distutils.dir_util.remove_tree(src)
+
+
+if __name__ == '__main__':
+    replace_init_code("D:\work\lyjymb")