Commit 2dd3113f by sikang

test

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