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
66ce41d4
Commit
66ce41d4
authored
Nov 01, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
4e6ce064
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
python/tools/garble/activity_garble.py
+11
-13
No files found.
python/tools/garble/activity_garble.py
View file @
66ce41d4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
glob
,
os
import
glob
,
os
import
string
import
string
import
random
import
random
import
re
class
ActivityGarble
:
class
ActivityGarble
:
__config
=
{}
__config
=
{}
...
@@ -21,20 +22,23 @@ class ActivityGarble:
...
@@ -21,20 +22,23 @@ class ActivityGarble:
#替换文件内容
#替换文件内容
def
__process_file_content
(
self
,
path
,
file_name
):
def
__process_file_content
(
self
,
path
,
file_name
):
# print("processing content: %s..."%path)
# print("processing content: %s..."%path)
chars
=
"_.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z"
.
split
(
'.'
)
with
open
(
path
,
"rt"
)
as
fin
:
with
open
(
path
,
"rt"
)
as
fin
:
file_content
=
fin
.
read
()
file_content
=
fin
.
read
()
# replace the file content based on mangle settings
# replace the file content based on mangle settings
for
(
src
,
dst
)
in
self
.
activity_mapping
.
items
():
for
(
src
,
dst
)
in
self
.
activity_mapping
.
items
():
#避免命名重复,确保要替换的部分前后没有合法的命名字符,如果有则还原
#避免命名重复,确保要替换的部分前后没有合法的命名字符,如果有则还原
file_content
=
file_content
.
replace
(
src
,
dst
)
file_content
=
file_content
.
replace
(
src
,
dst
)
for
char
in
chars
:
before
=
re
.
findall
(
r'[0-9a-zA-Z_]'
+
dst
,
file_content
)
if
char
+
dst
in
file_content
:
if
before
!=
None
:
file_content
=
file_content
.
replace
(
char
+
dst
,
char
+
src
)
for
name
in
before
:
elif
dst
+
char
in
file_content
:
char
=
name
.
split
(
dst
)[
0
]
file_content
=
file_content
.
replace
(
dst
+
char
,
src
+
char
)
file_content
=
file_content
.
replace
(
name
,
char
+
src
)
after
=
re
.
findall
(
r''
+
"
%
s[0-9a-zA-Z_]"
%
dst
,
file_content
)
if
after
!=
None
:
for
name
in
after
:
char
=
name
.
split
(
dst
)[
0
]
file_content
=
file_content
.
replace
(
name
,
char
+
src
)
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
if
ext
==
'.java'
:
if
ext
==
'.java'
:
...
@@ -84,10 +88,4 @@ class ActivityGarble:
...
@@ -84,10 +88,4 @@ class ActivityGarble:
for
main_dir
in
config
[
'lib_main'
]:
for
main_dir
in
config
[
'lib_main'
]:
self
.
__process_files
(
"
%
s/
%
s"
%
(
config
[
'root'
],
main_dir
))
self
.
__process_files
(
"
%
s/
%
s"
%
(
config
[
'root'
],
main_dir
))
#混淆AndroidManifest.xml
# print("start garble 混淆AndroidManifest.xml ...")
# for main_dir in config['lib_main']:
# manifest_path = os.path.join("%s/%s"% (config['root'],main_dir), "AndroidManifest.xml")
# self.__process_file_content(manifest_path,"AndroidManifest.xml")
print
(
"done"
)
print
(
"done"
)
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