Skip to content

Commit 4d87d2e

Browse files
authored
Merge pull request #343 from ThexXTURBOXx/smali
Properly fix Smali and Dex2Jar
2 parents a8d89ec + 531b373 commit 4d87d2e

37 files changed

+38
-74
lines changed

libs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Some dependencies may have been modified or could be released by their author in
2121

2222
- `JD-GUI`: Removed ASM and RSyntaxTextArea
2323
- `APKTool`: Recompiled with the newest dependency versions, removed prebuilt folder
24-
- `DarkLAF`: Merged core & windows libraries for 2.6.2-20210719.010320-83
24+
- `DX`: Just taken from build-tools without modifications
25+
- `D2Jar`: Compiled from scratch
Binary file not shown.

libs/com/android/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.jar.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.pom.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.pom.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/D2Jar-obf/maven-metadata.xml.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/D2Jar-obf/maven-metadata.xml.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/1.16bcv/DX-1.16bcv.jar.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/1.16bcv/DX-1.16bcv.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/1.16bcv/DX-1.16bcv.pom.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/1.16bcv/DX-1.16bcv.pom.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/maven-metadata.xml.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/com/android/DX/maven-metadata.xml.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
27ccd6872887a6fa467c9f773f9fd218
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ee70c208b9469e07dff48294d37ca4dfd009216c

libs/com/android/DX/1.16bcv/DX-1.16bcv.pom renamed to libs/com/android/dx/30.0.3/dx-30.0.3.pom

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.android</groupId>
6-
<artifactId>DX</artifactId>
7-
<version>1.16bcv</version>
6+
<artifactId>dx</artifactId>
7+
<version>30.0.3</version>
88
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1c8d965abdb64d5e7869fe7abd0f8f16
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e0c4f44b6eff749939e1cd6f2d2aa5ba2d9281d7
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<metadata>
33
<groupId>com.android</groupId>
4-
<artifactId>DX</artifactId>
4+
<artifactId>dx</artifactId>
55
<versioning>
6-
<release>1.16bcv</release>
6+
<release>30.0.3</release>
77
<versions>
8-
<version>1.16bcv</version>
8+
<version>30.0.3</version>
99
</versions>
10-
<lastUpdated>20210622185015</lastUpdated>
10+
<lastUpdated>20210809171340</lastUpdated>
1111
</versioning>
1212
</metadata>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9fc6457b2aaaca1869f9e0f1aab372d4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5e542c95e397f2b4c3f2b150360e39aa519f0863
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
81084e179c8ac7f9638de6fb749f1a0e
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a517e7a01c6d60dab4ea1645504c9ed9887a9190

libs/com/android/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.pom renamed to libs/com/googlecode/D2Jar-obf/1.0bcv/D2Jar-obf-1.0bcv.pom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44
<modelVersion>4.0.0</modelVersion>
5-
<groupId>com.android</groupId>
5+
<groupId>com.googlecode</groupId>
66
<artifactId>D2Jar-obf</artifactId>
77
<version>1.0bcv</version>
88
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c2145a55e8a96475489adebd58ea4968
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e45f03179f6fc5a3becb4eda787c34fae28f93e5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<metadata>
3-
<groupId>com.android</groupId>
3+
<groupId>com.googlecode</groupId>
44
<artifactId>D2Jar-obf</artifactId>
55
<versioning>
66
<release>1.0bcv</release>
77
<versions>
88
<version>1.0bcv</version>
99
</versions>
10-
<lastUpdated>20210622185021</lastUpdated>
10+
<lastUpdated>20210809231039</lastUpdated>
1111
</versioning>
1212
</metadata>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d54ac62e2043b2db34f2fcaad089de7c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
51083035146a191d5a37266136f5a19a3b2d78c9

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@
211211
</dependency>
212212
<dependency>
213213
<groupId>com.android</groupId>
214-
<artifactId>DX</artifactId>
215-
<version>1.16bcv</version>
214+
<artifactId>dx</artifactId>
215+
<version>30.0.3</version>
216216
</dependency>
217217
<dependency>
218-
<groupId>com.android</groupId>
218+
<groupId>com.googlecode</groupId>
219219
<artifactId>D2Jar-obf</artifactId>
220220
<version>1.0bcv</version>
221221
</dependency>
@@ -232,7 +232,7 @@
232232
<dependency>
233233
<groupId>com.github.gotson</groupId>
234234
<artifactId>webp-imageio</artifactId>
235-
<version>0.2.1</version>
235+
<version>0.2.2</version>
236236
</dependency>
237237
<dependency>
238238
<groupId>de.skuzzle</groupId>

src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/SmaliAssembler.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ public byte[] compile(String contents, String fullyQualifiedName)
6161
}
6262

