DONGGUOLIANGNEW\edy il y a 1 an
Parent
commit
3b5d5f4526
3 fichiers modifiés avec 166 ajouts et 121 suppressions
  1. 0 25
      smallsheep/apktool.yml
  2. 17 96
      smallsheep/script.py
  3. 149 0
      蚁族崛起/script.py

+ 0 - 25
smallsheep/apktool.yml

@@ -1,25 +0,0 @@
-apkFileName: game.apk
-compressionType: false
-doNotCompress:
-- resources.arsc
-- png
-- assets/ABfile/Android/buildversion.txt
-isFrameworkApk: false
-packageInfo:
-  forcedPackageId: '127'
-  renameManifestPackage: null
-sdkInfo:
-  minSdkVersion: '19'
-  targetSdkVersion: '28'
-sharedLibrary: false
-sparseResources: false
-unknownFiles:
-  androidsupportmultidexversion.txt: '0'
-usesFramework:
-  ids:
-  - 1
-  tag: null
-version: 2.6.0
-versionInfo:
-  versionCode: '1'
-  versionName: 0.0.201.225

+ 17 - 96
smallsheep/script.py

@@ -20,98 +20,6 @@ def change_application_id(extra_dir, packageName):
         f.write(cont)
         f.close()
 
-def fix_xmy_recharge_screen_orientation(decompile_dir_path):
-    developer_path = os.path.join(decompile_dir_path, 'assets', 'developer.properties')
-    print(developer_path)
-    is_landscape = True
-    with open(developer_path, 'r') as f:
-        smali_str_arr = f.readlines()
-        for line in smali_str_arr:
-            if 'screen_oriention' in line:
-                results = re.findall(re.compile(r'\d'), line)
-                if len(results) != 0:
-                    orientation_value = results[0]
-                    print('orientation_value', orientation_value)
-                    is_landscape = int(orientation_value) == 0
-                    break
-    print('is_landscape', is_landscape)
-    if not is_landscape:
-        return
-    namespace = '{http://schemas.android.com/apk/res/android}'
-    ET.register_namespace('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('%sname' % namespace)
-        print(activity_name)
-        if 'com.yog.kothoth.view.activity.SSRechargeActivity' == activity_name:
-            activity_node.set('%sscreenOrientation' % namespace, 'landscape')
-            xml_tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
-            break
-
-def fix_install_fail_bug(decompile_dir_path):
-    namespace = '{http://schemas.android.com/apk/res/android}'
-    ET.register_namespace('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()
-    application_node = xml_root.find('./application')
-    etract_value = application_node.get('%sextractNativeLibs' % namespace)
-    if etract_value is not None and etract_value == 'false':
-        # 修改extractNativeLib
-        application_node.set('%sextractNativeLibs' % namespace, 'true')
-        xml_tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
-
-    yaml_path = os.path.join(decompile_dir_path, 'apktool.yml')
-    file = open(yaml_path, 'r')
-    yaml_result = yaml.load(file, Loader=yaml.BaseLoader)
-    sdk_info = yaml_result['sdkInfo']
-    yaml_result['packageInfo']['renameManifestPackage'] = None
-    print(sdk_info)
-    if sdk_info.has_key('targetSdkVersion') and int(sdk_info['targetSdkVersion']) > 29:
-        sdk_info['targetSdkVersion'] = '29'
-        print(sdk_info)
-        file.close()
-        with open(yaml_path, 'w') as f:
-            # yaml.dump(yaml_result, f)
-            yaml.safe_dump(yaml_result, f,allow_unicode=True, default_flow_style=False)
-
-
-def fix_android8_bug_xmy(decompile_dir):
-    style_xml_path = os.path.join(decompile_dir, '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') == 'kf_splash_translucent':
-            items = style_root.findall('./item')
-            for item in items:
-                print('item name', item.get('name'))
-                print(item.findtext('.'))
-                if item.get('name') == 'android:windowIsTranslucent':
-                    item.text = 'false'
-            xml_tree.write(style_xml_path, encoding='utf-8', xml_declaration=True)
-            break
-    namespace = '{http://schemas.android.com/apk/res/android}'
-    ET.register_namespace('android', 'http://schemas.android.com/apk/res/android')
-    manifest_path = os.path.join(decompile_dir, 'AndroidManifest.xml')
-    xml_tree = ET.parse(manifest_path)
-    xml_root = xml_tree.getroot()
-    act_list = xml_root.findall('.//activity')
-    for act in act_list:
-        act_name = act.get('%sname' % namespace)
-        print(act_name)
-        if 'com.yog.kothoth.view.activity.SSShoppingMallActivity' == act_name or 'com.yog.kothoth.view.activity.SSRechargeActivity' == act_name:
-            act_theme = act.get('%stheme' % namespace)
-            print('act_theme', act_theme)
-            act.set('%stheme' % namespace, '@style/kf_splash_translucent')
-            xml_tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
-            break
-
 
 def script(work_sdk_dir, extra_dir, channel_sdk_info, new_game_channel_info, game_info):
     logging.info("---------------channel_sdk_info-------------")
@@ -122,9 +30,22 @@ def script(work_sdk_dir, extra_dir, channel_sdk_info, new_game_channel_info, gam
     logging.info(game_info)
     applicationId = channel_sdk_info["packNameSuffix"]
     change_application_id(extra_dir, applicationId)
-    fix_install_fail_bug(extra_dir)
-    fix_xmy_recharge_screen_orientation(extra_dir)
-    fix_android8_bug_xmy(extra_dir)
+    fix_kf_kuyun(extra_dir)
+
+def fix_kf_kuyun(decompile_dir):
+    for dirpath, dirnames, filenames in os.walk(decompile_dir):
+        # if ur'com\yog\kothoth\\utils' in dirpath and u'RealnameCheckor.smali' in filenames:
+            auth_listener_path = os.path.join(decompile_dir,"smali","com","yog","kothoth","utils",'RealnameCheckor.smali')
+            with open(auth_listener_path, 'r') as f:
+                content = f.read()
+            new_content = content.replace('com.kf.framework', 'com.kuyun.framewor')
+
+            if new_content == content:
+                print "no found"
+                return
+            with open(auth_listener_path, 'w') as f:
+                f.write(new_content)
 
 if __name__ == '__main__':
-    script("", ".", {'package_name':'com.netease.dwrg.yl.ludashi'}, {}, {})
+    # script("", ".", {'package_name':'com.netease.dwrg.yl.ludashi'}, {}, {})
+    fix_kf_kuyun("D:/work/autopack3/tool/outputGame/admin@163.com/nslm2/nslm2_311")

+ 149 - 0
蚁族崛起/script.py

@@ -0,0 +1,149 @@
+# 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
+import gw_data_center
+
+ANDROID_NS = 'http://schemas.android.com/apk/res/android'
+
+def script_init(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
+    # gw_data_center.pack_small=True
+    return
+
+def script_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
+    # 逆向渠道id
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "dependency_ordering")
+
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "graph")
+
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "cache_measures")
+
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "graph_wrap")
+
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "grouping")
+
+        public_xml = os.path.join(extract_dir, "res/values/public.xml")
+        handle_public_xml(public_xml, "ratio")
+        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")