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
0e83446e
Commit
0e83446e
authored
Oct 14, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
98628cf8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
19 deletions
+23
-19
script/garble/obact.json
+1
-0
script/garble/obact.py
+19
-18
script/garble/obact_lib.py
+3
-1
No files found.
script/garble/obact.json
View file @
0e83446e
...
...
@@ -9,6 +9,7 @@
"LoanHistoryActivity"
,
"LoginActivity"
,
"SettingsActivity"
,
"SplashActivity"
,
"AccountFragment"
,
"ContactInfoFragment"
,
"IdentityInfoFragment"
,
...
...
script/garble/obact.py
View file @
0e83446e
#!/usr/bin/env python3
import
json
import
string
import
os
import
random
import
glob
,
os
import
string
used_names
=
[]
activity_mangle_setting
=
{}
def
process_file_content
(
path
,
file_name
):
# print("processing content: %s..."%path)
with
open
(
path
,
"rt"
)
as
fin
:
file_content
=
fin
.
read
()
# replace the file content based on mangle settings
for
(
src
,
dst
)
in
activity_mangle_setting
.
items
():
file_content
=
file_content
.
replace
(
src
,
dst
)
separator
=
[
" "
,
"."
,
"
\"
"
,
"{"
,
"("
,
":"
]
for
sep
in
separator
:
file_content
=
file_content
.
replace
(
src
+
sep
,
dst
+
separator
)
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
if
ext
==
'.java'
:
comment
=
"// machine renamed:
%
s
\n
"
%
file_name
file_content
=
"
%
s
%
s"
%
(
comment
,
file_content
)
comment
=
"// machine renamed:
%
s
\n
"
%
file_name
file_content
=
"
%
s
%
s"
%
(
comment
,
file_content
)
with
open
(
path
,
"wt"
)
as
fout
:
fout
.
write
(
file_content
)
print
(
"done
\n
"
)
return
# rand string for class names
def
gen_rand_str
():
rand_str
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
ascii_lowercase
,
k
=
8
))
while
rand_str
in
used_names
:
rand_str
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
ascii_lowercase
,
k
=
8
))
used_names
.
append
(
rand_str
)
return
rand_str
# read configs
with
open
(
'obact.json'
,
"rt"
)
as
f
:
json_root
=
json
.
load
(
f
)
...
...
@@ -45,8 +50,8 @@ with open('obact.json', "rt") as f:
for
act_name
in
activities
:
activity_mangle_setting
[
act_name
]
=
gen_rand_str
()
print
(
"activity mapping
%
s"
%
activity_mangle_setting
)
print
(
"activity mapping
%
s"
%
activity_mangle_setting
)
root_path
=
os
.
path
.
join
(
os
.
getcwd
(),
source_root
)
# perform content replace for the files
print
(
"processing file content..."
)
...
...
@@ -56,7 +61,7 @@ for root, dirs, files in os.walk(source_root):
if
file
.
endswith
(
".java"
):
# get the path of the java file
path
=
os
.
path
.
join
(
directory
,
file
)
process_file_content
(
path
,
file
)
print
(
"processing file content done"
)
...
...
@@ -64,20 +69,16 @@ print("renaming files")
for
root
,
dirs
,
files
in
os
.
walk
(
source_root
):
directory
=
os
.
path
.
join
(
os
.
getcwd
(),
root
)
for
file
in
files
:
if
file
.
endswith
(
".java"
):
if
file
.
endswith
(
".java"
):
name
=
os
.
path
.
splitext
(
file
)[
0
]
if
name
in
activity_mangle_setting
:
# get the path of the java file
src
=
os
.
path
.
join
(
directory
,
file
)
dst
=
os
.
path
.
join
(
directory
,
"
%
s.java"
%
activity_mangle_setting
[
name
])
dst
=
os
.
path
.
join
(
directory
,
"
%
s.java"
%
activity_mangle_setting
[
name
])
# print("%s -> %s"%(src, dst))
os
.
rename
(
src
,
dst
)
print
(
"renaming files done"
)
manifest_path
=
os
.
path
.
join
(
os
.
getcwd
(),
manifest
)
process_file_content
(
manifest_path
,
"AndroidManifest.xml"
)
script/garble/obact_lib.py
View file @
0e83446e
...
...
@@ -14,7 +14,9 @@ def process_file_content(path, file_name):
# replace the file content based on mangle settings
for
(
src
,
dst
)
in
activity_mangle_setting
.
items
():
file_content
=
file_content
.
replace
(
src
,
dst
)
separator
=
[
" "
,
"."
,
"
\"
"
,
"{"
,
"("
,
":"
]
for
sep
in
separator
:
file_content
=
file_content
.
replace
(
src
+
sep
,
dst
+
separator
)
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
if
ext
==
'.java'
:
...
...
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