6363
try {
64-
com.googlecode.d2j.smali.SmaliCmd.main(new String[]{
65-
tempSmaliFolder.getAbsolutePath(),
66-
//"-o", tempDex.getAbsolutePath()
67-
});
64+
com.googlecode.d2j.smali.SmaliCmd.main(tempSmaliFolder.getAbsolutePath(),
65+
"-o", tempDex.getAbsolutePath());
6866
} catch (Exception e) {
6967
e.printStackTrace();
7068
//BytecodeViewer.handleException(e);

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.apache.commons.io.FileUtils;
1111
import org.objectweb.asm.tree.ClassNode;
1212
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
13+
import the.bytecode.club.bytecodeviewer.Constants;
1314
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
1415
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
1516
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
@@ -55,6 +56,7 @@ public String decompileClassNode(ClassNode cn, byte[] b)
5556

5657
final File tempClass = new File(start + ".class");
5758
final File tempDex = new File(start + ".dex");
59+
final File tempDexOut = new File(start + "-out");
5860
final File tempSmali = new File(start + "-smali"); //output directory
5961

6062
try (FileOutputStream fos = new FileOutputStream(tempClass)) {
@@ -68,7 +70,8 @@ public String decompileClassNode(ClassNode cn, byte[] b)
6870
Dex2Jar.saveAsDex(tempClass, tempDex, true);
6971

7072
try {
71-
com.googlecode.d2j.smali.BaksmaliCmd.main(new String[]{tempDex.getAbsolutePath()});
73+
com.googlecode.d2j.smali.BaksmaliCmd.main(tempDex.getAbsolutePath(),
74+
"-o", tempDexOut.getAbsolutePath());
7275
} catch (Exception e) {
7376
StringWriter sw = new StringWriter();
7477
e.printStackTrace(new PrintWriter(sw));
@@ -77,10 +80,8 @@ public String decompileClassNode(ClassNode cn, byte[] b)
7780
exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
7881
}
7982

80-
File rename = new File(tempDex.getName().replaceFirst("\\.dex", "-out"));
81-
8283
try {
83-
FileUtils.moveDirectory(rename, tempSmali);
84+
FileUtils.moveDirectory(tempDexOut, tempSmali);
8485
} catch (IOException e) {
8586
StringWriter sw = new StringWriter();
8687
e.printStackTrace(new PrintWriter(sw));

src/main/java/the/bytecode/club/bytecodeviewer/util/Dex2Jar.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
55

66
import java.io.File;
7-
import java.io.IOException;
8-
import java.lang.reflect.Field;
97

108
/***************************************************************************
119
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@@ -50,16 +48,6 @@ public static synchronized void dex2Jar(File input, File output) {
5048
}
5149
}
5250

53-
// TODO fix this properly
54-
private static void applyErrorFix(com.googlecode.dex2jar.tools.Dex2jarCmd cmd) {
55-
try {
56-
Field f = com.googlecode.dex2jar.tools.Dex2jarCmd.class.getDeclaredField("notHandleException");
57-
f.setAccessible(true);
58-
f.set(cmd, true);
59-
} catch (Throwable ignored) {
60-
}
61-
}
62-
6351
/**
6452
* Converts a .jar to .dex
6553
*
@@ -72,28 +60,7 @@ public static synchronized void saveAsDex(File input, File output) {
7260

7361
public static synchronized void saveAsDex(File input, File output, boolean delete) {
7462
try {
75-
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath());
76-
File currentDexLocation = new File("./" + input.getName());
77-
78-
if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".jar")) {
79-
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.jar", "-jar2dex"
80-
+ ".dex"));
81-
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".apk")) {
82-
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.apk", "-jar2dex"
83-
+ ".dex"));
84-
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".dex")) {
85-
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.dex", "-jar2dex"
86-
+ ".dex"));
87-
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".zip")) {
88-
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.zip", "-jar2dex"
89-
+ ".dex"));
90-
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".class")) {
91-
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.class", "-jar2dex"
92-
+ ".dex"));
93-
}
94-
95-
currentDexLocation.renameTo(output);
96-
63+
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(), "-o", output.getAbsolutePath());
9764
if (delete)
9865
input.delete();
9966
} catch (Exception e) {

src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ public void checkMulticast(InetAddress maddr) {
256256
@SuppressWarnings("deprecation")
257257
public void checkMulticast(InetAddress maddr, byte ttl) {
258258
}
259-
260-
@SuppressWarnings("deprecation")
259+
261260
public void checkPackageAccess(String pkg) {
262261
if(printingPackage)
263262
System.out.println("Accessing: " + pkg);
@@ -335,9 +334,7 @@ public void checkWrite(String file) {
335334
{
336335
throw new SecurityException(e);
337336
}
338-
339-
//TODO temporarily removed to fix #339
340-
// a proper fix is to edit the smali disassembler
341-
//throw new SecurityException("BCV is awesome, blocking write(" + file + ");");
337+
338+
throw new SecurityException("BCV is awesome, blocking write(" + file + ");");
342339
}
343340
}

0 commit comments

Comments
 (0)