Skip to content

Commit

Permalink
Fixed issue where a space in a path name would lead to an error
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsLibra committed Apr 2, 2019
1 parent 2fc95b7 commit 07fcaa5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>libra</groupId>
<artifactId>AndroidProjectCreator</artifactId>
<version>1.2-stable</version>
<version>1.2.2-stable</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/apc/AndroidProjectCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import enumeration.Action;
import enumeration.DecompilerType;
import java.io.File;
import library.OperatingSystemDetector;
import model.ArgumentPackage;

/**
Expand Down Expand Up @@ -48,7 +49,7 @@ public static void main(String[] args) {
if (debugging) {
//installTest();
//updateTest();
decompileTest(DecompilerType.JEB3);
decompileTest(DecompilerType.FERNFLOWER);
System.exit(0);
}

Expand Down Expand Up @@ -110,7 +111,12 @@ private static void decompileTest(DecompilerType decompiler) {
}
args[0] = "-decompile";
args[1] = decompiler.toString().toLowerCase();
args[2] = "/home/libra/Documents/apc-test/apk/challenge1_release.apk";
//Mac is excluded from the tests
if (OperatingSystemDetector.isLinux()) {
args[2] = "/home/libra/Documents/apc-test/apk/challenge1_release.apk";
} else if (OperatingSystemDetector.isWindows()) {
args[2] = "C:\\Users\\Libra\\Downloads\\ap k.apk";
}
args[3] = "./test-output-guid-" + java.util.UUID.randomUUID();
if (decompiler == DecompilerType.JEB3) {
args[4] = "/home/libra/Downloads/jeb-pro";
Expand All @@ -119,7 +125,7 @@ private static void decompileTest(DecompilerType decompiler) {
ArgumentPackage argumentPackage = argumentParser.setArguments(args);
manager.execute(argumentPackage);
}

//TODO refactor this method into the argument parser
private static void handleAction(ArgumentManager manager, String[] args) {
//If no arguments are given, the general usage information should be given
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/apc/ArgumentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ private void showError(Exception ex) {
* Display the version information
*/
public void showVersion() {
String versionNumber = "1.2-stable";
String versionNumber = "1.2.2-stable";
StringBuilder version = new StringBuilder();
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl>]\n");
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]\n");
System.out.println(version.toString());
}
}
8 changes: 4 additions & 4 deletions src/main/java/command/Decompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar ./apktool-cli-all.jar";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " d -f -s -m -k -o " + new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath() + "/apktool" + " " + argumentPackage.getApk().getAbsolutePath();
command += " d -f -s -m -k -o " + new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool").getAbsolutePath() + " \"" + argumentPackage.getApk().getAbsolutePath() + "\"";

workingDirectory = new File(Constants.APKTOOL_LIBRARY_FOLDER);
executeCommand(DecompilerType.APKTOOL, command, workingDirectory);
Expand All @@ -112,7 +112,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar ./apktool-cli-all.jar";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " d -f --no-assets --no-res -m -o " + new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath() + "/apktool-smali" + " " + argumentPackage.getApk().getAbsolutePath();
command += " d -f --no-assets --no-res -m -o " + new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool-smali").getAbsolutePath() + " \"" + argumentPackage.getApk().getAbsolutePath() + "\"";

workingDirectory = new File(Constants.APKTOOL_LIBRARY_FOLDER);
executeCommand(DecompilerType.APKTOOL, command, workingDirectory);
Expand Down Expand Up @@ -249,7 +249,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
} else {
command = "java -jar ./bin/app/jeb.jar";
}
command += " --srv2 --script=" + Constants.JEB3_CLI_ANDROID_SCRIPT_LIBRARY_FOLDER + "/DecompileAndroid.py -- " + argumentPackage.getApk().getAbsolutePath() + " " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
command += " --srv2 --script=" + new File(Constants.JEB3_CLI_ANDROID_SCRIPT_LIBRARY_FOLDER + "/DecompileAndroid.py").getAbsolutePath() + " -- " + argumentPackage.getApk().getAbsolutePath() + " " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
workingDirectory = argumentPackage.getJeb3Folder();
}
executeCommand(argumentPackage.getDecompilerType(), command, workingDirectory);
Expand Down Expand Up @@ -296,4 +296,4 @@ private void executeCommand(DecompilerType name, String commandString, File work
throw new IOException("Something went wrong with the I/O during the decompilation. Check the permissions of the output directory and try again.");
}
}
}
}
Binary file not shown.

0 comments on commit 07fcaa5

Please sign in to comment.