Skip to content

Commit 0065e8e

Browse files
committed
obfuscator script 0.3
1 parent 9bbda8c commit 0065e8e

File tree

9 files changed

+45
-57
lines changed

9 files changed

+45
-57
lines changed

AndroidStringObfuscator.jar

-3.45 MB
Binary file not shown.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Note that there is a difference between release and debug fingerprint.
88
Installation
99
------------
1010

11-
Put [AndroidStringObfuscator.jar](https://github.com/efraespada/AndroidStringObfuscator/raw/master/AndroidStringObfuscator.jar) on the app's module folder, next to "build.gradle" file and "build" folder.
11+
Put [AndroidStringObfuscator.jar](https://github.com/efraespada/AndroidStringObfuscator/raw/master/sample/AndroidStringObfuscator.jar) on the app's module folder, next to "build.gradle" file and "build" folder.
1212

1313
#### Gradle
1414

@@ -48,6 +48,8 @@ android.applicationVariants.all{ variant ->
4848
```
4949

5050

51+
52+
5153
Get encrypted strings
5254
---------------------
5355
You don't need to do anything. The script will encrypt all string tags with [hidden="true"] as attribute.

androidstringobfuscator/androidstringobfuscator.iml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@
6767
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6868
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
6969
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
70-
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
71-
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
72-
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
73-
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
74-
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
75-
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
76-
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
77-
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
7870
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
7971
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
8072
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -83,11 +75,16 @@
8375
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
8476
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8577
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
86-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
78+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
79+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
80+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
81+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
83+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
84+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
85+
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8786
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8887
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
89-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
90-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
9188
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.2/jars" />
9289
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.2.2/jars" />
9390
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.5/jars" />
@@ -103,43 +100,39 @@
103100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.2.1/jars" />
104101
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" />
105102
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
106-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
107-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
108103
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
109104
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
110105
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
111106
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
112107
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
113108
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
114-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
115-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/typedefs.txt" />
116109
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
117-
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
118110
</content>
119111
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
120112
<orderEntry type="sourceFolder" forTests="false" />
121113
<orderEntry type="library" exported="" name="support-v4-24.2.1" level="project" />
122114
<orderEntry type="library" exported="" name="support-compat-24.2.1" level="project" />
123115
<orderEntry type="library" exported="" name="support-media-compat-24.2.1" level="project" />
124116
<orderEntry type="library" exported="" name="animated-vector-drawable-24.2.1" level="project" />
125-
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
126117
<orderEntry type="library" exported="" name="support-fragment-24.2.1" level="project" />
118+
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
119+
<orderEntry type="library" exported="" name="support-core-ui-24.2.1" level="project" />
127120
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
128121
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
129-
<orderEntry type="library" exported="" name="support-core-ui-24.2.1" level="project" />
130122
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
131123
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
132124
<orderEntry type="library" exported="" name="appcompat-v7-24.2.1" level="project" />
133125
<orderEntry type="library" exported="" name="support-vector-drawable-24.2.1" level="project" />
126+
<orderEntry type="library" exported="" name="support-core-utils-24.2.1" level="project" />
134127
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
135128
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
136-
<orderEntry type="library" exported="" name="support-core-utils-24.2.1" level="project" />
137129
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
138130
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.3" level="project" />
139131
<orderEntry type="library" exported="" name="support-annotations-24.2.1" level="project" />
140132
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
141133
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
142134
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
143135
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
136+
<orderEntry type="library" exported="" name="android-android-24" level="project" />
144137
</component>
145138
</module>

local.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Location of the SDK. This is only used by Gradle.
88
# For customization when using a Version Control System, please read the
99
# header note.
10-
#Fri Oct 07 17:23:33 CEST 2016
10+
#Mon Oct 10 09:24:10 CEST 2016
1111
bintrayUser=efff
12+
ndk.dir=C\:\\Users\\Efra\\AppData\\Local\\Android\\Sdk\\ndk-bundle
1213
bintrayApiKey=1acf1ed062001f9a372e2391fdd0c16aed54a88a
13-
sdk.dir=/Users/efrainespada/Library/Android/sdk
14+
sdk.dir=C\:\\Users\\Efra\\AppData\\Local\\Android\\Sdk

obfuscator-script/.classpath

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,5 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/apache-commons-lang.jar"/>
6-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/commons-codec-1.7.jar"/>
7-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/ezmorph-1.0.6.jar"/>
8-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/json-lib.jar"/>
9-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/org-apache-commons-logging.jar"/>
10-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/org.apache.commons.beanutils.jar"/>
11-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/org.apache.commons.collections.jar"/>
12-
<classpathentry exported="true" kind="lib" path="/Users/efrainespada/Desktop/AndroidStringObfuscator/obfuscator-script/src/libs/xom-1.2.10.jar"/>
135
<classpathentry kind="output" path="bin"/>
146
</classpath>

obfuscator-script/src/main/Core.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class Core {
1818
public static void main(String[] args) {
1919

2020
String xml = "";
21-
System.out.println(":obfuscator-script:hello!");
21+
System.out.println(":obfuscator-script: -----------------------------------------------------------------------------");
22+
System.out.println(":obfuscator-script: v0.3 --- bugs or improvements to https://github.com/efraespada/AndroidStringObfuscator/issues");
23+
System.out.println(":obfuscator-script: -----------------------------------------------------------------------------");
2224

2325
if (args.length != 2) {
2426
System.out.println(":obfuscator-script: -> params [xml_file_name] [SHA1_fingerprint_app]");
@@ -62,7 +64,7 @@ public static void main(String[] args) {
6264

6365
File xmlFile = new File(fingerFolder, "strings.xml");
6466
writeFile(xmlFile, xml);
65-
System.out.println(":obfuscator-script:end");
67+
System.out.println(":obfuscator-script: -----------------------------------------------------------------------------");
6668
}
6769

6870
public static String getString(BufferedReader br) {
@@ -97,9 +99,9 @@ public static boolean isEncrypted(String value, String key) {
9799
try {
98100
if (AES.decrypt(value, key).equals(value)) { // not encrypted value
99101
encrypted = false;
100-
}
102+
} else encrypted = true;
101103
} catch (Exception e) {
102-
e.printStackTrace();
104+
encrypted = false;
103105
}
104106
return encrypted;
105107
}
@@ -114,11 +116,26 @@ public static String find(String xmlO, String key) {
114116
String result = extrac(toAnalyze);
115117

116118
try {
117-
String encrypted = AES.encrypt(result, key);
118-
xmlO = xmlO.replaceAll(result, encrypted);
119-
String toShow = result.length() > 8 ? result.substring(0, 8) + ".." : result;
120-
String toShow_ = encrypted.length() > 8 ? encrypted.substring(0, 8) + ".." : encrypted;
121-
System.out.println(":obfuscator-script: -> " + toShow + " -> " + toShow_);
119+
String encrypted = "";
120+
String toShow = "";
121+
122+
String extra = " value_already_encrypted";
123+
boolean hasExtra = false;
124+
125+
if (isEncrypted(result, key)) {
126+
encrypted = result;
127+
toShow = AES.decrypt(result, key);
128+
hasExtra = true;
129+
} else {
130+
encrypted = AES.encrypt(result, key);
131+
toShow = result;
132+
xmlO = xmlO.replaceAll(result, encrypted);
133+
}
134+
135+
136+
toShow = toShow.length() > 8 ? toShow.substring(0, 8) + ".." : toShow;
137+
encrypted = encrypted.length() > 8 ? encrypted.substring(0, 8) + ".." : encrypted;
138+
System.out.println(":obfuscator-script: -> [" + toShow + "] - [" + encrypted + "]" + (hasExtra ? extra : ""));
122139
} catch (Exception e) {
123140
System.out.println("error on " + result);
124141
e.printStackTrace();

obfuscator-script/strings.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

sample/AndroidStringObfuscator.jar

-1.72 MB
Binary file not shown.

sample/sample.iml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@
8282
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
8383
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8484
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
85-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8685
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
87-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
88-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
8986
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.2/jars" />
9087
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.2.2/jars" />
9188
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.5/jars" />
@@ -102,23 +99,11 @@
10299
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" />
103100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/efraespada/androidstringobfuscator/0.2/jars" />
104101
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
105-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
106-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
107-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
108-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
109-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
110-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
111-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
112102
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
113-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
114103
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
115-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
116104
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
117-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
118105
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
119-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
120106
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
121-
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
122107
</content>
123108
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
124109
<orderEntry type="sourceFolder" forTests="false" />
@@ -146,5 +131,6 @@
146131
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
147132
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
148133
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
134+
<orderEntry type="library" exported="" name="android-android-24" level="project" />
149135
</component>
150136
</module>

0 commit comments

Comments
 (0)