Commit 0b10e0b9 by sikang

update script

parent f8965fef
# -*-coding:utf-8-*-
from func import Function
from shell import Shell
from tools. garble.garble import Garble
from tools. garble.api_garble import ApiGarble
from tools. garble.activity_garble import ActivityGarble
from tools.garble.string_garble import StringGarble
from tools. garble.package_garble import PackageGarble
from tools. garble.manifest_grable import ManifestGarble
from tools.sdk_manager import SdkManager
......@@ -14,7 +15,8 @@ config = Function().load_properties("../../gradle.properties")
config['root'] = "../.."
config['jks_path'] = "../../jks"
config['properties'] = "../../gradle.properties"
config['apk_path'] = "../../resGuardApks/%s_%s_release.apk"% (config["corp_id"],config["app_name"].replace(" ","_"))
config['apk_path'] = "../../resGuardApks/%s_%s_release.apk" % (
config["corp_id"], config["app_name"].replace(" ", "_"))
config['jiagu_output'] = "/Users/connor/Documents/apks"
config['jiagu_account'] = "15902141504"
config['jiagu_pwd'] = "qwqw10010"
......@@ -51,30 +53,30 @@ command = int(input("请输入指令编号:"))
# 命令
if command == 1:
#注释通话记录代码
# 注释通话记录代码
SdkManager().start_process(config, False, "NOLOG")
#注释/开启 通讯录代码
# 注释/开启 通讯录代码
if config['contact'] == "true":
SdkManager().start_process(config, True, "CONTACT")
else:
SdkManager().start_process(config, False, "CONTACT")
#api混淆
Garble().api_garble(config)
#字符串混淆
Garble().str_grable(config)
#四大组件类名混淆
# api混淆
ApiGarble().api_garble(config)
# 字符串混淆
StringGarble().str_grable(config)
# 四大组件类名混淆
ActivityGarble().activity_garble(config)
#包路径混淆
# 包路径混淆
PackageGarble().pkg_garble(config)
#Manifest混淆
# Manifest混淆
ManifestGarble().manifest_garble(config)
#旧版脚本编译(待转移)
# 旧版脚本编译(待转移)
Shell().build_release(config)
Shell().reset_project(config)
elif command == 2:
Function().new_appid(config)
elif command == 3:
Function().new_keystore(config)
......
......@@ -4,7 +4,7 @@ import string
import random
import base64
class Garble:
class ApiGarble:
#api混淆
def __rename_api(self,path,config):
with open("%s/script/api_mapping"%config['root'], "r", encoding="utf-8") as f:
......@@ -58,35 +58,5 @@ class Garble:
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) + "#-#"
grable_str = str(base64.b64encode((randStr + str_value).encode("utf-8")), "utf-8")
line = str_name + randStr + grable_str + "</string>\n"
f_w.write(line)
print("done\n")
return
def str_grable(self,config):
for root, dirs, files in os.walk("%s/lib_base/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)
# -*-coding:utf-8-*-
import glob, os
import string
import random
import base64
class StringGarble:
#字符串混淆
def __string_garble(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) + "#-#"
grable_str = str(base64.b64encode((randStr + str_value).encode("utf-8")), "utf-8")
line = str_name + randStr + grable_str + "</string>\n"
f_w.write(line)
return
#随机插入字符串
def __insert_strings(self,path):
with open(path, "r") as f:
fileContent = f.read()
strings = ""
for i in range(0,random.randint(100,500)):
strings += "%s\n"% ''.join(random.sample("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", random.randint(5, 100)))
with open(path, "w") as f_w:
fileContent = fileContent.replace("</resources>","%s\n</resources>"% strings)
f_w.write(fileContent)
def str_grable(self,config):
for root, dirs, files in os.walk("%s/lib_base/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_garble(path)
self.__insert_strings(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