Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
2dd3113f
Commit
2dd3113f
authored
Nov 04, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
f1af4b94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
python/config.json
+8
-0
python/tools/garble/layout_garble.py
+20
-5
No files found.
python/config.json
View file @
2dd3113f
...
@@ -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"
,
...
...
python/tools/garble/layout_garble.py
View file @
2dd3113f
...
@@ -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
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment