script.py 7.7 KB

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