script.py 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. # coding:utf8
  2. __author__ = '灌篮高手酷派'
  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. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  11. return
  12. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  13. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  14. if channelSdkInfo['id'] == '549' or channelSdkInfo['id'] == '591':
  15. s1 = os.path.join(decompileDir, "smali_classes19","com","haowanyou")
  16. if os.path.exists(s1):
  17. smali_classes_new = create_mutil_smali(decompileDir)
  18. s3 = os.path.join(decompileDir, smali_classes_new,"com","haowanyou")
  19. list_package = ["router","sdkaes","sdkpermission","session","tool","tracepath","xmltojson"]
  20. if not os.path.exists(s3):
  21. distutils.dir_util.mkpath(s3)
  22. move_package(s1, s3, list_package)
  23. if channelSdkInfo['id'] == '597':
  24. s1 = os.path.join(decompileDir, "smali")
  25. if os.path.exists(s1):
  26. smali_classes_new = create_mutil_smali(decompileDir)
  27. s3 = os.path.join(decompileDir, smali_classes_new)
  28. list_package = ["androidx"]
  29. if not os.path.exists(s3):
  30. distutils.dir_util.mkpath(s3)
  31. move_package(s1, s3, list_package)
  32. s1 = os.path.join(decompileDir, "smali_classes2","com")
  33. if os.path.exists(s1):
  34. smali_classes_new = create_mutil_smali(decompileDir)
  35. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  36. list_package = ["samsung","sdk","splash","tencent","twobigears","unionpay","unity","unity3d","wysd","ycsdk","yulong","yysg","zndroid","zui"]
  37. if not os.path.exists(s3):
  38. distutils.dir_util.mkpath(s3)
  39. move_package(s1, s3, list_package)
  40. s1 = os.path.join(decompileDir, "smali_classes2","com")
  41. if os.path.exists(s1):
  42. smali_classes_new = create_mutil_smali(decompileDir)
  43. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  44. list_package = ["google","haowanyou","huawei","hwy","ipaynow","jaredrummler","luoshihai","mob","netease","onevcat","push"]
  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_classes2","com")
  49. if os.path.exists(s1):
  50. smali_classes_new = create_mutil_smali(decompileDir)
  51. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  52. list_package = ["luoshihai","mob","netease","onevcat","push"]
  53. if not os.path.exists(s3):
  54. distutils.dir_util.mkpath(s3)
  55. move_package(s1, s3, list_package)
  56. s1 = os.path.join(decompileDir, "smali_classes2","com")
  57. if os.path.exists(s1):
  58. smali_classes_new = create_mutil_smali(decompileDir)
  59. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  60. list_package = ["hwy","ipaynow","jaredrummler"]
  61. if not os.path.exists(s3):
  62. distutils.dir_util.mkpath(s3)
  63. move_package(s1, s3, list_package)
  64. s1 = os.path.join(decompileDir, "smali_classes2","com")
  65. if os.path.exists(s1):
  66. smali_classes_new = create_mutil_smali(decompileDir)
  67. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  68. list_package = ["haowanyou"]
  69. if not os.path.exists(s3):
  70. distutils.dir_util.mkpath(s3)
  71. move_package(s1, s3, list_package)
  72. s1 = os.path.join(decompileDir, "smali_classes4")
  73. if os.path.exists(s1):
  74. smali_classes_new = create_mutil_smali(decompileDir)
  75. s3 = os.path.join(decompileDir, smali_classes_new)
  76. list_package = ["com"]
  77. if not os.path.exists(s3):
  78. distutils.dir_util.mkpath(s3)
  79. move_package(s1, s3, list_package)
  80. s1 = os.path.join(decompileDir, "smali_classes5","com")
  81. if os.path.exists(s1):
  82. smali_classes_new = create_mutil_smali(decompileDir)
  83. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  84. list_package = ["faceunity","friendtime","friendtimes"]
  85. if not os.path.exists(s3):
  86. distutils.dir_util.mkpath(s3)
  87. move_package(s1, s3, list_package)
  88. s1 = os.path.join(decompileDir, "smali_classes7","androidx")
  89. if os.path.exists(s1):
  90. smali_classes_new = create_mutil_smali(decompileDir)
  91. s3 = os.path.join(decompileDir, smali_classes_new,"androidx")
  92. list_package = ["appcompat","asynclayoutinflater","coordinatorlayout","cursoradapter","documentfile","fragment","arch","collection","core","customview","drawerlayout","interpolator"]
  93. if not os.path.exists(s3):
  94. distutils.dir_util.mkpath(s3)
  95. move_package(s1, s3, list_package)
  96. s1 = os.path.join(decompileDir, "smali_classes9","com")
  97. if os.path.exists(s1):
  98. smali_classes_new = create_mutil_smali(decompileDir)
  99. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  100. list_package = ["google","haowanyou","huawei","hwy","ipaynow","jaredrummler"]
  101. if not os.path.exists(s3):
  102. distutils.dir_util.mkpath(s3)
  103. move_package(s1, s3, list_package)
  104. s1 = os.path.join(decompileDir, "smali_classes9","com")
  105. if os.path.exists(s1):
  106. smali_classes_new = create_mutil_smali(decompileDir)
  107. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  108. list_package = ["google","huawei"]
  109. if not os.path.exists(s3):
  110. distutils.dir_util.mkpath(s3)
  111. move_package(s1, s3, list_package)
  112. s1 = os.path.join(decompileDir, "smali_classes9","com")
  113. if os.path.exists(s1):
  114. smali_classes_new = create_mutil_smali(decompileDir)
  115. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  116. list_package = ["hwy","ipaynow","jaredrummler"]
  117. if not os.path.exists(s3):
  118. distutils.dir_util.mkpath(s3)
  119. move_package(s1, s3, list_package)
  120. s1 = os.path.join(decompileDir, "smali_classes9","com","haowanyou")
  121. if os.path.exists(s1):
  122. smali_classes_new = create_mutil_smali(decompileDir)
  123. s3 = os.path.join(decompileDir, smali_classes_new,"com","haowanyou")
  124. list_package = ["application","channel","common","core","event","multibundle","react"]
  125. if not os.path.exists(s3):
  126. distutils.dir_util.mkpath(s3)
  127. move_package(s1, s3, list_package)
  128. s1 = os.path.join(decompileDir, "smali_classes9","com","haowanyou")
  129. if os.path.exists(s1):
  130. smali_classes_new = create_mutil_smali(decompileDir)
  131. s3 = os.path.join(decompileDir, smali_classes_new,"com","haowanyou")
  132. list_package = ["react_native","reactnative","router","sdkaes","sdkpermission","session","tool","tracepath","xmltojson"]
  133. if not os.path.exists(s3):
  134. distutils.dir_util.mkpath(s3)
  135. move_package(s1, s3, list_package)
  136. s1 = os.path.join(decompileDir, "smali_classes9","com")
  137. if os.path.exists(s1):
  138. smali_classes_new = create_mutil_smali(decompileDir)
  139. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  140. list_package = ["mob"]
  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_classes16","com")
  145. if os.path.exists(s1):
  146. smali_classes_new = create_mutil_smali(decompileDir)
  147. s3 = os.path.join(decompileDir, smali_classes_new,"com")
  148. list_package = ["haowanyou"]
  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_classes20","com/haowanyou")
  153. if os.path.exists(s1):
  154. smali_classes_new = create_mutil_smali(decompileDir)
  155. s3 = os.path.join(decompileDir, smali_classes_new,"com/haowanyou")
  156. list_package = ["application","channel","common","core","event","multibundle","react","react_native","reactnative"]
  157. if not os.path.exists(s3):
  158. distutils.dir_util.mkpath(s3)
  159. move_package(s1, s3, list_package)
  160. def create_mutil_smali(decompileDir):
  161. f_idx = 2
  162. while True:
  163. # tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  164. tmp = os.path.join(decompileDir, 'smali_classes%d' % f_idx)
  165. tmp = tmp.replace('\\', '/')
  166. tmp = re.sub('/+', '/', tmp)
  167. if os.path.exists(tmp):
  168. f_idx += 1
  169. else:
  170. smali_classes2_dir = tmp
  171. break
  172. # endwhile
  173. os.mkdir(smali_classes2_dir)
  174. return smali_classes2_dir
  175. def move_package(s1, s3, list_package):
  176. for d in list_package:
  177. src = os.path.join(s1, d)
  178. if os.path.exists(src):
  179. dst = os.path.join(s3, d)
  180. distutils.dir_util.copy_tree(src, dst)
  181. distutils.dir_util.remove_tree(src)
  182. if __name__ == '__main__':
  183. replace_life_method("D:\\work\\xmy")