Properly fix Smali

This commit is contained in:
Nico Mexis 2021-08-09 19:37:52 +02:00
parent 8117aaecad
commit aebba0d704
No known key found for this signature in database
GPG Key ID: 27D6E17CE092AB78

AI 샘플 코드 생성 중입니다

Loading...
34 changed files with 35 additions and 72 deletions

View File

@ -1 +0,0 @@
f917a330ef6379f8976ce3761e30e0fc

View File

@ -1 +0,0 @@
f5fbd039a4c3161b2a3db817786b39366e2cd796

View File

@ -1 +0,0 @@
08b71893e812afc9c2670a92acdded46

View File

@ -1 +0,0 @@
d0eb90a0d8eb49d0a9573224000c859358610783

View File

@ -1 +0,0 @@
0591d48d90ee4e7bcf92f9995686d3cb

View File

@ -1 +0,0 @@
24a479a29c3fe9293a6ccf69d975e0f3a3b09546

View File

@ -1 +0,0 @@
cab2e66e5444aaab6a440f7afa4f7829

View File

@ -1 +0,0 @@
9aee7f4031c7717c9dd18a61410d81cdbc4c7fb9

View File

@ -1 +0,0 @@
5d95e64f137ec77ddf401d25771b671c

View File

@ -1 +0,0 @@
926db5c7f9b2abf84fa1b17063e6676af73b9fcf

View File

@ -0,0 +1 @@
27ccd6872887a6fa467c9f773f9fd218

View File

@ -0,0 +1 @@
ee70c208b9469e07dff48294d37ca4dfd009216c

View File

@ -3,6 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.android</groupId>
<artifactId>DX</artifactId>
<version>1.16bcv</version>
<artifactId>dx</artifactId>
<version>30.0.3</version>
</project>

View File

@ -0,0 +1 @@
1c8d965abdb64d5e7869fe7abd0f8f16

View File

@ -0,0 +1 @@
e0c4f44b6eff749939e1cd6f2d2aa5ba2d9281d7

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.android</groupId>
<artifactId>DX</artifactId>
<artifactId>dx</artifactId>
<versioning>
<release>1.16bcv</release>
<release>30.0.3</release>
<versions>
<version>1.16bcv</version>
<version>30.0.3</version>
</versions>
<lastUpdated>20210622185015</lastUpdated>
<lastUpdated>20210809171340</lastUpdated>
</versioning>
</metadata>

View File

@ -1 +1 @@
00c4e169d820da2b52ecff592c462a5c
9fc6457b2aaaca1869f9e0f1aab372d4

View File

@ -1 +1 @@
3aa3ae5b23afd0e8e497860be45d2babcbdd03de
5e542c95e397f2b4c3f2b150360e39aa519f0863

View File

@ -0,0 +1 @@
1d977900a2f9afd1200abdd1bd660553

View File

@ -0,0 +1 @@
ce73cbb58e13fc2449d43483f650d671bc63cba8

View File

@ -2,7 +2,7 @@
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.android</groupId>
<groupId>com.googlecode</groupId>
<artifactId>D2Jar-obf</artifactId>
<version>1.0bcv</version>
</project>

View File

@ -0,0 +1 @@
c2145a55e8a96475489adebd58ea4968

View File

@ -0,0 +1 @@
e45f03179f6fc5a3becb4eda787c34fae28f93e5

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.android</groupId>
<groupId>com.googlecode</groupId>
<artifactId>D2Jar-obf</artifactId>
<versioning>
<release>1.0bcv</release>
<versions>
<version>1.0bcv</version>
</versions>
<lastUpdated>20210622185021</lastUpdated>
<lastUpdated>20210809170725</lastUpdated>
</versioning>
</metadata>

View File

@ -0,0 +1 @@
d7504c5ccd9fdb6ed4cdbea4a743c8b1

View File

@ -0,0 +1 @@
daff1db4b2d9ba351c2d17362618d012d94fcbc6

View File

@ -211,11 +211,11 @@
</dependency>
<dependency>
<groupId>com.android</groupId>
<artifactId>DX</artifactId>
<version>1.16bcv</version>
<artifactId>dx</artifactId>
<version>30.0.3</version>
</dependency>
<dependency>
<groupId>com.android</groupId>
<groupId>com.googlecode</groupId>
<artifactId>D2Jar-obf</artifactId>
<version>1.0bcv</version>
</dependency>

