Commit 66d929ef by sikang

update script

parent 3abc4ae7
......@@ -30,6 +30,7 @@ print("13、打印checklist")
print("14、生成隐协议文件")
print("15、刷新本地协议")
print("16、api混淆")
print("17、字符串混淆")
print("21、reset project")
command = int(input("请输入指令编号:"))
......@@ -84,5 +85,8 @@ elif command == 15:
elif command == 16:
Garble().api_garble(config)
elif command == 17:
Garble().str_grable(config)
elif command == 21:
Shell().reset_project(config)
#!/usr/bin/env python3
import glob, os
import string
import random
import base64
class Garble:
#api混淆
def __rename_api(self,path,config):
with open("%s/script/api_mapping"%config['root'], "r", encoding="utf-8") as f:
......@@ -41,14 +42,45 @@ class Garble:
print(path + " done\n")
return
def api_garble(self,config):
#java目录的路径
for root, dirs, files in os.walk("%s/src/main"%config['root']):
dir = os.path.join(os.getcwd(), root)
for root, dirs, files in os.walk("%s/lib_base/src/main"%config['root']):
directory = os.path.join(os.getcwd(), root)
for file in files:
#要检索的文件名
if file.endswith("LoanApi.java") or file.endswith("UploadApi.java") or file.endswith("UserApi.java"):
# get the path of the java file
path = os.path.join(dir, file)
self.__rename_api(path,config)
\ No newline at end of file
path = os.path.join(directory, file)
self.__rename_api(path,config)
#字符串混淆
def __string_grable(self,path):
with open(path, "r") as f:
lines = f.readlines()
with open(path, "w") as f_w:
for line in lines:
if "<string" in line and "</string>\n" in line and "<!" not in line:
if "*keep*" not in line:
line = line.replace("</string>\n", "")
str_name = line.split(">")[0] + ">"
str_value = line.split(">")[1]
number=""
for i in range(0,random.randint(2,15)):
number += str(random.randint(0,9))
randStr = str(number) + "#-#"
line = str_name + randStr + base64.b64encode(randStr + str_value) + "</string>\n"
f_w.write(line)
# print("done\n")
return
def str_grable(self,config):
for root, dirs, files in os.walk("%s/src/main/res"% config['root']):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith("strings.xml"):
# get the path of the java file
path = os.path.join(directory, file)
self.__string_grable(path)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment