script.py 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. logging.info("remove_navigate")
  16. remove_navigate(decompileDir)
  17. remove_value(decompileDir, "values-v31")
  18. remove_value(decompileDir, "color-v31")
  19. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  20. return
  21. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  22. sdk_id = channelSdkInfo['id']
  23. if sdk_id == "597":
  24. s1 = os.path.join(decompileDir, "smali", "androidx")
  25. if os.path.exists(s1):
  26. smali_classes2_dir = create_mutil_smali(decompileDir)
  27. s3 = os.path.join(smali_classes2_dir, "androidx")
  28. if not os.path.exists(s3):
  29. distutils.dir_util.mkpath(s3)
  30. move_package(s1, s3,["activity","annotation","appcompat","arch","asynclayoutinflater","browser"])
  31. s1 = os.path.join(decompileDir, "smali", "androidx")
  32. if os.path.exists(s1):
  33. smali_classes2_dir = create_mutil_smali(decompileDir)
  34. s3 = os.path.join(smali_classes2_dir, "androidx")
  35. if not os.path.exists(s3):
  36. distutils.dir_util.mkpath(s3)
  37. move_package(s1, s3,["tracing","transition","vectordrawable","versionedparcelable","viewpager","viewpager2","webkit","work"])
  38. s1 = os.path.join(decompileDir, "smali", "androidx")
  39. if os.path.exists(s1):
  40. smali_classes2_dir = create_mutil_smali(decompileDir)
  41. s3 = os.path.join(smali_classes2_dir, "androidx")
  42. if not os.path.exists(s3):
  43. distutils.dir_util.mkpath(s3)
  44. move_package(s1, s3,["cardview","collection","concurrent","constraintlayout","coordinatorlayout","core","cursoradapter","customview","documentfile","drawerlayout","dynamicanimation"])
  45. s1 = os.path.join(decompileDir, "smali", "androidx")
  46. if os.path.exists(s1):
  47. smali_classes2_dir = create_mutil_smali(decompileDir)
  48. s3 = os.path.join(smali_classes2_dir, "androidx")
  49. if not os.path.exists(s3):
  50. distutils.dir_util.mkpath(s3)
  51. move_package(s1, s3,["emoji2","fragment","inspection","interpolator"])
  52. s1 = os.path.join(decompileDir, "smali", "androidx")
  53. if os.path.exists(s1):
  54. smali_classes2_dir = create_mutil_smali(decompileDir)
  55. s3 = os.path.join(smali_classes2_dir, "androidx")
  56. if not os.path.exists(s3):
  57. distutils.dir_util.mkpath(s3)
  58. move_package(s1, s3,["print","recyclerview","resourceinspection","room","savedstate","security","slidingpanelayout","sqlite","startup","swiperefreshlayout"])
  59. s1 = os.path.join(decompileDir, "smali", "androidx")
  60. if os.path.exists(s1):
  61. smali_classes2_dir = create_mutil_smali(decompileDir)
  62. s3 = os.path.join(smali_classes2_dir, "androidx")
  63. if not os.path.exists(s3):
  64. distutils.dir_util.mkpath(s3)
  65. move_package(s1, s3,["media","multidex","navigation"])
  66. s1 = os.path.join(decompileDir, "smali", "androidx")
  67. if os.path.exists(s1):
  68. smali_classes2_dir = create_mutil_smali(decompileDir)
  69. s3 = os.path.join(smali_classes2_dir, "androidx")
  70. if not os.path.exists(s3):
  71. distutils.dir_util.mkpath(s3)
  72. move_package(s1, s3,["legacy","lifecycle","loader","localbroadcastmanager"])
  73. # smali andriodx 完毕
  74. s1 = os.path.join(decompileDir, "smali_classes2", "com")
  75. if os.path.exists(s1):
  76. smali_classes2_dir = create_mutil_smali(decompileDir)
  77. s3 = os.path.join(smali_classes2_dir, "com")
  78. if not os.path.exists(s3):
  79. distutils.dir_util.mkpath(s3)
  80. move_package(s1, s3,["onevcat","seasun","sharry","sina","snail"])
  81. s1 = os.path.join(decompileDir, "smali_classes2", "com")
  82. if os.path.exists(s1):
  83. smali_classes2_dir = create_mutil_smali(decompileDir)
  84. s3 = os.path.join(smali_classes2_dir, "com")
  85. if not os.path.exists(s3):
  86. distutils.dir_util.mkpath(s3)
  87. move_package(s1, s3,["netease"])
  88. s1 = os.path.join(decompileDir, "smali_classes2", "com")
  89. if os.path.exists(s1):
  90. smali_classes2_dir = create_mutil_smali(decompileDir)
  91. s3 = os.path.join(smali_classes2_dir, "com")
  92. if not os.path.exists(s3):
  93. distutils.dir_util.mkpath(s3)
  94. move_package(s1, s3,["lzy"])
  95. s1 = os.path.join(decompileDir, "smali_classes2", "com/kingsoft/shiyou/omnisdk")
  96. if os.path.exists(s1):
  97. smali_classes2_dir = create_mutil_smali(decompileDir)
  98. s3 = os.path.join(smali_classes2_dir, "com/kingsoft/shiyou/omnisdk")
  99. if not os.path.exists(s3):
  100. distutils.dir_util.mkpath(s3)
  101. move_package(s1, s3,["plugin","project"])
  102. s1 = os.path.join(decompileDir, "smali_classes2", "com/kingsoft/shiyou/omnisdk")
  103. if os.path.exists(s1):
  104. smali_classes2_dir = create_mutil_smali(decompileDir)
  105. s3 = os.path.join(smali_classes2_dir, "com/kingsoft/shiyou/omnisdk")
  106. if not os.path.exists(s3):
  107. distutils.dir_util.mkpath(s3)
  108. move_package(s1, s3,["api","basic","channel","core"])
  109. # smali_classes2结束
  110. s1 = os.path.join(decompileDir, "smali_classes3", "com")
  111. if os.path.exists(s1):
  112. smali_classes2_dir = create_mutil_smali(decompileDir)
  113. s3 = os.path.join(smali_classes2_dir, "com")
  114. if not os.path.exists(s3):
  115. distutils.dir_util.mkpath(s3)
  116. move_package(s1, s3,["snyu","tencent","unionpay","unity3d","vmadalin","yulong"])
  117. return
  118. def move_package_one(src, dst):
  119. if os.path.exists(src):
  120. distutils.dir_util.copy_tree(src, dst)
  121. distutils.dir_util.remove_tree(src)
  122. def move_package(s1, s3, list_package):
  123. for d in list_package:
  124. src = os.path.join(s1, d)
  125. if os.path.exists(src):
  126. dst = os.path.join(s3, d)
  127. distutils.dir_util.copy_tree(src, dst)
  128. distutils.dir_util.remove_tree(src)
  129. def move_11_bytedance(decompileDir):
  130. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  131. smali_classes_new = create_mutil_smali(decompileDir)
  132. s3 = os.path.join(decompileDir, smali_classes_new)
  133. list_package = ["rocketapi", "wrapper_account", "wrapper_alog", "wrapper_appcloud", "wrapper_applog"]
  134. if not os.path.exists(s3):
  135. distutils.dir_util.mkpath(s3)
  136. move_package(s1, s3, list_package)
  137. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  138. smali_classes_new = create_mutil_smali(decompileDir)
  139. s3 = os.path.join(decompileDir, smali_classes_new)
  140. list_package = ["wrapper_download", "wrapper_encrypt", "wrapper_jsbridge", "wrapper_librarian", "wrapper_net"]
  141. if not os.path.exists(s3):
  142. distutils.dir_util.mkpath(s3)
  143. move_package(s1, s3, list_package)
  144. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  145. smali_classes_new = create_mutil_smali(decompileDir)
  146. s3 = os.path.join(decompileDir, smali_classes_new)
  147. list_package = ["wrapper_pangolinsdk", "wrapper_push", "wrapper_sdk_monitor", "wrapper_service_manager",
  148. "wrapper_setting_manager"]
  149. if not os.path.exists(s3):
  150. distutils.dir_util.mkpath(s3)
  151. move_package(s1, s3, list_package)
  152. s1 = os.path.join(decompileDir, "smali_classes11/com/bytedance")
  153. smali_classes_new = create_mutil_smali(decompileDir)
  154. s3 = os.path.join(decompileDir, smali_classes_new)
  155. list_package = ["wrapper_share", "wrapper_smartrouter", "wrapper_utility"]
  156. if not os.path.exists(s3):
  157. distutils.dir_util.mkpath(s3)
  158. move_package(s1, s3, list_package)
  159. def create_mutil_smali(decompileDir):
  160. f_idx = 2
  161. while True:
  162. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  163. tmp = tmp.replace('\\', '/')
  164. tmp = re.sub('/+', '/', tmp)
  165. if os.path.exists(tmp):
  166. f_idx += 1
  167. else:
  168. smali_classes2_dir = tmp
  169. break
  170. # endwhile
  171. os.mkdir(smali_classes2_dir)
  172. return smali_classes2_dir
  173. def remove_navigate(decompileDir):
  174. tmp_res = os.path.join(decompileDir, "res", "navigation")
  175. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  176. if os.path.exists(tmp_res):
  177. distutils.dir_util.remove_tree(tmp_res)
  178. if os.path.exists(tmp_public_xml):
  179. os.remove(tmp_public_xml)
  180. def remove_value(decompileDir, remove_dir):
  181. tmp_res = os.path.join(decompileDir, "res", remove_dir)
  182. if os.path.exists(tmp_res):
  183. distutils.dir_util.remove_tree(tmp_res)
  184. if __name__ == '__main__':
  185. # del_qihoo("C:\\Users\\Administrator\\Desktop\\zt")
  186. remove_navigate("G:\\autopack2.0_kuaifa\\tool\\workspace\\lrs360\\13651\\extract")