|
|
@@ -0,0 +1,358 @@
|
|
|
+#!/usr/bin/python
|
|
|
+# -*- coding: UTF-8 -*-
|
|
|
+
|
|
|
+import os
|
|
|
+import re
|
|
|
+import shutil
|
|
|
+import sys
|
|
|
+import xml.etree.ElementTree as ET
|
|
|
+
|
|
|
+import yaml
|
|
|
+
|
|
|
+print("全民泡泡超人Y-小绵羊")
|
|
|
+print(sys.argv)
|
|
|
+decompile_dir_path = sys.argv[1]
|
|
|
+print(decompile_dir_path)
|
|
|
+
|
|
|
+# def decode_yb_and_del_v4_and_copy_yb_res_and_modify_colors_v31():
|
|
|
+# game_dir = sys.argv[2]
|
|
|
+# yb_decode_path = r'D:\work\game_yb'
|
|
|
+# game_name = ''
|
|
|
+# if not os.path.exists(yb_decode_path):
|
|
|
+# for name in os.listdir(game_dir):
|
|
|
+# if '小绵羊' not in name and '朱雀' not in name and '九狐' not in name:
|
|
|
+# game_name = name
|
|
|
+# print(game_name)
|
|
|
+# if game_name == '':
|
|
|
+# raise Exception('让客服放入原包')
|
|
|
+# yb_path = os.path.join(game_dir, game_name)
|
|
|
+# print(yb_path)
|
|
|
+# cmd_decode_yb = f'apktool d {yb_path} -f -o {yb_decode_path} --only-main-classes'
|
|
|
+# os.system(cmd_decode_yb)
|
|
|
+# else:
|
|
|
+# print('yb_decode_path is exists', yb_decode_path)
|
|
|
+# # 用原包中的abc_screen_simple、abc_screen_content_include、abc_action_menu_item_layout.xml替换小绵包中的
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_simple.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_content_include.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_action_menu_item_layout.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+#
|
|
|
+# yb_public_path = os.path.join(yb_decode_path, "res", "values", "public.xml")
|
|
|
+# build_public_path = os.path.join(decompile_dir_path, "res", "values", "public.xml")
|
|
|
+# cmd_run_refresh_resource = rf'python F:\python_learn\day_1\learn\refresh_resource_qmpp.py {yb_public_path} {build_public_path} {decompile_dir_path}'
|
|
|
+# print(cmd_run_refresh_resource)
|
|
|
+# os.system(cmd_run_refresh_resource)
|
|
|
+#
|
|
|
+# shutil.rmtree(yb_decode_path)
|
|
|
+
|
|
|
+def decode_yb_and_del_v4_and_copy_yb_res_and_modify_colors_v31():
|
|
|
+ game_dir = sys.argv[2]
|
|
|
+ yb_decode_path = r'D:\work\game_yb_xmy'
|
|
|
+ aapt2_output_dir = r'D:\work\output'
|
|
|
+ game_name = ''
|
|
|
+ for name in os.listdir(game_dir):
|
|
|
+ if '小绵羊' not in name and '朱雀' not in name and '九狐' not in name and 'FAKE' not in name:
|
|
|
+ game_name = name
|
|
|
+ print(game_name)
|
|
|
+ if game_name == '':
|
|
|
+ raise Exception('让客服放入原包')
|
|
|
+ yb_path = os.path.join(game_dir, game_name)
|
|
|
+ print(yb_path)
|
|
|
+ cmd_decode_yb = f'apktool d {yb_path} -f -o {yb_decode_path} --only-main-classes'
|
|
|
+ os.system(cmd_decode_yb)
|
|
|
+ # 用原包中的abc_screen_simple、abc_screen_content_include、abc_action_menu_item_layout.xml替换小绵包中的
|
|
|
+ shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_simple.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+ shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_content_include.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+ shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_action_menu_item_layout.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+ # 将原包中的values-v31和color-v31拷贝到xmy\res目录下
|
|
|
+ # shutil.copytree(os.path.join(yb_decode_path,'res','color-v31'),os.path.join(decompile_dir_path,'res','color-v31'))
|
|
|
+ # shutil.copytree(os.path.join(yb_decode_path,'res','values-v31'),os.path.join(decompile_dir_path,'res','values-v31'))
|
|
|
+ #删除drawable-v4、mipmap-v4等含有v4的文件夹
|
|
|
+ for res_dir_name in os.listdir(os.path.join(decompile_dir_path, 'res')):
|
|
|
+ if 'v4' in res_dir_name and ('drawable' in res_dir_name or 'mipmap' in res_dir_name):
|
|
|
+ drawable_v4_path = os.path.join(decompile_dir_path, 'res', res_dir_name)
|
|
|
+ print('delete:', drawable_v4_path)
|
|
|
+ shutil.rmtree(drawable_v4_path)
|
|
|
+ #
|
|
|
+ # colors_xml_path = os.path.join(decompile_dir_path, 'res', 'values-v31', 'colors.xml')
|
|
|
+ # xml_tree = ET.parse(colors_xml_path)
|
|
|
+ # xml_root = xml_tree.getroot()
|
|
|
+ # color_roots = xml_root.findall('./color')
|
|
|
+ # for style_root in color_roots:
|
|
|
+ # style_root.text = '@android:color/white'
|
|
|
+ # xml_tree.write(colors_xml_path, encoding='utf-8', xml_declaration=True)
|
|
|
+
|
|
|
+ if not os.path.exists(aapt2_output_dir):
|
|
|
+ os.makedirs(aapt2_output_dir)
|
|
|
+ print("make dir:", aapt2_output_dir)
|
|
|
+ # aapt2不支持中文路径,拷贝渠道包res到output
|
|
|
+ shutil.copytree(os.path.join(decompile_dir_path, "res"), os.path.join(aapt2_output_dir, "res"))
|
|
|
+ # 重新编译资源
|
|
|
+ channel_apk_res_path = os.path.join(aapt2_output_dir, "res")
|
|
|
+ aapt2_res_zip_path = os.path.join(aapt2_output_dir, "res.zip")
|
|
|
+ cmd_aapt2_compile = rf'F:\Android\as_sdk\build-tools\30.0.2\aapt2.exe compile --dir {channel_apk_res_path} -o {aapt2_res_zip_path} -v'
|
|
|
+ print(cmd_aapt2_compile)
|
|
|
+ os.system(cmd_aapt2_compile)
|
|
|
+ aapt2_apk_path = os.path.join(aapt2_output_dir, "aapt.apk")
|
|
|
+ cmd_aapt2_link = rf'F:\Android\as_sdk\build-tools\30.0.2\aapt2.exe link {aapt2_res_zip_path} -I F:\Android\as_sdk\platforms\android-30\android.jar -o {aapt2_apk_path} --manifest {os.path.join(decompile_dir_path, "AndroidManifest.xml")} -v'
|
|
|
+ print(cmd_aapt2_link)
|
|
|
+ os.system(cmd_aapt2_link)
|
|
|
+ cmd_decode_output_apk = rf'apktool d {os.path.join(aapt2_output_dir, "aapt.apk")} -f -o {os.path.join(aapt2_output_dir, "aapt")} --only-main-classes'
|
|
|
+ print(cmd_decode_output_apk)
|
|
|
+ os.system(cmd_decode_output_apk)
|
|
|
+
|
|
|
+ yb_public_path = os.path.join(yb_decode_path, "res", "values", "public.xml")
|
|
|
+ build_public_path = os.path.join(aapt2_output_dir, "aapt", "res", "values", "public.xml")
|
|
|
+ apk_path = decompile_dir_path
|
|
|
+ cmd_run_refresh_resource = rf'python F:\python_learn\day_1\learn\refresh_resource_qmpp_rose.py {yb_public_path} {build_public_path} {apk_path}'
|
|
|
+ print(cmd_run_refresh_resource)
|
|
|
+ os.system(cmd_run_refresh_resource)
|
|
|
+ shutil.copy(build_public_path, os.path.join(decompile_dir_path, "res", "values"))
|
|
|
+
|
|
|
+ shutil.rmtree(aapt2_output_dir)
|
|
|
+ shutil.rmtree(yb_decode_path)
|
|
|
+
|
|
|
+# def decode_yb_and_del_v4_and_copy_yb_res_and_modify_colors_v31():
|
|
|
+# game_dir = sys.argv[2]
|
|
|
+# yb_decode_path = r'D:\work\game_yb'
|
|
|
+# aapt2_output_dir = r'D:\work\output'
|
|
|
+# game_name = ''
|
|
|
+# for name in os.listdir(game_dir):
|
|
|
+# if '小绵羊' not in name and '朱雀' not in name:
|
|
|
+# game_name = name
|
|
|
+# print(game_name)
|
|
|
+# if game_name == '':
|
|
|
+# raise Exception('让客服放入原包')
|
|
|
+# yb_path = os.path.join(game_dir, game_name)
|
|
|
+# print(yb_path)
|
|
|
+# cmd_decode_yb = f'apktool d {yb_path} -f -o {yb_decode_path} --only-main-classes'
|
|
|
+# os.system(cmd_decode_yb)
|
|
|
+# # 用原包中的abc_screen_simple、abc_screen_content_include、abc_action_menu_item_layout.xml替换小绵包中的
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_simple.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_screen_content_include.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+# shutil.copy(os.path.join(yb_decode_path, "res", 'layout', 'abc_action_menu_item_layout.xml'), os.path.join(decompile_dir_path, "res", 'layout'))
|
|
|
+# # 将原包中的values-v31和color-v31拷贝到xmy\res目录下
|
|
|
+# shutil.copytree(os.path.join(yb_decode_path,'res','color-v31'),os.path.join(decompile_dir_path,'res','color-v31'))
|
|
|
+# shutil.copytree(os.path.join(yb_decode_path,'res','values-v31'),os.path.join(decompile_dir_path,'res','values-v31'))
|
|
|
+# #删除drawable-v4、mipmap-v4等含有v4的文件夹
|
|
|
+# for res_dir_name in os.listdir(os.path.join(decompile_dir_path, 'res')):
|
|
|
+# if 'v4' in res_dir_name and ('drawable' in res_dir_name or 'mipmap' in res_dir_name):
|
|
|
+# drawable_v4_path = os.path.join(decompile_dir_path, 'res', res_dir_name)
|
|
|
+# print('delete:', drawable_v4_path)
|
|
|
+# shutil.rmtree(drawable_v4_path)
|
|
|
+# #
|
|
|
+# colors_xml_path = os.path.join(decompile_dir_path, 'res', 'values-v31', 'colors.xml')
|
|
|
+# xml_tree = ET.parse(colors_xml_path)
|
|
|
+# xml_root = xml_tree.getroot()
|
|
|
+# color_roots = xml_root.findall('./color')
|
|
|
+# for style_root in color_roots:
|
|
|
+# style_root.text = '@android:color/white'
|
|
|
+# xml_tree.write(colors_xml_path, encoding='utf-8', xml_declaration=True)
|
|
|
+#
|
|
|
+# if not os.path.exists(aapt2_output_dir):
|
|
|
+# os.makedirs(aapt2_output_dir)
|
|
|
+# print("make dir:", aapt2_output_dir)
|
|
|
+# # aapt2不支持中文路径,拷贝渠道包res到output
|
|
|
+# shutil.copytree(os.path.join(decompile_dir_path, "res"), os.path.join(aapt2_output_dir, "res"))
|
|
|
+# # 重新编译资源
|
|
|
+# channel_apk_res_path = os.path.join(aapt2_output_dir, "res")
|
|
|
+# aapt2_res_zip_path = os.path.join(aapt2_output_dir, "res.zip")
|
|
|
+# cmd_aapt2_compile = rf'F:\Android\as_sdk\build-tools\30.0.2\aapt2.exe compile --dir {channel_apk_res_path} -o {aapt2_res_zip_path} -v'
|
|
|
+# print(cmd_aapt2_compile)
|
|
|
+# os.system(cmd_aapt2_compile)
|
|
|
+# aapt2_apk_path = os.path.join(aapt2_output_dir, "aapt.apk")
|
|
|
+# cmd_aapt2_link = rf'F:\Android\as_sdk\build-tools\30.0.2\aapt2.exe link {aapt2_res_zip_path} -I F:\Android\as_sdk\platforms\android-30\android.jar -o {aapt2_apk_path} --manifest {os.path.join(decompile_dir_path, "AndroidManifest.xml")} -v'
|
|
|
+# print(cmd_aapt2_link)
|
|
|
+# os.system(cmd_aapt2_link)
|
|
|
+# cmd_decode_output_apk = rf'apktool d {os.path.join(aapt2_output_dir, "aapt.apk")} -f -o {os.path.join(aapt2_output_dir, "aapt")} --only-main-classes'
|
|
|
+# print(cmd_decode_output_apk)
|
|
|
+# os.system(cmd_decode_output_apk)
|
|
|
+#
|
|
|
+# yb_public_path = os.path.join(yb_decode_path, "res", "values", "public.xml")
|
|
|
+# build_public_path = os.path.join(aapt2_output_dir, "aapt", "res", "values", "public.xml")
|
|
|
+# apk_path = decompile_dir_path
|
|
|
+# cmd_run_refresh_resource = rf'python F:\python_learn\day_1\learn\refresh_resource.py {yb_public_path} {build_public_path} {apk_path}'
|
|
|
+# print(cmd_run_refresh_resource)
|
|
|
+# os.system(cmd_run_refresh_resource)
|
|
|
+# shutil.copy(build_public_path, os.path.join(decompile_dir_path, "res", "values"))
|
|
|
+#
|
|
|
+# shutil.rmtree(aapt2_output_dir)
|
|
|
+# shutil.rmtree(yb_decode_path)
|
|
|
+
|
|
|
+def isNeedReplaceApplicationLine(line):
|
|
|
+ return '.super Landroid/app/Application;' in line \
|
|
|
+ or 'invoke-direct {p0}, Landroid/app/Application;-><init>()V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Landroid/app/Application;->attachBaseContext(Landroid/content/Context;)V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Landroid/app/Application;->onConfigurationChanged(Landroid/content/res/Configuration;)V' in line \
|
|
|
+ or 'invoke-super {p0}, Landroid/app/Application;->onLowMemory()V' in line \
|
|
|
+ or 'invoke-super {p0}, Landroid/app/Application;->onTerminate()V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Landroid/app/Application;->onTrimMemory(I)V' in line \
|
|
|
+ or 'invoke-super {p0}, Landroid/app/Application;->onCreate()V' in line
|
|
|
+
|
|
|
+def is_kf_replace_application(line):
|
|
|
+ return '.super Lcom/kf/framework/KFApplication;' in line \
|
|
|
+ or 'invoke-direct {p0}, Lcom/kf/framework/KFApplication;-><init>()V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Lcom/kf/framework/KFApplication;->attachBaseContext(Landroid/content/Context;)V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Lcom/kf/framework/KFApplication;->onConfigurationChanged(Landroid/content/res/Configuration;)V' in line \
|
|
|
+ or 'invoke-super {p0}, Lcom/kf/framework/KFApplication;->onLowMemory()V' in line \
|
|
|
+ or 'invoke-super {p0}, Lcom/kf/framework/KFApplication;->onTerminate()V' in line \
|
|
|
+ or 'invoke-super {p0, p1}, Lcom/kf/framework/KFApplication;->onTrimMemory(I)V' in line \
|
|
|
+ or 'invoke-super {p0}, Lcom/kf/framework/KFApplication;->onCreate()V' in line
|
|
|
+
|
|
|
+def replace_application_verify_xmy_bug(decompile_dir):
|
|
|
+ for dirpath, dirnames, filenames in os.walk(decompile_dir):
|
|
|
+ if r'com\kingsoft\shiyou\omnisdk\api' in dirpath and 'OmniApplication.smali' in filenames:
|
|
|
+ application_path = os.path.join(dirpath, "OmniApplication.smali")
|
|
|
+ print(application_path)
|
|
|
+ with open(application_path, "r") as f:
|
|
|
+ smali_str_arr = f.readlines()
|
|
|
+ for line in smali_str_arr:
|
|
|
+ if not is_kf_replace_application(line) and 'Lcom/kf/framework/KFApplication' in line:
|
|
|
+ smali_str_arr[smali_str_arr.index(line)] = line.replace('Lcom/kf/framework/KFApplication',
|
|
|
+ 'Landroid/app/Application')
|
|
|
+ if isNeedReplaceApplicationLine(line):
|
|
|
+ smali_str_arr[smali_str_arr.index(line)] = line.replace('Landroid/app/Application',
|
|
|
+ 'Lcom/kf/framework/KFApplication')
|
|
|
+ with open(application_path, "w") as f:
|
|
|
+ f.write(''.join(smali_str_arr))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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')
|
|
|
+print(application_node)
|
|
|
+application_name = application_node.get(f'{namespace}name')
|
|
|
+print(application_name)
|
|
|
+# 修改extractNativeLib
|
|
|
+application_node.set(f'{namespace}extractNativeLibs', 'true')
|
|
|
+request_storage_name = application_node.get(f'{namespace}requestLegacyExternalStorage')
|
|
|
+print(request_storage_name)
|
|
|
+if request_storage_name is None:
|
|
|
+ application_node.set(f'{namespace}requestLegacyExternalStorage', 'true')
|
|
|
+xml_tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
|
|
|
+
|
|
|
+
|
|
|
+#改方法返回值为true
|
|
|
+def change_is_show_privacy():
|
|
|
+ for dirpath, dirnames, filenames in os.walk(decompile_dir_path):
|
|
|
+ if r'com\kingsoft\shiyou\omnisdk\project' in dirpath and 'ExtensionsKt.smali' in filenames:
|
|
|
+ smali_path = os.path.join(dirpath, 'ExtensionsKt.smali')
|
|
|
+ with open(smali_path, 'r', encoding='utf-8') as f:
|
|
|
+ smali_str_arr = f.readlines()
|
|
|
+ index_str = '.method public static final isShowedPrivacyAgreement()Z'
|
|
|
+ end_method_str = 'return'
|
|
|
+ on_create_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:
|
|
|
+ print('insert_index', index)
|
|
|
+ # smali_str_arr.insert(index, add_instance_str)
|
|
|
+ print(value)
|
|
|
+ print(re.findall(r'[v|p]\d', value))
|
|
|
+ var_list = re.findall(r'[v|p]\d', value)
|
|
|
+ if len(var_list) > 0:
|
|
|
+ var_name = re.findall(r'[v|p]\d', value)[0]
|
|
|
+ insert_str = f'\tconst/4 {var_name}, 0x1\n\n'
|
|
|
+ smali_str_arr.insert(index, insert_str)
|
|
|
+ break
|
|
|
+ with open(smali_path, 'w', encoding='utf-8') as f:
|
|
|
+ f.write(''.join(smali_str_arr))
|
|
|
+ break
|
|
|
+r_regex_str = r'sget[^\n]*R\$layout[^\n]*I|sget[^\n]*R\$id[^\n]*I|sget[^\n]*R\$drawable[^\n]*I|sget[^\n]*R\$string[^\n]*I|sget[^\n]*R\$array[^\n]*I|sget[^\n]*R\$bool[^\n]*I|sget[^\n]*R\$integer[^\n]*I'
|
|
|
+
|
|
|
+def replace_resource(d_dir):
|
|
|
+ for dirpath, dirnames, filenames in os.walk(d_dir):
|
|
|
+ if r'androidx\startup' in dirpath or r'androidx\work\impl' in dirpath or r'com\snyu\ddcr' in dirpath:
|
|
|
+ for smali_file in filenames:
|
|
|
+ smali_file_path = os.path.join(dirpath, smali_file)
|
|
|
+ print(smali_file_path)
|
|
|
+ findRSmaliAndReplace(smali_file_path, r_regex_str)
|
|
|
+ # attachBaseContext提前赋值
|
|
|
+ if r'com\kf\framework' in dirpath and 'KFApplication.smali' in filenames:
|
|
|
+ smali_path = os.path.join(dirpath, 'KFApplication.smali')
|
|
|
+ print(smali_path)
|
|
|
+ with open(smali_path, 'r', encoding='utf-8') as f:
|
|
|
+ smali_str_arr = f.readlines()
|
|
|
+ resume_index_str = r'.method public attachBaseContext(Landroid/content/Context;)V'
|
|
|
+ resume_insert_str = '\n\tsput-object p0, Lcom/kf/framework/KFApplication;->application:Landroid/content/Context;\n\n'
|
|
|
+ for index, value in enumerate(smali_str_arr):
|
|
|
+ if resume_index_str in value:
|
|
|
+ smali_str_arr.insert(index + 2, resume_insert_str)
|
|
|
+ with open(smali_path, 'w', encoding='utf-8') as f:
|
|
|
+ f.write(''.join(smali_str_arr))
|
|
|
+def findRSmaliAndReplace(smali_file_path, regex_str):
|
|
|
+ with open(smali_file_path, 'r') as f:
|
|
|
+ smali_str = f.read()
|
|
|
+ pattern = re.compile(regex_str)
|
|
|
+ resource_arr = pattern.findall(smali_str)
|
|
|
+ for r_str in resource_arr:
|
|
|
+ virtual_name = r_str[r_str.index(' ') + 1:r_str.index(',')]
|
|
|
+ print(virtual_name)
|
|
|
+ resource_type = r_str[r_str.index('R$') + 2:r_str.index(';')].capitalize()
|
|
|
+ print(resource_type)
|
|
|
+ resource_name = r_str[r_str.index('->') + 2:r_str.index(':')]
|
|
|
+ print(resource_name)
|
|
|
+ new_r_str = "const-string %s, \"%s\"\n\n\tinvoke-static {%s}, Lcom/kf/framework/MommyUtils;->get%sId(Ljava/lang/String;)I\n\n\tmove-result %s" % (
|
|
|
+ virtual_name, resource_name, virtual_name, resource_type, virtual_name)
|
|
|
+ print(new_r_str)
|
|
|
+ smali_str = smali_str.replace(r_str, new_r_str)
|
|
|
+ with open(smali_file_path, 'w') as f:
|
|
|
+ f.write(smali_str)
|
|
|
+def change_min_sdk_version(decompile_dir_path):
|
|
|
+ # 修改minSdkVersion
|
|
|
+ yaml_path = os.path.join(decompile_dir_path, 'apktool.yml')
|
|
|
+ file = open(yaml_path, 'r', encoding='utf-8')
|
|
|
+ yaml_result = yaml.load(file, Loader=yaml.BaseLoader)
|
|
|
+ sdk_info = yaml_result['sdkInfo']
|
|
|
+ yaml_result['packageInfo']['renameManifestPackage'] = None
|
|
|
+ print(sdk_info)
|
|
|
+ sdk_info['minSdkVersion'] = '24'
|
|
|
+ print(sdk_info)
|
|
|
+ file.close()
|
|
|
+ with open(yaml_path, 'w', encoding='utf-8') as f:
|
|
|
+ yaml.dump(yaml_result, f)
|
|
|
+def add_resource_method_xmy(resource_type):
|
|
|
+ insert_str_list = [
|
|
|
+ f'\n\t.method public static get{resource_type.capitalize()}Id(Ljava/lang/String;)I\n\n',
|
|
|
+ '\t.locals 3\n\n',
|
|
|
+ '\tinvoke-static {}, Lcom/kf/framework/KFApplication;->getApplication()Landroid/content/Context;\n\n',
|
|
|
+ '\tmove-result-object v0\n\n',
|
|
|
+ '\tinvoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;\n\n',
|
|
|
+ '\tmove-result-object v0\n\n',
|
|
|
+ f'\tconst-string v1, "{resource_type}"\n\n',
|
|
|
+ '\tinvoke-static {}, Lcom/kf/framework/KFApplication;->getApplication()Landroid/content/Context;\n\n',
|
|
|
+ '\tmove-result-object v2\n\n',
|
|
|
+ '\tinvoke-virtual {v2}, Landroid/content/Context;->getPackageName()Ljava/lang/String;\n\n',
|
|
|
+ '\tmove-result-object v2\n\n',
|
|
|
+ '\tinvoke-virtual {v0, p0, v1, v2}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I\n\n',
|
|
|
+ '\tmove-result p0\n\n',
|
|
|
+ '\treturn p0\n',
|
|
|
+ '.end method\n\n']
|
|
|
+ for dirpath, dirnames, filenames in os.walk(decompile_dir_path):
|
|
|
+ if r'com\kf\framework' in dirpath and 'MommyUtils.smali' in filenames:
|
|
|
+ smali_path = os.path.join(dirpath, 'MommyUtils.smali')
|
|
|
+ print(smali_path)
|
|
|
+ with open(smali_path, 'r', encoding='utf-8') as f:
|
|
|
+ smali_str_arr = f.readlines()
|
|
|
+ insert_str = ''.join(insert_str_list)
|
|
|
+ smali_str_arr.append(insert_str)
|
|
|
+ with open(smali_path, 'w', encoding='utf-8') as f:
|
|
|
+ f.write(''.join(smali_str_arr))
|
|
|
+#替换application
|
|
|
+add_resource_method_xmy('bool')
|
|
|
+replace_application_verify_xmy_bug(decompile_dir_path)
|
|
|
+# change_is_show_privacy()
|
|
|
+replace_resource(decompile_dir_path)
|
|
|
+change_min_sdk_version(decompile_dir_path)
|
|
|
+decode_yb_and_del_v4_and_copy_yb_res_and_modify_colors_v31()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|