script.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # coding:utf8
  2. __author__ = 'dong'
  3. import os
  4. import logging
  5. import xml.dom.minidom
  6. import re
  7. import shutil
  8. import glob
  9. import distutils.dir_util
  10. import os
  11. import gw_apk_tool
  12. import gw_file_system
  13. def script_second(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  14. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  15. if channelSdkInfo['id'] == '597':
  16. logging.info("remove_navigate")
  17. remove_navigate(decompileDir)
  18. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  19. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  20. if channelSdkInfo['id'] == '597':
  21. logging.info("remove_navigate")
  22. remove_navigate(decompileDir)
  23. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  24. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  25. if channelSdkInfo['id'] == "549" or channelSdkInfo['id'] == "597":
  26. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  27. smali_classes_new = create_mutil_smali(decompileDir)
  28. s3 = os.path.join(decompileDir, smali_classes_new)
  29. list_package = ["module"]
  30. if not os.path.exists(s3):
  31. distutils.dir_util.mkpath(s3)
  32. move_package(s1, s3, list_package)
  33. move_11_bytedance(decompileDir)
  34. s1 = os.path.join(decompileDir, "smali_classes11/com")
  35. smali_classes_new = create_mutil_smali(decompileDir)
  36. s3 = os.path.join(decompileDir, smali_classes_new)
  37. list_package = ["bytedance"]
  38. if not os.path.exists(s3):
  39. distutils.dir_util.mkpath(s3)
  40. move_package(s1, s3, list_package)
  41. s1 = os.path.join(decompileDir, "smali_classes11/com/huawei")
  42. smali_classes_new = create_mutil_smali(decompileDir)
  43. s3 = os.path.join(decompileDir, smali_classes_new)
  44. list_package = ["hms"]
  45. if not os.path.exists(s3):
  46. distutils.dir_util.mkpath(s3)
  47. move_package(s1, s3, list_package)
  48. s1 = os.path.join(decompileDir, "smali_classes11/com")
  49. smali_classes_new = create_mutil_smali(decompileDir)
  50. s3 = os.path.join(decompileDir, smali_classes_new)
  51. list_package = ["huawei","hermes","google"]
  52. if not os.path.exists(s3):
  53. distutils.dir_util.mkpath(s3)
  54. move_package(s1, s3, list_package)
  55. s1 = os.path.join(decompileDir, "smali_classes17/com/bytedance/ttgame/module")
  56. smali_classes_new = create_mutil_smali(decompileDir)
  57. s3 = os.path.join(decompileDir, smali_classes_new)
  58. list_package = ["usercenter", "voice", "vtranslate", "webview"]
  59. if not os.path.exists(s3):
  60. distutils.dir_util.mkpath(s3)
  61. move_package(s1, s3, list_package)
  62. s1 = os.path.join(decompileDir, "smali_classes40/com/bytedance/ttgame")
  63. smali_classes_new = create_mutil_smali(decompileDir)
  64. s3 = os.path.join(decompileDir, smali_classes_new)
  65. list_package = ["core"]
  66. if not os.path.exists(s3):
  67. distutils.dir_util.mkpath(s3)
  68. move_package(s1, s3, list_package)
  69. def move_package(s1, s3, list_package):
  70. for d in list_package:
  71. src = os.path.join(s1, d)
  72. if os.path.exists(src):
  73. dst = os.path.join(s3, d)
  74. distutils.dir_util.copy_tree(src, dst)
  75. distutils.dir_util.remove_tree(src)
  76. def move_11_bytedance(decompileDir):
  77. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  78. smali_classes_new = create_mutil_smali(decompileDir)
  79. s3 = os.path.join(decompileDir, smali_classes_new)
  80. list_package = ["rocketapi","wrapper_account","wrapper_alog","wrapper_appcloud","wrapper_applog"]
  81. if not os.path.exists(s3):
  82. distutils.dir_util.mkpath(s3)
  83. move_package(s1, s3, list_package)
  84. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  85. smali_classes_new = create_mutil_smali(decompileDir)
  86. s3 = os.path.join(decompileDir, smali_classes_new)
  87. list_package = ["wrapper_download","wrapper_encrypt","wrapper_jsbridge","wrapper_librarian","wrapper_net"]
  88. if not os.path.exists(s3):
  89. distutils.dir_util.mkpath(s3)
  90. move_package(s1, s3, list_package)
  91. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  92. smali_classes_new = create_mutil_smali(decompileDir)
  93. s3 = os.path.join(decompileDir, smali_classes_new)
  94. list_package = ["wrapper_pangolinsdk","wrapper_push","wrapper_sdk_monitor","wrapper_service_manager","wrapper_setting_manager"]
  95. if not os.path.exists(s3):
  96. distutils.dir_util.mkpath(s3)
  97. move_package(s1, s3, list_package)
  98. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  99. smali_classes_new = create_mutil_smali(decompileDir)
  100. s3 = os.path.join(decompileDir, smali_classes_new)
  101. list_package = ["wrapper_share","wrapper_smartrouter","wrapper_utility"]
  102. if not os.path.exists(s3):
  103. distutils.dir_util.mkpath(s3)
  104. move_package(s1, s3, list_package)
  105. def create_mutil_smali(decompileDir):
  106. f_idx = 2
  107. while True:
  108. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  109. tmp = tmp.replace('\\', '/')
  110. tmp = re.sub('/+', '/', tmp)
  111. if os.path.exists(tmp):
  112. f_idx += 1
  113. else:
  114. smali_classes2_dir = tmp
  115. break
  116. # endwhile
  117. os.mkdir(smali_classes2_dir)
  118. return smali_classes2_dir
  119. def remove_navigate(decompileDir):
  120. tmp_res = os.path.join(decompileDir, "res", "navigation")
  121. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  122. if os.path.exists(tmp_res):
  123. distutils.dir_util.remove_tree(tmp_res)
  124. if os.path.exists(tmp_public_xml):
  125. os.remove(tmp_public_xml)
  126. if __name__ == '__main__':
  127. # del_qihoo("C:\\Users\\Administrator\\Desktop\\zt")
  128. remove_navigate("G:\\autopack2.0_kuaifa\\tool\\workspace\\lrs360\\13651\\extract")