Commit 3a0e61cf by sikang

update

parent 1de627f4
......@@ -122,7 +122,7 @@ elif command == 12:
elif command == 13 or command == 133:
Function().print_checklist(config, command == 133)
print("Api混淆、包路径全混淆、四大组件混淆、manifest混淆、随机插入乱码、随机插入Activity、字符串加密、随机插入字符串、随机插入图片")
print("Api混淆、包路径全混淆、四大组件混淆、manifest混淆、随机插入乱码、随机插入Activity、字符串加密、随机插入字符串、随机插入图片、登录提前")
print(" ")
elif command == 14:
......
......@@ -6,7 +6,6 @@ import os
class JavaGarble:
__used_names = []
__variables = []
__functions = []
__logic_model = ""
__config = {}
......@@ -19,24 +18,6 @@ class JavaGarble:
self.__used_names.append(result)
return result
# 生成变量
def __generate_variable(self):
var_scope = ["public", "private", "protected"]
var_types = ["String", "int", "double", "float"]
var_count = random.randint(
random.randint(3, 10), random.randint(20, 30))
for i in range(0, var_count):
code = "%s %s %s = " % (
var_scope[random.randint(0, 2)],
var_types[random.randint(0, 3)],
self.__gen_rand_str()
)
if " String " in code:
code += "\"%s\"" % self.__gen_rand_str()
else:
code += "%d" % random.randint(1, 1000)
code += ";"
self.__variables.append(code)
# 生成方法
def __generate_function(self, model_path):
......@@ -107,29 +88,13 @@ class JavaGarble:
# 插入代码
def __insert_code(self):
codes = self.__logic_model.split("//sep\n")
code = codes[random.randint(0, len(codes)-1)]
code = code.replace("${string}", self.__gen_rand_str())\
.replace("${name}", self.__gen_rand_str())\
.replace("${number}", str(random.randint(1, 10000)))
vars_size = len(self.__variables)-1
items = self.__variables[random.randint(0, vars_size)].split(" ")
if "String" in items[1]:
condition = "%s.length()%s%s" % (
items[2], ''.join(random.sample("><", 1)), items[4])
else:
condition = "%s%s%s" % (items[2], ''.join(random.sample("><", 1)), items[4])
code = code.replace("${condition}", condition)
content = ""
for i in range(0, random.randint(0, vars_size)):
var = self.__variables[random.randint(0, vars_size)]
content += "%s + " % var.split(" ")[2]
content = "System.out.println((%s\"\").length());" % content
code = code.replace("${content}", content)
return code
codes = self.__logic_model.split("@---sep---\n")
# code = codes[random.randint(0, len(codes)-1)]
# code = code.replace("${string}", self.__gen_rand_str())\
# .replace("${name}", self.__gen_rand_str())\
# .replace("${number}", str(random.randint(1, 10000)))
return ""
def __garble_java_file(self, file):
self.__used_names = []
......@@ -138,8 +103,6 @@ class JavaGarble:
with open(file, "r", encoding="utf-8") as fin:
lines = fin.readlines()
# 生成全局变量
self.__generate_variable()
# 生成方法
self.__generate_function("tools/garble/model/function_model.java")
......@@ -165,8 +128,7 @@ class JavaGarble:
# 定位1个缩进开头的类方法
if (line.startswith(" ") and not line.startswith(" ")) \
and ("){\n" in line or ") {\n" in line) and "static" not in line:
if (line.startswith(" ") and not line.startswith(" ")) and ("){\n" in line or ") {\n" in line):
curly_braces = line.count("{")
curly_braces -= line.count("}")
......@@ -190,5 +152,5 @@ class JavaGarble:
for main_dir in config['lib_main']:
for root, dirs, files in os.walk("%s/%s" % (config["root"], main_dir)):
for file in files:
if file.endswith(".java"):
if file.endswith("HomeActicity.java"):
self.__garble_java_file(os.path.join(root, file))
android.util.Log.d("${string}","${string}")
//sep
android.util.Log.e("${string}","${string}")
//sep
android.util.Log.i("${string}","${string}")
//sep
android.util.Log.v("${string}","${string}")
//sep
@var
String ${name1} = "${string1}";
int ${name1} = ${number1};
float ${name1} = ${number1};
double ${name1} = ${number1};
long ${name1} = ${number1};
@var
@condition
${name1}.contains("${string1}${string1}")
${name1} > ${number1}
${name1} < ${number1}
${name1} == ${number1} + ${number1}
@condition
@code
android.util.Log.d("${name1}","${name2}");
@---sep---
android.util.Log.e("${name1}","${name2}");
@---sep---
android.util.Log.i("${name1}","${name2}");
@---sep---
android.util.Log.v("${name1}","${name2}");
@---sep---
${vars}
while(${condition}){
${content}
System.out.println(${name1} + "${string2}" + "${string3}" + "${string4}" + "${string5}");
}
//sep
for(${condition}){
${content}
@---sep---
${vars}
for(int ${name2} = 0; ${condition}; ${name2}++ ){
${name3} = ${name2} + ${name1};
System.out.println(${name3} + "${string2}" + "${string3}" );
}
//sep
if(int ${name};${condition};${name}++){
${content}
@---sep---
${vars}
if(${condition}){
System.out.println(${name1} + "${string2}" + "${string3}" + "${string4}" );
}
//sep
boolean ${name} = ${condition}
@---sep---
${vars}
boolean ${name2} = ${condition};
if(${name}){
${content}
System.out.println(${name1} + "${string2}");
}
//sep
String ${name} = "${string}"
System.out.println(${name}+"${string}");
//sep
float ${name} = ${number}
while((int)${name} < (${name} - 1)){
${content}
@---sep---
String ${name1} = "${string1}";
System.out.println(${name1}+"${string2}");
@---sep---
float ${name1} = ${number1};
while((int)${name1} < (${name1} - 1)){
System.out.println("${string1}");
}
//sep
@---sep---
if(android.text.TextUtils.isEmpty(android.os.Build.BOARD)){
${content}
System.out.println("${string1}");
}
//sep
if(android.os.Build.DEVICE.contains("${string}")){
${content}
}
\ No newline at end of file
@---sep---
if(android.os.Build.DEVICE.equals("${string1}")){
System.out.println("${string2}");
}
@code
\ 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