Browse Source

添加游戏

DONGGUOLIANGNEW\edy 1 year ago
parent
commit
a8e1382006

+ 36 - 0
君临传奇酷派/script.py

@@ -0,0 +1,36 @@
+# coding:utf8
+
+__author__ = '极无双'
+
+import os
+from xml.etree import ElementTree as ET
+
+
+def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    fix_fake_recharge_screen_orientation_portrait(decompileDir)
+
+
+def fix_fake_recharge_screen_orientation_portrait(decompile_dir_path):
+    namespace = '{http://schemas.android.com/apk/res/android}'
+    ET._namespace_map['android'] = 'http://schemas.android.com/apk/res/android'
+
+    manifest_path = os.path.join(decompile_dir_path, 'AndroidManifest.xml')
+    xml_tree = ET.parse(manifest_path)
+    xml_root = xml_tree.getroot()
+    activity_nodes = xml_root.findall('.//activity')
+    print activity_nodes
+    for activity_node in activity_nodes:
+        print activity_node.attrib
+        activity_name = activity_node.get(namespace + 'name')
+        print activity_name
+        if 'com.cccolyun.sdkkit.gameplatform.paysdk.view.activity.CoolPaySDKActivity' == activity_name:
+            activity_node.set(namespace + 'screenOrientation', 'portrait')
+            xml_tree.write(manifest_path, encoding=u'utf-8', xml_declaration=True)
+            # break
+        # if 'com.yulong.android.paysdk.view.pay.CoolPaySDKActivity' == activity_name:
+        #     activity_node.set(namespace + 'screenOrientation', 'landscape')
+        #     xml_tree.write(manifest_path, encoding=u'utf-8', xml_declaration=True)
+
+
+if __name__ == '__main__':
+    ""

+ 15 - 115
弹弹堂大冒险酷派/script.py