View File

@ -61,10 +61,8 @@ public class SmaliAssembler extends InternalCompiler
}
try {
com.googlecode.d2j.smali.SmaliCmd.main(new String[]{
tempSmaliFolder.getAbsolutePath(),
//"-o", tempDex.getAbsolutePath()
});
com.googlecode.d2j.smali.SmaliCmd.main(tempSmaliFolder.getAbsolutePath(),
"-o", tempDex.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
//BytecodeViewer.handleException(e);

View File

@ -10,6 +10,7 @@ import me.konloch.kontainer.io.DiskReader;
import org.apache.commons.io.FileUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
@ -55,6 +56,7 @@ public class SmaliDisassembler extends InternalDecompiler
final File tempClass = new File(start + ".class");
final File tempDex = new File(start + ".dex");
final File tempDexOut = new File(start + "-out");
final File tempSmali = new File(start + "-smali"); //output directory
try (FileOutputStream fos = new FileOutputStream(tempClass)) {
@ -68,7 +70,8 @@ public class SmaliDisassembler extends InternalDecompiler
Dex2Jar.saveAsDex(tempClass, tempDex, true);
try {
com.googlecode.d2j.smali.BaksmaliCmd.main(new String[]{tempDex.getAbsolutePath()});
com.googlecode.d2j.smali.BaksmaliCmd.main(tempDex.getAbsolutePath(),
"-o", tempDexOut.getAbsolutePath());
} catch (Exception e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
@ -77,10 +80,8 @@ public class SmaliDisassembler extends InternalDecompiler
exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
}
File rename = new File(tempDex.getName().replaceFirst("\\.dex", "-out"));
try {
FileUtils.moveDirectory(rename, tempSmali);
FileUtils.moveDirectory(tempDexOut, tempSmali);
} catch (IOException e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));

View File

@ -4,8 +4,6 @@ import com.googlecode.d2j.dex.Dex2jar;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -50,16 +48,6 @@ public class Dex2Jar {
}
}
// TODO fix this properly
private static void applyErrorFix(com.googlecode.dex2jar.tools.Dex2jarCmd cmd) {
try {
Field f = com.googlecode.dex2jar.tools.Dex2jarCmd.class.getDeclaredField("notHandleException");
f.setAccessible(true);
f.set(cmd, true);
} catch (Throwable ignored) {
}
}
/**
* Converts a .jar to .dex
*
@ -72,28 +60,7 @@ public class Dex2Jar {
public static synchronized void saveAsDex(File input, File output, boolean delete) {
try {
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath());
File currentDexLocation = new File("./" + input.getName());
if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".jar")) {
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.jar", "-jar2dex"
+ ".dex"));
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".apk")) {
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.apk", "-jar2dex"
+ ".dex"));
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".dex")) {
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.dex", "-jar2dex"
+ ".dex"));
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".zip")) {
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.zip", "-jar2dex"
+ ".dex"));
} else if (currentDexLocation.getAbsolutePath().toLowerCase().endsWith(".class")) {
currentDexLocation = new File(currentDexLocation.getAbsolutePath().replaceFirst("\\.class", "-jar2dex"
+ ".dex"));
}
currentDexLocation.renameTo(output);
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(), "-o", output.getAbsolutePath());
if (delete)
input.delete();
} catch (Exception e) {

View File

@ -257,7 +257,6 @@ public class SecurityMan extends SecurityManager
public void checkMulticast(InetAddress maddr, byte ttl) {
}
@SuppressWarnings("deprecation")
public void checkPackageAccess(String pkg) {
if(printingPackage)
System.out.println("Accessing: " + pkg);
@ -336,8 +335,6 @@ public class SecurityMan extends SecurityManager
throw new SecurityException(e);
}
//TODO temporarily removed to fix #339
// a proper fix is to edit the smali disassembler
//throw new SecurityException("BCV is awesome, blocking write(" + file + ");");
throw new SecurityException("BCV is awesome, blocking write(" + file + ");");
}
}