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
238eb1b8
Commit
238eb1b8
authored
Oct 24, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udpate script
parent
eae23874
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
147 additions
and
17 deletions
+147
-17
python/main.py
+30
-6
python/shell.py
+11
-5
python/tools/garble/activity_garble.py
+0
-0
python/tools/garble/class_builder.py
+0
-0
python/tools/garble/garble.py
+3
-0
python/tools/garble/manifest_grable.py
+6
-3
python/tools/garble/model/activity_model.java
+0
-0
python/tools/garble/model/function_model.java
+0
-0
python/tools/garble/model/variable_model.java
+0
-0
python/tools/garble/package_garble.py
+2
-3
python/tools/sdk_manager.py
+95
-0
No files found.
python/main.py
View file @
238eb1b8
# -*-coding:utf-8-*-
# -*-coding:utf-8-*-
from
func
import
Function
from
func
import
Function
from
shell
import
Shell
from
shell
import
Shell
from
tools.garbel.garble
import
Garble
from
tools
.
garble
.
garble
import
Garble
from
tools.garbel.activity_garble
import
ActivityGarble
from
tools
.
garble
.
activity_garble
import
ActivityGarble
from
tools.garbel.package_garble
import
PackageGarble
from
tools
.
garble
.
package_garble
import
PackageGarble
from
tools.garbel.manifest_grable
import
ManifestGarble
from
tools
.
garble
.
manifest_grable
import
ManifestGarble
from
tools.sdk_manager
import
SdkManager
import
os
import
os
import
shutil
import
shutil
...
@@ -38,12 +39,32 @@ print("18、四大组件混淆")
...
@@ -38,12 +39,32 @@ print("18、四大组件混淆")
print
(
"19、包路径混淆"
)
print
(
"19、包路径混淆"
)
print
(
"20、插入Activity"
)
print
(
"20、插入Activity"
)
print
(
"21、reset project"
)
print
(
"21、reset project"
)
print
(
"26、启用/禁用代码"
)
command
=
int
(
input
(
"请输入指令编号:"
))
command
=
int
(
input
(
"请输入指令编号:"
))
# 命令
# 命令
if
command
==
1
:
if
command
==
1
:
Shell
()
.
build_release
()
#注释通话记录代码
SdkManager
()
.
start_process
(
config
,
False
,
"NOLOG"
)
#注释/开启 通讯录代码
if
config
[
'contact'
]
==
"true"
:
SdkManager
()
.
start_process
(
config
,
True
,
"CONTACT"
)
else
:
SdkManager
()
.
start_process
(
config
,
False
,
"CONTACT"
)
#api混淆
Garble
()
.
api_garble
(
config
)
#字符串混淆
Garble
()
.
str_grable
(
config
)
#四大组件类名混淆
ActivityGarble
()
.
activity_garble
(
config
)
#包路径混淆
PackageGarble
()
.
pkg_garble
(
config
)
#Manifest混淆
ManifestGarble
()
.
manifest_garble
(
config
)
#旧版脚本编译(待转移)
Shell
()
.
build_release
(
config
)
Shell
()
.
reset_project
(
config
)
elif
command
==
2
:
elif
command
==
2
:
Function
()
.
new_appid
(
config
)
Function
()
.
new_appid
(
config
)
...
@@ -101,7 +122,10 @@ elif command == 19:
...
@@ -101,7 +122,10 @@ elif command == 19:
PackageGarble
()
.
pkg_garble
(
config
)
PackageGarble
()
.
pkg_garble
(
config
)
elif
command
==
20
:
elif
command
==
20
:
ManifestGarble
()
.
manifest_garb
el
(
config
)
ManifestGarble
()
.
manifest_garb
le
(
config
)
elif
command
==
21
:
elif
command
==
21
:
Shell
()
.
reset_project
(
config
)
Shell
()
.
reset_project
(
config
)
elif
command
==
26
:
SdkManager
()
.
sdk_manage
(
config
)
python/shell.py
View file @
238eb1b8
...
@@ -5,11 +5,17 @@ import os
...
@@ -5,11 +5,17 @@ import os
class
Shell
:
class
Shell
:
#编译 待开发
#编译 待开发
def
build_release
(
self
):
def
build_release
(
self
,
config
):
command
=
"
%
s
\n
%
s
\n
"
\
command
=
"
%
s
\n
%
s
\n
%
s
\n
%
s
\n
%
s
\n
%
s
\n
%
s
\n
%
s
\n
"
\
%
(
%
(
"cd ../script"
,
"cd
%
s"
%
config
[
'root'
],
"./release_builder.sh"
"rm -rf resGuardApks"
,
"gradlew clean"
,
"cd lib_base/script/garble"
,
"./insert.py || { echo
\"
insert_code error!
\"
; exit 1; }"
,
"cd
%
s"
%
config
[
'root'
],
"gradlew resguardAppProductGoogleplayRelease"
,
"gradlew clean"
)
)
os
.
system
(
command
)
os
.
system
(
command
)
...
@@ -18,7 +24,7 @@ class Shell:
...
@@ -18,7 +24,7 @@ class Shell:
def
push_project
(
self
,
config
):
def
push_project
(
self
,
config
):
command
=
"
%
s
\n
%
s
\n
%
s
\n
%
s
\n
"
\
command
=
"
%
s
\n
%
s
\n
%
s
\n
%
s
\n
"
\
%
(
%
(
"cd
"
+
config
[
'root'
],
"cd
%
s"
%
config
[
'root'
],
"git add ."
,
"git add ."
,
"git commit -m
\"
%
s
\"
"
%
(
config
[
'app_id'
]
+
" "
+
config
[
'version_name'
]),
"git commit -m
\"
%
s
\"
"
%
(
config
[
'app_id'
]
+
" "
+
config
[
'version_name'
]),
"git push origin
%
s"
%
config
[
'git_branch'
]
"git push origin
%
s"
%
config
[
'git_branch'
]
...
...
python/tools/garb
el
/activity_garble.py
→
python/tools/garb
le
/activity_garble.py
View file @
238eb1b8
File moved
python/tools/garb
el
/class_builder.py
→
python/tools/garb
le
/class_builder.py
View file @
238eb1b8
File moved
python/tools/garb
el
/garble.py
→
python/tools/garb
le
/garble.py
View file @
238eb1b8
...
@@ -44,6 +44,9 @@ class Garble:
...
@@ -44,6 +44,9 @@ class Garble:
return
return
def
api_garble
(
self
,
config
):
def
api_garble
(
self
,
config
):
if
not
os
.
path
.
exists
(
"
%
s/script/api_mapping"
%
config
[
'root'
]):
print
(
"api_mapping not found"
)
return
#java目录的路径
#java目录的路径
for
root
,
dirs
,
files
in
os
.
walk
(
"
%
s/lib_base/src/main"
%
config
[
'root'
]):
for
root
,
dirs
,
files
in
os
.
walk
(
"
%
s/lib_base/src/main"
%
config
[
'root'
]):
directory
=
os
.
path
.
join
(
os
.
getcwd
(),
root
)
directory
=
os
.
path
.
join
(
os
.
getcwd
(),
root
)
...
...
python/tools/garb
el
/manifest_grable.py
→
python/tools/garb
le
/manifest_grable.py
View file @
238eb1b8
import
random
import
random
import
os
import
os
from
tools.garb
el
.class_builder
import
ClassBuilder
from
tools.garb
le
.class_builder
import
ClassBuilder
class
ManifestGarble
:
class
ManifestGarble
:
__used_names
=
[]
__used_names
=
[]
...
@@ -17,7 +17,7 @@ class ManifestGarble:
...
@@ -17,7 +17,7 @@ class ManifestGarble:
def
__create_activities
(
self
,
path
):
def
__create_activities
(
self
,
path
):
activities
=
[]
activities
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
if
len
(
files
)
>
0
:
if
len
(
files
)
>
0
and
(
files
[
0
]
.
endswith
(
".java"
)
or
files
[
0
]
.
endswith
(
".kt"
))
:
for
i
in
range
(
0
,
random
.
randint
(
3
,
10
)):
for
i
in
range
(
0
,
random
.
randint
(
3
,
10
)):
act_name
=
self
.
__gen_rand_str
()
act_name
=
self
.
__gen_rand_str
()
act_path
=
"
%
s/
%
s.java"
%
(
root
,
act_name
)
act_path
=
"
%
s/
%
s.java"
%
(
root
,
act_name
)
...
@@ -43,7 +43,7 @@ class ManifestGarble:
...
@@ -43,7 +43,7 @@ class ManifestGarble:
def
manifest_garb
el
(
self
,
config
):
def
manifest_garb
le
(
self
,
config
):
print
(
"generating activity ..."
)
print
(
"generating activity ..."
)
app_activities
=
self
.
__create_activities
(
"
%
s/app/src/main/java"
%
config
[
"root"
])
app_activities
=
self
.
__create_activities
(
"
%
s/app/src/main/java"
%
config
[
"root"
])
base_activities
=
self
.
__create_activities
(
"
%
s/lib_base/src/main/java"
%
config
[
"root"
])
base_activities
=
self
.
__create_activities
(
"
%
s/lib_base/src/main/java"
%
config
[
"root"
])
...
@@ -53,3 +53,6 @@ class ManifestGarble:
...
@@ -53,3 +53,6 @@ class ManifestGarble:
self
.
__insert_to_manifest
(
"
%
s/lib_base/src/main/AndroidManifest.xml"
%
config
[
"root"
],
base_activities
)
self
.
__insert_to_manifest
(
"
%
s/lib_base/src/main/AndroidManifest.xml"
%
config
[
"root"
],
base_activities
)
print
(
"done"
)
print
(
"done"
)
if
__name__
==
"__main__"
:
ManifestGarble
()
.
manifest_garble
({})
python/tools/garb
el
/model/activity_model.java
→
python/tools/garb
le
/model/activity_model.java
View file @
238eb1b8
File moved
python/tools/garb
el
/model/function_model.java
→
python/tools/garb
le
/model/function_model.java
View file @
238eb1b8
File moved
python/tools/garb
el
/model/variable_model.java
→
python/tools/garb
le
/model/variable_model.java
View file @
238eb1b8
File moved
python/tools/garb
el
/package_garble.py
→
python/tools/garb
le
/package_garble.py
View file @
238eb1b8
...
@@ -137,5 +137,4 @@ class PackageGarble:
...
@@ -137,5 +137,4 @@ class PackageGarble:
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
#project 根目录
#project 根目录
config
=
{
"root"
:
"../../../../"
}
PackageGarble
()
.
pkg_garble
({})
PackageGarble
()
.
pkg_garble
(
config
)
\ No newline at end of file
\ No newline at end of file
python/tools/sdk_manager.py
0 → 100755
View file @
238eb1b8
#!/usr/bin/env python3
import
json
import
string
import
random
import
glob
,
os
import
sys
class
SdkManager
:
def
__disable_code
(
self
,
path
,
sdk
):
# print("processing content: %s..." % path)
with
open
(
path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
lines
=
f
.
readlines
()
with
open
(
path
,
"w"
,
encoding
=
"utf-8"
)
as
f_w
:
is_sdk_code
=
False
for
line
in
lines
:
if
"//SDK-"
+
sdk
+
"-END"
in
line
or
"<!--SDK-"
+
sdk
+
"-END-->"
in
line
:
is_sdk_code
=
False
java_mark
=
"//SDK-"
+
sdk
+
"-CODE ->"
;
xml_mark
=
"<!--SDK-"
+
sdk
+
"-CODE//"
;
if
(
path
.
endswith
(
".java"
)
or
path
.
endswith
(
".gradle"
))
and
is_sdk_code
and
java_mark
not
in
line
:
line
=
java_mark
+
line
if
path
.
endswith
(
".xml"
)
and
is_sdk_code
and
xml_mark
not
in
line
:
line
=
xml_mark
+
line
.
replace
(
"
\n
"
,
"//-->
\n
"
)
if
"//SDK-"
+
sdk
+
"-START"
in
line
or
"<!--SDK-"
+
sdk
+
"-START-->"
in
line
:
is_sdk_code
=
True
f_w
.
write
(
line
)
return
def
__enable_code
(
self
,
path
,
sdk
):
# print("processing content: %s..." % path)
code_mark
=
"//SDK-"
+
sdk
+
"-CODE ->"
xml_mark
=
"<!--SDK-"
+
sdk
+
"-CODE//"
with
open
(
path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
lines
=
f
.
readlines
()
with
open
(
path
,
"w"
,
encoding
=
"utf-8"
)
as
f_w
:
for
line
in
lines
:
if
code_mark
in
line
:
line
=
line
.
replace
(
code_mark
,
""
)
if
xml_mark
in
line
:
line
=
line
.
replace
(
xml_mark
,
""
)
.
replace
(
"//-->"
,
""
)
f_w
.
write
(
line
)
return
def
__process_files
(
self
,
path
,
enable
,
sdk_mark
):
if
not
os
.
path
.
isdir
(
path
):
if
enable
:
self
.
__enable_code
(
path
,
sdk_mark
)
else
:
self
.
__disable_code
(
path
,
sdk_mark
)
else
:
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
directory
=
os
.
path
.
join
(
os
.
getcwd
(),
root
)
for
file
in
files
:
if
file
.
endswith
(
".java"
)
or
file
.
endswith
(
"AndroidManifest.xml"
)
or
file
.
endswith
(
".gradle"
):
# get the path of the java file
path
=
os
.
path
.
join
(
directory
,
file
)
if
enable
:
self
.
__enable_code
(
path
,
sdk_mark
)
else
:
self
.
__disable_code
(
path
,
sdk_mark
)
def
start_process
(
self
,
config
,
enable
,
sdk_mark
):
#混淆build.gradle
self
.
__process_files
(
"
%
s/build.gradle"
%
config
[
'root'
],
enable
,
sdk_mark
)
self
.
__process_files
(
"
%
s/lib_base/build.gradle"
%
config
[
'root'
],
enable
,
sdk_mark
)
#混淆代码
self
.
__process_files
(
"
%
s/app/src/main"
%
config
[
'root'
],
enable
,
sdk_mark
)
self
.
__process_files
(
"
%
s/lib_base/src/main"
%
config
[
'root'
],
enable
,
sdk_mark
)
def
sdk_manage
(
self
,
config
):
print
(
" "
)
print
(
"1、启用SDK"
)
print
(
"2、禁用SDK"
)
command
=
int
(
input
(
"请输入指令编号:"
))
print
(
" "
)
print
(
"占位的标记:ADVANCE、YITU、MOTION 等"
)
sdk
=
str
(
input
(
"要操作的SDK:"
))
if
command
==
1
:
self
.
start_process
(
config
,
True
,
sdk
)
else
:
self
.
start_process
(
config
,
False
,
sdk
)
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