Commit 2dd3113f by sikang

test

parent f1af4b94
...@@ -63,6 +63,14 @@ ...@@ -63,6 +63,14 @@
"UploadCollectionBean.java" "UploadCollectionBean.java"
], ],
"//ignore_layout":"布局混淆时,要跳过的layout,没有自定义layout可以忽略",
"ignore_layout":[
"TitleSpan",
"TopBar",
"SpanButton"
],
"//jiagu_output" : "360加固输出路径", "//jiagu_output" : "360加固输出路径",
"jiagu_output" : "/Users/connor/Documents/apks", "jiagu_output" : "/Users/connor/Documents/apks",
......
...@@ -9,6 +9,7 @@ class LayoutGarble: ...@@ -9,6 +9,7 @@ class LayoutGarble:
__used_names = [] __used_names = []
__layout_model = [] __layout_model = []
__colors = [] __colors = []
__config = []
def __gen_rand_str(self): def __gen_rand_str(self):
result = "" result = ""
...@@ -64,6 +65,7 @@ class LayoutGarble: ...@@ -64,6 +65,7 @@ class LayoutGarble:
views += self.__set_values(view).replace("${attributes}", self.__create_attributes()) views += self.__set_values(view).replace("${attributes}", self.__create_attributes())
return views return views
#生成一个layout文件 #生成一个layout文件
def __create_layout(self, path): def __create_layout(self, path):
layouts = self.__layout_model[1].split("@---sep---") layouts = self.__layout_model[1].split("@---sep---")
...@@ -88,17 +90,30 @@ class LayoutGarble: ...@@ -88,17 +90,30 @@ class LayoutGarble:
def __rewrite_layout(self,path): def __rewrite_layout(self,path):
with open(path,"r",encoding='utf-8') as fin: with open(path,"r",encoding='utf-8') as fin:
lines = fin.readlines() lines = fin.readlines()
with open(path,"w+",encoding='utf-8') as fin: with open(path,"w+",encoding='utf-8') as fin:
ignores = []
for line in lines: for line in lines:
if "</LinearLayout>" in line or "</RelativeLayout>" in line or "</FrameLayout>" in line: view_name = line.replace("<","").replace("/","").replace(">","")
if random.randint(0,10) % random.randint(2,3) == 0: #自定义layout忽略
view = self.__create_views(1).replace("/>","\n%s/>"%"android:visibility=\"gone\"") if "<" in line and "." in line:
line = "%s\n%s"%(view,line) items = line.split(".")
if items[len(items)-1] in self.__config['ignore_layout']:
ignores.append(view_name)
if "/" in line and view_name in ignores:
ignores.remove(view_name)
if len(ignores) == 0:
if "</LinearLayout>" in line or "</RelativeLayout>" in line or "</FrameLayout>" in line or "<TextView" in line \
or "<ImageView" in line or "<EditText" in line or "<Button" in line or "<ImageButton" in line or "<CheckBox" in line:
if random.randint(0,10) % random.randint(2,3) == 0:
view = self.__create_views(1).replace("/>","\n%s/>"%"android:visibility=\"gone\"")
line = "%s\n%s"%(view,line)
fin.write(line) fin.write(line)
#开始layout混淆 #开始layout混淆
def layout_garble(self, config): def layout_garble(self, config):
self.__config = config
with open("tools/garble/model/layout_model.xml", "r", encoding="utf-8") as fin: with open("tools/garble/model/layout_model.xml", "r", encoding="utf-8") as fin:
self.__layout_model = fin.read().split("@code\n") self.__layout_model = fin.read().split("@code\n")
......
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