Skip to content

Commit

Permalink
Release of version 1.3.1-stable: resolved the command line argument p…
Browse files Browse the repository at this point in the history
…arsing issue when there was a space at any given point in a given path
  • Loading branch information
ThisIsLibra committed Mar 30, 2020
1 parent 80995dc commit d230c5b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
27 changes: 26 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,38 @@
<modelVersion>4.0.0</modelVersion>
<groupId>libra</groupId>
<artifactId>AndroidProjectCreator</artifactId>
<version>1.3-stable</version>
<version>1.3.1-stable</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jgit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/apc/ArgumentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void showError(Exception ex) {
* Display the version information
*/
public void showVersion() {
String versionNumber = "1.3-stable";
String versionNumber = "1.3.1-stable";
StringBuilder version = new StringBuilder();
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]\n");
System.out.println(version.toString());
Expand Down
28 changes: 19 additions & 9 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 + "/apktool").getAbsolutePath() + " \"" + argumentPackage.getApk().getAbsolutePath() + "\"";
command += " d -f -s -m -k -o " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool").getAbsolutePath()) + " " + encapsulate(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 + "/apktool-smali").getAbsolutePath() + " \"" + argumentPackage.getApk().getAbsolutePath() + "\"";
command += " d -f --no-assets --no-res -m -o " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool-smali").getAbsolutePath()) + " " + encapsulate(argumentPackage.getApk().getAbsolutePath());

workingDirectory = new File(Constants.APKTOOL_LIBRARY_FOLDER);
executeCommand(DecompilerType.APKTOOL, command, workingDirectory);
Expand All @@ -139,7 +139,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "sh ./d2j-dex2jar.sh";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " -n -f -o " + new File(Constants.TEMP_CONVERTED_JAR) + " " + new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool/classes.dex").getAbsolutePath();
command += " -n -f -o " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool/classes.dex").getAbsolutePath());
workingDirectory = new File(Constants.DEX2JAR_LIBRARY_FOLDER);
executeCommand(DecompilerType.DEX2JAR, command, workingDirectory);

Expand All @@ -157,7 +157,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar ./fernflower.jar";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " " + new File(Constants.TEMP_CONVERTED_JAR) + " " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
command += " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
workingDirectory = new File(Constants.FERNFLOWER_LIBRARY_FOLDER);
break;
case JADX:
Expand All @@ -182,7 +182,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "sh ./jadx";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " -r --escape-unicode -d " + new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath() + " " + new File(Constants.TEMP_CONVERTED_JAR);
command += " -r --escape-unicode -d " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
workingDirectory = new File(Constants.JADX_LIBRARY_FOLDER);
break;
case JDCMD:
Expand All @@ -196,7 +196,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar ./jd-cli.jar";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " -od " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath() + " " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath();
command += " -od " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
workingDirectory = new File(Constants.JDCMD_LIBRARY_FOLDER);
break;
case CFR:
Expand Down Expand Up @@ -229,7 +229,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar " + cfrFileName;
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath() + " --aexagg true --outputdir " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
command += " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " --aexagg true --outputdir " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
workingDirectory = new File(Constants.CFR_LIBRARY_FOLDER);
break;
case PROCYON:
Expand All @@ -247,7 +247,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
command = "java -jar ./procyon-decompiler-0.5.30.jar";
}
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
command += " -ci -eml --jar-file " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath() + " -o " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
command += " -ci -eml --jar-file " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " -o " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
workingDirectory = new File(Constants.PROCYON_LIBRARY_FOLDER);
break;
case JEB3:
Expand All @@ -265,7 +265,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
} else {
command = "java -jar ./bin/app/jeb.jar";
}
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();
command += " --srv2 --script=" + encapsulate(new File(Constants.JEB3_CLI_ANDROID_SCRIPT_LIBRARY_FOLDER + "/DecompileAndroid.py").getAbsolutePath()) + " -- " + encapsulate(argumentPackage.getApk().getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
workingDirectory = argumentPackage.getJeb3Folder();
}
executeCommand(argumentPackage.getDecompilerType(), command, workingDirectory);
Expand Down Expand Up @@ -312,4 +312,14 @@ 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.");
}
}

/**
* Encapsulates the given string between quotes
*
* @param value the string to encapsulate
* @return the encapsulated string
*/
private String encapsulate(String value) {
return "\"" + value + "\"";
}
}
Binary file not shown.

0 comments on commit d230c5b

Please sign in to comment.