diff --git a/.gitignore b/.gitignore
index 481f81b..6c56cd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,4 @@ app/.DS_Store
.idea/*
gradle/.DS_Store
build/
+localRepo/
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 4b23991..cf3ac34 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -56,7 +56,6 @@ BlackObfuscator {
}
dependencies {
-
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f96d65e..d09a485 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,5 +17,4 @@
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 6378090..265019d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
+
repositories {
google()
mavenCentral()
@@ -8,13 +9,16 @@ buildscript {
url uri('./localRepo')
}
}
+
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
- classpath "top.niunaijun.blackobfuscator:plugin:1.0.0"
+ //classpath "com.github.CodingGay:BlackObfuscator-ASPlugin:3.7"
+ classpath "top.niunaijun.blackobfuscator:plugin:1.0.3"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
+
}
allprojects {
diff --git a/local.properties b/local.properties
index 9fffe5f..ed22404 100644
--- a/local.properties
+++ b/local.properties
@@ -1,10 +1,8 @@
-## This file is automatically generated by Android Studio.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file should *NOT* be checked into Version Control Systems,
+## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
-sdk.dir=/Users/milk/Library/Android/sdk
\ No newline at end of file
+#Sat Apr 02 12:21:53 CST 2022
+sdk.dir=H\:\\AS\\SDK
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar
index 66e8739..151f2aa 100644
Binary files a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar and b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar differ
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.md5
index ddf060b..b0c1346 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.md5
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.md5
@@ -1 +1 @@
-eb035af7c6ce60caf3ab9c762a96e98d
\ No newline at end of file
+2cc479f7df8b0401cee0ff12e5ed48ae
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.sha1
index bb30c42..92268ae 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.sha1
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.jar.sha1
@@ -1 +1 @@
-eaab39a87530bce1ff233150bed9bd1c786c64d1
\ No newline at end of file
+bae29a1184ce71fb538fefc617dfea07294bdab3
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom
index 784be73..3960b57 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom
@@ -6,12 +6,6 @@
plugin
1.0.0
-
- com.android.tools.build
- gradle
- 3.3.1
- runtime
-
com.android.tools.build
transform-api
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.md5
index 21ccd4a..a8029e7 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.md5
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.md5
@@ -1 +1 @@
-e072c183806d331aa32ac8863534a4ce
\ No newline at end of file
+4dfa616d9a3575f09dc1336592899ea6
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.sha1
index 1fa3344..14fccfe 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.sha1
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.0/plugin-1.0.0.pom.sha1
@@ -1 +1 @@
-76b4be6ced264f6379d490e0d7331dd732df1641
\ No newline at end of file
+3770cd6d1e57dc5269842e67e496ecb2fa313479
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar
new file mode 100644
index 0000000..31aed35
Binary files /dev/null and b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar differ
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.md5
new file mode 100644
index 0000000..4e254df
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.md5
@@ -0,0 +1 @@
+d9e5bbd2a5c31b0f861e067ac373aa6e
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.sha1
new file mode 100644
index 0000000..71c1378
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.jar.sha1
@@ -0,0 +1 @@
+cba454afc51b76ea3ace6095464a2b50afb70de2
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom
new file mode 100644
index 0000000..c88e5b2
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+ top.niunaijun.blackobfuscator
+ plugin
+ 1.0.1
+
+
+ com.android.tools.build
+ transform-api
+ 1.5.0
+ runtime
+
+
+ commons-io
+ commons-io
+ 2.5
+ runtime
+
+
+ com.github.CodingGay.BlackObfuscator
+ dex-tools
+ 2.1
+ runtime
+
+
+
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.md5
new file mode 100644
index 0000000..eebbc3e
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.md5
@@ -0,0 +1 @@
+6393228b2c72a38d646a5e7b0eea4456
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.sha1
new file mode 100644
index 0000000..bdd2047
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.1/plugin-1.0.1.pom.sha1
@@ -0,0 +1 @@
+87072021313e113b29a7ea4025008259e99ae6b1
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar
new file mode 100644
index 0000000..2a39362
Binary files /dev/null and b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar differ
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.md5
new file mode 100644
index 0000000..e5aea0a
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.md5
@@ -0,0 +1 @@
+27c6777a52f527a7efbb4df32c2512e5
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.sha1
new file mode 100644
index 0000000..603e638
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.jar.sha1
@@ -0,0 +1 @@
+598f1ed21cb1b5d89a1ea9ee0123211f21ed67d3
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom
new file mode 100644
index 0000000..90901f2
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+ top.niunaijun.blackobfuscator
+ plugin
+ 1.0.2
+
+
+ com.android.tools.build
+ transform-api
+ 1.5.0
+ runtime
+
+
+ commons-io
+ commons-io
+ 2.5
+ runtime
+
+
+ com.github.CodingGay.BlackObfuscator
+ dex-tools
+ 2.1
+ runtime
+
+
+
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.md5
new file mode 100644
index 0000000..778f831
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.md5
@@ -0,0 +1 @@
+8a8b34cb96bc02a875597ce209302e46
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.sha1
new file mode 100644
index 0000000..d6f396e
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.2/plugin-1.0.2.pom.sha1
@@ -0,0 +1 @@
+655283ab363374fc0ea086307d4a4ed80c7c1572
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar
new file mode 100644
index 0000000..c7bc695
Binary files /dev/null and b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar differ
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.md5
new file mode 100644
index 0000000..815c7a3
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.md5
@@ -0,0 +1 @@
+249debbf4b43fda9b1264184482cc43c
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.sha1
new file mode 100644
index 0000000..3ce9e30
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.jar.sha1
@@ -0,0 +1 @@
+531ad837be966650c1987f0a234c1550eda92cd8
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom
new file mode 100644
index 0000000..b578892
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+ top.niunaijun.blackobfuscator
+ plugin
+ 1.0.3
+
+
+ com.android.tools.build
+ transform-api
+ 1.5.0
+ runtime
+
+
+ commons-io
+ commons-io
+ 2.5
+ runtime
+
+
+ com.github.CodingGay.BlackObfuscator
+ dex-tools
+ 2.1
+ runtime
+
+
+
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.md5
new file mode 100644
index 0000000..0f82cbb
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.md5
@@ -0,0 +1 @@
+8ddca8ad0f0d91ee7c7e3e2dd68db17a
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.sha1
new file mode 100644
index 0000000..64164fe
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.3/plugin-1.0.3.pom.sha1
@@ -0,0 +1 @@
+91ebe6cff18e41e3cf495bd2b5f70eafb98a8da9
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar
new file mode 100644
index 0000000..c6c8df7
Binary files /dev/null and b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar differ
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.md5
new file mode 100644
index 0000000..3343cc4
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.md5
@@ -0,0 +1 @@
+fa2641d8ceb1ad8dfd89cf2cd2e99592
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.sha1
new file mode 100644
index 0000000..783f5d4
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.jar.sha1
@@ -0,0 +1 @@
+50300b26c1c185a9f17a1b8af740311877f352a6
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom
new file mode 100644
index 0000000..6d35597
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+ top.niunaijun.blackobfuscator
+ plugin
+ 1.0.4
+
+
+ com.android.tools.build
+ transform-api
+ 1.5.0
+ runtime
+
+
+ commons-io
+ commons-io
+ 2.5
+ runtime
+
+
+ com.github.CodingGay.BlackObfuscator
+ dex-tools
+ 2.1
+ runtime
+
+
+
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.md5
new file mode 100644
index 0000000..54032d8
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.md5
@@ -0,0 +1 @@
+c4ff871445e1f4271eb1e4194c7ecbd8
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.sha1
new file mode 100644
index 0000000..bf4b8b3
--- /dev/null
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/1.0.4/plugin-1.0.4.pom.sha1
@@ -0,0 +1 @@
+dd6612e814a361a39f252c50871c47300f8aafaa
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml
index 39d1a89..71c0d3e 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml
@@ -3,10 +3,16 @@
top.niunaijun.blackobfuscator
plugin
- 1.0.0
+ 1.0.6
1.0.0
+ 1.0.1
+ 1.0.2
+ 1.0.3
+ 1.0.4
+ 1.0.5
+ 1.0.6
- 20220113045741
+ 20220403075502
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.md5 b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.md5
index 3dfae95..e19b24c 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.md5
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.md5
@@ -1 +1 @@
-a4e0ad7fcf21d4047bf1348dbbbeae58
\ No newline at end of file
+4b729cb58ee37a658cdbdeaec5886621
\ No newline at end of file
diff --git a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.sha1 b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.sha1
index fd40176..7c2a1eb 100644
--- a/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.sha1
+++ b/localRepo/top/niunaijun/blackobfuscator/plugin/maven-metadata.xml.sha1
@@ -1 +1 @@
-ef65fe9ba949d79e0d61ed67e5197027f3a5221b
\ No newline at end of file
+7e2a31627f480aa71549c5dcdff74da5746fba66
\ No newline at end of file
diff --git a/plugin/build.gradle b/plugin/build.gradle
index f003331..f3df135 100644
--- a/plugin/build.gradle
+++ b/plugin/build.gradle
@@ -1,10 +1,10 @@
apply plugin: 'groovy'
-//apply plugin: 'maven'
-apply plugin: 'com.github.dcendents.android-maven'
-
+apply plugin: 'maven'
+//apply plugin: 'com.github.dcendents.android-maven'
group='top.niunaijun.blackobfuscator'
dependencies {
- implementation "com.android.tools.build:gradle:3.3.1"
+ //implementation "com.android.tools.build:gradle:3.3.1"
+ compileOnly "com.android.tools.build:gradle:4.0.1"
implementation "com.android.tools.build:transform-api:1.5.0"
implementation "commons-io:commons-io:2.5"
//gradle sdk
@@ -22,16 +22,11 @@ repositories {
}
group='top.niunaijun.blackobfuscator'
-version='1.0.0'
-//uploadArchives {
-// repositories {
-// mavenDeployer {
-// //提交到远程服务器:
-// // repository(url: "http://www.xxx.com/repos") {
-// // authentication(userName: "admin", password: "admin")
-// // }
-// //本地的Maven地址设置为E:/Maven
-// repository(url: uri('../localRepo'))
-// }
-// }
-//}
\ No newline at end of file
+version='1.0.6'
+uploadArchives {
+ repositories{
+ mavenDeployer {
+ repository(url: uri('../localRepo'))
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy
index fe8d123..3b03bf3 100644
--- a/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy
+++ b/plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy
@@ -1,15 +1,9 @@
package top.niunaijun.blackobfuscator
-
import com.android.build.gradle.AppExtension
import com.android.build.gradle.api.ApplicationVariant
import com.android.build.gradle.internal.api.ReadOnlyProductFlavor
-import com.android.build.gradle.internal.dsl.BuildType
-import com.android.build.gradle.internal.dsl.ProductFlavor
-import com.android.build.gradle.internal.tasks.DexMergingTask
import org.gradle.api.*
-import org.gradle.api.internal.file.DefaultFilePropertyFactory
import top.niunaijun.blackobfuscator.core.ObfDex
-
public class ObfPlugin implements Plugin {
private String PLUGIN_NAME = "BlackObfuscator"
private Project mProject
@@ -17,35 +11,28 @@ public class ObfPlugin implements Plugin {
public Map mTaskMapping = new HashMap<>()
void apply(Project project) {
+ // 缓存project
this.mProject = project
+ // 获取android:AppExtension
def android = project.extensions.findByType(AppExtension)
+ // 自定义配置
project.configurations.create(PLUGIN_NAME).extendsFrom(project.configurations.implementation)
sObfuscatorExtension = project.extensions.create(PLUGIN_NAME, BlackObfuscatorExtension, project)
-
+ // 清理任务映射
mTaskMapping.clear()
+ // 输出日志提示信息
project.afterEvaluate {
System.out.println("=====BlackObfuscator=====")
System.out.println(sObfuscatorExtension.toString())
System.out.println("=========================")
}
-
+ // 配置自定义任务
project.afterEvaluate { ->
if (!sObfuscatorExtension.enabled) {
return
}
- def action = new Action() {
- @Override
- void execute(Task task) {
- task.getOutputs().getFiles().collect().each() { element ->
- def file = new File(element.toString())
- ObfDex.obf(file.getAbsolutePath(),
- sObfuscatorExtension.depth,
- sObfuscatorExtension.obfClass,
- sObfuscatorExtension.blackClass,
- mTaskMapping.get(task.name))
- }
- }
- }
+
+ //初始化任务列表
List tasks = new ArrayList<>()
if (android != null) {
android.applicationVariants.all(new Action() {
@@ -55,7 +42,9 @@ public class ObfPlugin implements Plugin {
if (applicationVariant.buildType.minifyEnabled) {
mappingFile = applicationVariant.mappingFile
}
+
def buildType = upperCaseFirst(applicationVariant.buildType.name)
+
boolean empty = true
for (ReadOnlyProductFlavor flavor : applicationVariant.productFlavors) {
def flavorName = upperCaseFirst(applicationVariant.flavorName)
@@ -70,9 +59,29 @@ public class ObfPlugin implements Plugin {
})
}
+ // 自定义action
+ def action = new Action() {
+ @Override
+ void execute(Task task) {
+ task.getOutputs().getFiles().collect().each() { element ->
+ def file = new File(element.toString())
+ def taskOutputFilePath = file.getAbsolutePath()
+ def mappingFilePath = mTaskMapping.get(task.name)
+ // 混淆核心逻辑
+ ObfDex.obf(taskOutputFilePath,
+ sObfuscatorExtension.depth,
+ sObfuscatorExtension.obfClass,
+ sObfuscatorExtension.blackClass,
+ mappingFilePath)
+ }
+ }
+ }
+
+ // 遍历任务列表 通过doLast 追加自定义action
for (Task task : tasks) {
task.doLast(action)
}
+
if (tasks.isEmpty()) {
System.err.println("This gradle version is not applicable. Please submit issues in https://github.com/CodingGay/BlackObfuscator-ASPlugin")
}
@@ -85,7 +94,6 @@ public class ObfPlugin implements Plugin {
addTask("mergeProjectDex${name}${buildType}", tasks, mappingFile)
addTask("transformDexArchiveWithDexMergerFor${name}${buildType}", tasks, mappingFile)
addTask("minify${name}${buildType}WithR8", tasks, mappingFile)
-
println("$name$buildType mappingFile $mappingFile")
}
diff --git a/plugin/src/main/java/com/wonson/CommonUtil.java b/plugin/src/main/java/com/wonson/CommonUtil.java
new file mode 100644
index 0000000..df5359c
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/CommonUtil.java
@@ -0,0 +1,9 @@
+package com.wonson;
+import java.util.UUID;
+public class CommonUtil {
+ public static String getRandomString(){
+ String s = UUID.randomUUID().toString();
+ String substring = s.substring(0, 8);
+ return substring;
+ }
+}
diff --git a/plugin/src/main/java/com/wonson/EncodeClassVisitor.java b/plugin/src/main/java/com/wonson/EncodeClassVisitor.java
new file mode 100644
index 0000000..e4e8169
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/EncodeClassVisitor.java
@@ -0,0 +1,61 @@
+package com.wonson;
+import org.objectweb.asm.*;
+import java.lang.reflect.Constructor;
+import java.util.Random;
+import static org.objectweb.asm.Opcodes.*;
+public class EncodeClassVisitor extends ClassVisitor {
+ private String owner;
+ private boolean on;
+ private String data_name;
+ private String index_name;
+ private Random random = new Random();
+ private Class extends EncodeMethodVisitor> encodeMethodVisitorClass;
+
+ public EncodeClassVisitor(int api, ClassVisitor classVisitor, Class extends EncodeMethodVisitor> encodeMethodVisitorClass) {
+ super(api, classVisitor);
+ this.encodeMethodVisitorClass = encodeMethodVisitorClass;
+ }
+
+ @Override
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+ super.visit(version, access, name, signature, superName, interfaces);
+ if ((access & ACC_ABSTRACT) != 0 || (access & ACC_INTERFACE) != 0 || (access & ACC_ENUM) != 0 || (access & ACC_ANNOTATION) != 0) {
+ on = false;
+ } else {
+ on = true;
+ }
+ System.out.println("encoding:" + name);
+ this.owner = name;
+ if(encodeMethodVisitorClass == EncodePlanAMethodVisitor.class && on){
+ data_name = "d_" + CommonUtil.getRandomString();
+ index_name = "i_" + CommonUtil.getRandomString();
+ FieldVisitor fv = cv.visitField(ACC_PUBLIC + ACC_STATIC, data_name, "[B", null, null);
+ fv.visitEnd();
+ fv = cv.visitField(ACC_PUBLIC + ACC_STATIC, index_name, "I", null, null);
+ fv.visitEnd();
+ }
+ }
+
+ @Override
+ public void visitSource(String source, String debug) {
+ super.visitSource("null", "null");
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
+ try {
+ Constructor extends EncodeMethodVisitor> constructor = encodeMethodVisitorClass.getConstructor(int.class, MethodVisitor.class);
+ EncodeMethodVisitor encodeMethodVisitor = constructor.newInstance(ASM7, methodVisitor);
+ encodeMethodVisitor.setOn(on);
+ encodeMethodVisitor.setData_name(data_name);
+ encodeMethodVisitor.setIndex_name(index_name);
+ encodeMethodVisitor.setOwner(owner);
+ encodeMethodVisitor.setRandom(random);
+ return encodeMethodVisitor;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return methodVisitor;
+ }
+ }
+}
diff --git a/plugin/src/main/java/com/wonson/EncodeMethodVisitor.java b/plugin/src/main/java/com/wonson/EncodeMethodVisitor.java
new file mode 100644
index 0000000..8a6514a
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/EncodeMethodVisitor.java
@@ -0,0 +1,35 @@
+package com.wonson;
+import org.objectweb.asm.MethodVisitor;
+import java.util.Random;
+public abstract class EncodeMethodVisitor extends MethodVisitor{
+ protected boolean on;
+ protected Random random;
+ protected String owner;
+ protected String data_name;
+ protected String index_name;
+
+ public void setOn(boolean on) {
+ this.on = on;
+ }
+
+ public void setRandom(Random random) {
+ this.random = random;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public void setData_name(String data_name) {
+ this.data_name = data_name;
+ }
+
+ public void setIndex_name(String index_name) {
+ this.index_name = index_name;
+ }
+
+ public EncodeMethodVisitor(int api, MethodVisitor methodVisitor) {
+ super(api, methodVisitor);
+ }
+
+}
diff --git a/plugin/src/main/java/com/wonson/EncodePlanAMethodVisitor.java b/plugin/src/main/java/com/wonson/EncodePlanAMethodVisitor.java
new file mode 100644
index 0000000..0cafe2c
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/EncodePlanAMethodVisitor.java
@@ -0,0 +1,13 @@
+package com.wonson;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+public class EncodePlanAMethodVisitor extends EncodeMethodVisitor{
+ public EncodePlanAMethodVisitor(int api, MethodVisitor methodVisitor) {
+ super(api, methodVisitor);
+ }
+ @Override
+ public void visitLineNumber(int line, Label start) {}
+
+ @Override
+ public void visitLocalVariable(String name, String descriptor, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index) {}
+}
diff --git a/plugin/src/main/java/com/wonson/EncodePlanBMethodVisitor.java b/plugin/src/main/java/com/wonson/EncodePlanBMethodVisitor.java
new file mode 100644
index 0000000..5aa4773
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/EncodePlanBMethodVisitor.java
@@ -0,0 +1,52 @@
+package com.wonson;
+import org.objectweb.asm.MethodVisitor;
+import java.util.Base64;
+import static org.objectweb.asm.Opcodes.*;
+import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
+public class EncodePlanBMethodVisitor extends EncodePlanAMethodVisitor{
+
+ public EncodePlanBMethodVisitor(int api, MethodVisitor methodVisitor) {
+ super(api, methodVisitor);
+ }
+
+ @Override
+ public void visitLdcInsn(Object cst) {
+ if(cst != null && cst instanceof String){
+ String target = String.class.cast(cst);
+ //˵ַ
+ if(target.length() == 0) {
+ mv.visitLdcInsn(cst);
+ } else {
+ // һ ýջ
+ mv.visitTypeInsn(NEW, "java/lang/String");
+ mv.visitInsn(DUP);
+ mv.visitMethodInsn(INVOKESTATIC, "java/util/Base64", "getDecoder", "()Ljava/util/Base64$Decoder;", false);
+ byte[] encode = Base64.getEncoder().encode(target.getBytes());
+ //
+ // BIPUSH: һbyteͳֵջ
+ // mv.visitIntInsn(BIPUSH,encode.length);
+ mv.visitLdcInsn(encode.length);
+ // ջֵcountΪ鳤ȣһ顣ջֵջýջ
+ mv.visitIntInsn(NEWARRAY,T_BYTE);
+ //ջֵҸֵջ
+ mv.visitInsn(DUP);
+ //ֵ
+ for(int index = 0; index < encode.length;index++){
+ mv.visitLdcInsn(index);
+ mv.visitIntInsn(BIPUSH,encode[index]);
+ //ջbooleanbyteֵָָ±괦
+ mv.visitInsn(BASTORE);
+ if(index < encode.length - 1) {
+ mv.visitInsn(DUP);
+ }
+ }
+ //
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/Base64$Decoder", "decode", "([B)[B", false);
+ // ó췽ʵʼ˽з
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/String", "", "([B)V", false);
+ }
+ } else {
+ super.visitLdcInsn(cst);
+ }
+ }
+}
diff --git a/plugin/src/main/java/com/wonson/Operator.java b/plugin/src/main/java/com/wonson/Operator.java
new file mode 100644
index 0000000..c2574cc
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/Operator.java
@@ -0,0 +1,85 @@
+package com.wonson;
+import org.objectweb.asm.*;
+import java.io.*;
+import java.util.*;
+import static org.objectweb.asm.Opcodes.*;
+public class Operator {
+ public static void run(File input_jar,File output_jar,boolean delete_input){
+ try {
+ ZipFileHelper zipFileHelper = new ZipFileHelper(input_jar, output_jar);
+ List zip_entry_names = zipFileHelper.new_zip_entry_names;
+ Iterator iterator = zip_entry_names.iterator();
+ while (iterator.hasNext()){
+ String entry_name = iterator.next();
+ if(entry_name.endsWith(".class")){
+ InputStream entryInputStream = zipFileHelper.getEntryInputStream(entry_name,true);
+ byte[] ret = start(entryInputStream);
+ zipFileHelper.add_entry(entry_name,ret);
+ }
+ }
+ zipFileHelper.commit();
+ if(delete_input) {
+ input_jar.delete();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void run(File file){
+ if(file.isDirectory()){
+ FileFilter fileFilter = new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ if (!pathname.isDirectory() && !pathname.getName().endsWith(".class")) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ };
+ File[] files = file.listFiles(fileFilter);
+ for (File listFile : files) {
+ run(listFile);
+ }
+ }else {
+ start(file);
+ }
+ }
+
+ private static void start(File classFile) {
+ try {
+ FileInputStream fileInputStream = new FileInputStream(classFile);
+ byte[] ret = start(fileInputStream);
+ FileOutputStream fileOutputStream = new FileOutputStream(classFile);
+ fileOutputStream.write(ret);
+ fileInputStream.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static byte[] start(InputStream inputStream) throws IOException {
+ byte[] bytes = ZipFileHelper.inputStreamToByteArray(inputStream);
+ return start(bytes);
+ }
+
+ private static byte[] start(byte[] classByteCode){
+ byte[] back_up = new byte[classByteCode.length];
+ for (int index = 0; index < back_up.length; index++){
+ back_up[index] = classByteCode[index];
+ }
+ ClassReader classReader = new ClassReader(classByteCode);
+ ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ ClassVisitor classVisitor = new EncodeClassVisitor(ASM7,classWriter,EncodePlanBMethodVisitor.class);
+ classReader.accept(classVisitor,ClassReader.SKIP_DEBUG);
+ try {
+ return classWriter.toByteArray();
+ }catch (Exception exception){
+ exception.printStackTrace();
+ return back_up;
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/main/java/com/wonson/ZipFileHelper.java b/plugin/src/main/java/com/wonson/ZipFileHelper.java
new file mode 100644
index 0000000..47c32eb
--- /dev/null
+++ b/plugin/src/main/java/com/wonson/ZipFileHelper.java
@@ -0,0 +1,130 @@
+package com.wonson;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+public class ZipFileHelper {
+ protected List old_zip_entry_names;
+ protected List new_zip_entry_names;
+ protected ZipFile op_zip_file;
+ protected ZipOutputStream zipOutputStream;
+ protected String zip_input_file_path;
+
+ public ZipFileHelper(File zip_input_file,File zip_output_file) throws IOException {
+ this.zip_input_file_path = zip_input_file.getAbsolutePath();
+ this.op_zip_file = new ZipFile(zip_input_file);
+ this.zipOutputStream = new ZipOutputStream(new FileOutputStream(zip_output_file));
+ this.old_zip_entry_names = new ArrayList<>();
+ this.new_zip_entry_names = new ArrayList<>();
+ Enumeration extends ZipEntry> entries = op_zip_file.entries();
+ while (entries.hasMoreElements()){
+ ZipEntry zipEntry = entries.nextElement();
+ String entryName = zipEntry.getName();
+ old_zip_entry_names.add(entryName);
+ new_zip_entry_names.add(entryName);
+ }
+ }
+
+ public void commit() throws IOException {
+ Iterator iterator = old_zip_entry_names.iterator();
+ while (iterator.hasNext()){
+ String next = iterator.next();
+ ZipEntry entry = op_zip_file.getEntry(next);
+ ZipEntry zipEntry = new ZipEntry(next);
+ zipOutputStream.putNextEntry(zipEntry);
+ InputStream inputStream = op_zip_file.getInputStream(entry);
+ write_to_outputStream_from_inputStream(inputStream,zipOutputStream,false);
+ zipOutputStream.closeEntry();
+ }
+ zipOutputStream.close();
+ op_zip_file.close();
+ }
+
+ public boolean remove_entry(String entry_name){
+ if(entry_name.startsWith("/")){
+ entry_name = entry_name.substring(1);
+ }
+ return old_zip_entry_names.remove(entry_name);
+ }
+
+ public void remove_all_entry(){
+ old_zip_entry_names.clear();
+ }
+
+ public void recover_entry(String entry_name){
+ if(entry_name.startsWith("/")) entry_name = entry_name.substring(1);
+ old_zip_entry_names.add(entry_name);
+ }
+
+ public void add_entry(String entry_name,InputStream inputStream) throws IOException {
+ entry_name = filter(entry_name);
+ ZipEntry zipEntry = new ZipEntry(entry_name);
+ zipOutputStream.putNextEntry(zipEntry);
+ write_to_outputStream_from_inputStream(inputStream,zipOutputStream,false);
+ zipOutputStream.closeEntry();
+ }
+
+ public void add_entry(String entry_name,String text) throws IOException {
+ entry_name = filter(entry_name);
+ ZipEntry zipEntry = new ZipEntry(entry_name);
+ zipOutputStream.putNextEntry(zipEntry);
+ zipOutputStream.write(text.getBytes());
+ zipOutputStream.closeEntry();
+ }
+
+ public void add_entry(String entry_name,byte[] data) throws IOException {
+ entry_name = filter(entry_name);
+ ZipEntry zipEntry = new ZipEntry(entry_name);
+ zipOutputStream.putNextEntry(zipEntry);
+ zipOutputStream.write(data);
+ zipOutputStream.closeEntry();
+ }
+
+ public byte[] getEntryByteArray(String entry_name,boolean remove_entry) throws IOException {
+ InputStream entryInputStream = getEntryInputStream(entry_name,remove_entry);
+ byte[] bytes = inputStreamToByteArray(entryInputStream);
+ return bytes;
+ }
+
+ public InputStream getEntryInputStream(String entry_name,boolean remove_entry) throws IOException {
+ if(entry_name.startsWith("/")) entry_name.substring(1);
+ ZipEntry zipEntry = op_zip_file.getEntry(entry_name);
+ InputStream inputStream = op_zip_file.getInputStream(zipEntry);
+ if(remove_entry) remove_entry(entry_name);
+ return inputStream;
+ }
+
+ private void write_to_outputStream_from_inputStream(InputStream inputStream, OutputStream outputStream,boolean close_outputStream) throws IOException {
+ int offset;
+ byte[] buffer = new byte[1024];
+ while ((offset = inputStream.read(buffer)) != -1) outputStream.write(buffer,0,offset);
+ inputStream.close();
+ if(close_outputStream) outputStream.close();
+ }
+
+ private String filter(String entry_name) throws IOException {
+ if(entry_name.startsWith("/")) entry_name = entry_name.substring(1);
+ if(old_zip_entry_names.contains(entry_name)){
+ boolean ok = remove_entry(entry_name);
+ String failed_to_remove = new StringBuilder("failed to remove ").append(entry_name).toString();
+ if(!ok) throw new IOException(failed_to_remove);
+ }
+ return entry_name;
+ }
+
+ public static byte[] inputStreamToByteArray(InputStream inputStream) throws IOException {
+ byte[] result = null;
+ byte[] buffer = new byte[1024];
+ int offset;
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ while ((offset = inputStream.read(buffer)) != -1) byteArrayOutputStream.write(buffer,0,offset);
+ result = byteArrayOutputStream.toByteArray();
+ byteArrayOutputStream.close();
+ inputStream.close();
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java b/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java
index e33e521..2725167 100644
--- a/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java
+++ b/plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java
@@ -1,18 +1,15 @@
package top.niunaijun.blackobfuscator.core;
-
import com.googlecode.dex2jar.tools.Dex2jarCmd;
import com.googlecode.dex2jar.tools.Jar2Dex;
-
+import com.wonson.Operator;
import org.jf.DexLib2Utils;
import org.jf.util.TrieTree;
-
import java.io.File;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import top.niunaijun.obfuscator.ObfuscatorConfiguration;
-
/**
* Created by Milk on 2021/12/17.
* * ∧_∧
@@ -27,8 +24,7 @@ public static void obf(String dir, int depth, String[] obfClass, String[] blackC
Mapping mapping = new Mapping(mappingFile);
if (file.isDirectory()) {
File[] files = file.listFiles();
- if (files == null)
- return;
+ if (files == null) return;
for (File input : files) {
if (input.isFile()) {
handleDex(input, depth, obfClass, blackClass, mapping);
@@ -42,21 +38,21 @@ public static void obf(String dir, int depth, String[] obfClass, String[] blackC
}
private static void handleDex(File input, int depth, String[] obfClass, String[] blackClass, Mapping mapping) {
- if (!input.getAbsolutePath().endsWith(".dex"))
- return;
+ if (!input.getAbsolutePath().endsWith(".dex")) return;
File tempJar = null;
File splitDex = null;
File obfDex = null;
+ File new_tempJar = null;
try {
tempJar = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".jar");
splitDex = new File(input.getParent(), System.currentTimeMillis() + "split" + input.getName() + ".dex");
obfDex = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".dex");
+ new_tempJar = new File(tempJar.getParent(), "new_" + tempJar.getName());
List obfClassList = arrayToList(obfClass);
List blackClassList = arrayToList(blackClass);
-
+ // 解析官方的类名混淆文件 获取白名单中被映射后的类名
TrieTree whiteListTree = new TrieTree();
whiteListTree.addAll(obfClassList);
-
for (String aClass : mapping.getMapping().keySet()) {
if (whiteListTree.search(aClass)) {
String orig = mapping.get(aClass);
@@ -66,7 +62,7 @@ private static void handleDex(File input, int depth, String[] obfClass, String[]
}
}
}
-
+ // 解析官方的类名混淆文件 获取黑名单中被映射后的类名
TrieTree blackListTree = new TrieTree();
blackListTree.addAll(blackClassList);
List tmpBlackClass = new ArrayList<>(blackClassList);
@@ -79,13 +75,20 @@ private static void handleDex(File input, int depth, String[] obfClass, String[]
}
}
}
+
+ // 通过dexLib2 解析出在obfClassList&&不在blackClassList中的类 分别编译成smali文件 再合并成新的dex文件
+ // 并输出到splitDex指定的路径
long l = DexLib2Utils.splitDex(input, splitDex, obfClassList, blackClassList);
if (l <= 0) {
System.out.println("Obfuscator Class not found");
return;
}
- new Dex2jarCmd(new ObfuscatorConfiguration() {
+ // 实例化混淆配置
+ ObfuscatorConfiguration obfuscatorConfiguration = new ObfuscatorConfiguration() {
+ private int depth;
+ private boolean accept;
+
@Override
public int getObfDepth() {
return depth;
@@ -93,16 +96,35 @@ public int getObfDepth() {
@Override
public boolean accept(String className, String methodName) {
- System.out.println("BlackObf Class: " + className + "#" + methodName);
- return super.accept(className, methodName);
+ if(accept) System.out.println("BlackObf Class: " + className + "#" + methodName);
+ return accept;
+ }
+
+ public void setAccept(boolean accept) {
+ this.accept = accept;
+ }
+
+ public void setDepth(int depth){
+ this.depth = depth;
}
- }).doMain("-f", splitDex.getAbsolutePath(), "-o", tempJar.getAbsolutePath());
- new Jar2Dex().doMain("-f", "-o", obfDex.getAbsolutePath(), tempJar.getAbsolutePath());
+ };
+ Class extends ObfuscatorConfiguration> obfuscatorConfigurationClass = obfuscatorConfiguration.getClass();
+ Method setDepth = obfuscatorConfigurationClass.getDeclaredMethod("setDepth", int.class);
+ Method setAccept = obfuscatorConfigurationClass.getDeclaredMethod("setAccept", boolean.class);
+ // 控制流混淆
+ setDepth.invoke(obfuscatorConfiguration,depth);
+ setAccept.invoke(obfuscatorConfiguration,true);
+ new Dex2jarCmd(obfuscatorConfiguration).doMain("-f", splitDex.getAbsolutePath(), "-o", tempJar.getAbsolutePath());
+ // 字符串加密
+ Operator.run(tempJar,new_tempJar,true);
+ new Jar2Dex().doMain("-f", "-o", obfDex.getAbsolutePath(), new_tempJar.getAbsolutePath());
+ // 合并
DexLib2Utils.mergerAndCoverDexFile(input, obfDex, input);
} catch (Throwable t) {
t.printStackTrace();
} finally {
tempJar.delete();
+ new_tempJar.delete();
splitDex.delete();
obfDex.delete();
}