@@ -11,130 +11,30 @@ 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):
+def script_last(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
+    handle_style(extract_dir)
     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-----")
-    return
-
-
-def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
-    sdk_id = channelSdkInfo['id']
-    if sdk_id == "597" :#深圳 成都都是用这个id
-        s1 = os.path.join(decompileDir, "smali_classes2","androidx")
-        if os.path.exists(s1):
-            smali_classes2_dir = create_mutil_smali(decompileDir)
-            s3 = os.path.join(smali_classes2_dir, "androidx")
-            list_package = ["fragment", "interpolator", "legacy", "lifecycle", "loader", "localbroadcastmanager"]
-            list_package.extend(
-                ["multidex", "print", "recyclerview", "slidingpanelayout", "swiperefreshlayout", "vectordrawable",
-                 "versionedparcelable", "viewpager"])
-            if not os.path.exists(s3):
-                distutils.dir_util.mkpath(s3)
-            move_package(s1, s3, list_package)
-    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
+def handle_style(decompile_dir_path):
+    style_xml_path = os.path.join(decompile_dir_path, 'res', 'values', 'styles.xml')
+    xml_tree = ET.parse(style_xml_path)
+    xml_root = xml_tree.getroot()
+    style_roots = xml_root.findall('./style')
+    for style_root in style_roots:
+        if style_root.get('name') == 'AppTheme':
+            print(style_root.get('parent'))
+            style_root.set('parent', '@style/Theme.AppCompat.Light.NoActionBar')
+            xml_tree.write(style_xml_path, encoding='utf-8', xml_declaration=True)
             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__':
+    d="D:/work/guanyu"
+    handle_style(d)
     # replace_super_application("D:\work\wzdq")
-    modify_manifest("E:\\apk\\youhua\\youhua.zip.out", "requestLegacyExternalStorage")
+    # modify_manifest("E:\\apk\\youhua\\youhua.zip.out", "requestLegacyExternalStorage")

+ 78 - 0
新盗墓笔记酷派/script.py

@@ -0,0 +1,78 @@
+# 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
+
+ANDROID_NS = 'http://schemas.android.com/apk/res/android'
+
+
+def script_last(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
+    handle_smali(extract_dir)
+    # fix_coolyun_application_getinstance_null_bug(extract_dir)
+    return
+
+
+def handle_smali(decompile_dir_path):
+    for dirpath, dirnames, filenames in os.walk(decompile_dir_path):
+        if 'com\\youzu\\gamexy' in dirpath and 'Game.smali' in filenames:
+            smali_path = os.path.join(dirpath, 'Game.smali')
+            print(smali_path)
+            f = open(smali_path, 'r')
+            smali_str_arr = f.readlines()
+            f.close()
+            for line in smali_str_arr:
+                if 'invoke-static {p0}, Lcom/youzu/gamexy/Game;->Init(Landroid/content/Context;)V' in line:
+                    logging.info("script脚本执行成功gamexy")
+                    smali_str_arr[smali_str_arr.index(
+                        line)] = '\t#invoke-static {p0}, Lcom/youzu/gamexy/Game;->Init(Landroid/content/Context;)V\n'
+            f = open(smali_path, 'w')
+            f.write(''.join(smali_str_arr))
+            f.close()
+
+def fix_coolyun_application_getinstance_null_bug(decompile_dir):
+    insert_str_list = [
+        '\n\t.locals 1\n\n',
+        '\tsget-object v0, Lcom/coolyun/framework/CoolYunApplication;->application:Landroid/content/Context;\n\n',
+        '\tcheck-cast v0, Lcom/coolyun/framework/CoolYunApplication;\n\n',
+        '\treturn-object v0\n\n']
+    for dirpath, dirnames, filenames in os.walk(decompile_dir):
+        if r'com\coolyun\framework' in dirpath and 'CoolYunApplication.smali' in filenames:
+            smali_path = os.path.join(dirpath, 'CoolYunApplication.smali')
+            with open(smali_path, 'r') as f:
+                smali_str_arr = f.readlines()
+                index_str = '.method public static getInstance()Lcom/coolyun/framework/CoolYunApplication;'
+                end_method_str = '.end method'
+                insert_str = ''.join(insert_str_list)
+                on_create_index = 0
+                insert_index = 0
+                for line in smali_str_arr:
+                    if index_str in line:
+                        on_create_index = smali_str_arr.index(line)
+                        print('on_create_index', on_create_index, line)
+                        break
+                for index, value in enumerate(smali_str_arr):
+                    if index > on_create_index and end_method_str in value:
+                        insert_index = index
+                        print('insert_index', index)
+                        break
+                print(on_create_index, insert_index)
+                del smali_str_arr[on_create_index + 1:insert_index]
+                smali_str_arr.insert(on_create_index + 1, insert_str)
+            with open(smali_path, 'w') as f:
+                f.write(''.join(smali_str_arr))
+                break
+
+if __name__ == '__main__':
+    d="D:/work/autopack3/tool/workspace/quanminpaopaochaorenkp/120/extract"
+    handle_smali(d)
+    # replace_super_application("D:\work\wzdq")
+    # modify_manifest("E:\\apk\\youhua\\youhua.zip.out", "requestLegacyExternalStorage")

+ 54 - 0
迷失星球酷派/script.py

@@ -0,0 +1,54 @@
+# coding:utf8
+
+__author__ = '极无双'
+
+import os
+import logging
+import xml.dom.minidom
+import re
+import shutil
+import glob
+
+ANDROID_NS = 'http://schemas.android.com/apk/res/android'
+from xml.etree import ElementTree as ET
+
+def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
+    fix_coolyun_application_getinstance_null_bug(decompileDir)
+    return
+
+def fix_coolyun_application_getinstance_null_bug(decompile_dir):
+    insert_str_list = [
+        '\n\t.locals 1\n\n',
+        '\tsget-object v0, Lcom/coolyun/framework/CoolYunApplication;->application:Landroid/content/Context;\n\n',
+        '\tcheck-cast v0, Lcom/coolyun/framework/CoolYunApplication;\n\n',
+        '\treturn-object v0\n\n']
+    for dirpath, dirnames, filenames in os.walk(decompile_dir):
+        if r'com\coolyun\framework' in dirpath and 'CoolYunApplication.smali' in filenames:
+            smali_path = os.path.join(dirpath, 'CoolYunApplication.smali')
+            with open(smali_path, 'r') as f:
+                smali_str_arr = f.readlines()
+                index_str = '.method public static getInstance()Lcom/coolyun/framework/CoolYunApplication;'
+                end_method_str = '.end method'
+                insert_str = ''.join(insert_str_list)
+                on_create_index = 0
+                insert_index = 0
+                for line in smali_str_arr:
+                    if index_str in line:
+                        on_create_index = smali_str_arr.index(line)
+                        print('on_create_index', on_create_index, line)
+                        break
+                for index, value in enumerate(smali_str_arr):
+                    if index > on_create_index and end_method_str in value:
+                        insert_index = index
+                        print('insert_index', index)
+                        break
+                print(on_create_index, insert_index)
+                del smali_str_arr[on_create_index + 1:insert_index]
+                smali_str_arr.insert(on_create_index + 1, insert_str)
+            with open(smali_path, 'w') as f:
+                f.write(''.join(smali_str_arr))
+                break
+
+
+if __name__ == '__main__':
+    ""