Skip to content

Commit d230c5b

Browse files
committed
Release of version 1.3.1-stable: resolved the command line argument parsing issue when there was a space at any given point in a given path
1 parent 80995dc commit d230c5b

4 files changed

Lines changed: 46 additions & 11 deletions

File tree

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,38 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>libra</groupId>
55
<artifactId>AndroidProjectCreator</artifactId>
6-
<version>1.3-stable</version>
6+
<version>1.3.1-stable</version>
77
<packaging>jar</packaging>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1010
<maven.compiler.source>1.8</maven.compiler.source>
1111
<maven.compiler.target>1.8</maven.compiler.target>
1212
</properties>
13+
<pluginRepositories>
14+
<pluginRepository>
15+
<id>central</id>
16+
<name>Central Repository</name>
17+
<url>https://repo.maven.apache.org/maven2</url>
18+
<layout>default</layout>
19+
<snapshots>
20+
<enabled>false</enabled>
21+
</snapshots>
22+
<releases>
23+
<updatePolicy>never</updatePolicy>
24+
</releases>
25+
</pluginRepository>
26+
</pluginRepositories>
27+
<repositories>
28+
<repository>
29+
<id>central</id>
30+
<name>Central Repository</name>
31+
<url>https://repo.maven.apache.org/maven2</url>
32+
<layout>default</layout>
33+
<snapshots>
34+
<enabled>false</enabled>
35+
</snapshots>
36+
</repository>
37+
</repositories>
1338
<dependencies>
1439
<dependency>
1540
<groupId>org.eclipse.jgit</groupId>

src/main/java/apc/ArgumentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void showError(Exception ex) {
158158
* Display the version information
159159
*/
160160
public void showVersion() {
161-
String versionNumber = "1.3-stable";
161+
String versionNumber = "1.3.1-stable";
162162
StringBuilder version = new StringBuilder();
163163
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]\n");
164164
System.out.println(version.toString());

src/main/java/command/Decompiler.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
8989
command = "java -jar ./apktool-cli-all.jar";
9090
}
9191
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
92-
command += " d -f -s -m -k -o " + new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool").getAbsolutePath() + " \"" + argumentPackage.getApk().getAbsolutePath() + "\"";
92+
command += " d -f -s -m -k -o " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool").getAbsolutePath()) + " " + encapsulate(argumentPackage.getApk().getAbsolutePath());
9393

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

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

@@ -157,7 +157,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
157157
command = "java -jar ./fernflower.jar";
158158
}
159159
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
160-
command += " " + new File(Constants.TEMP_CONVERTED_JAR) + " " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
160+
command += " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
161161
workingDirectory = new File(Constants.FERNFLOWER_LIBRARY_FOLDER);
162162
break;
163163
case JADX:
@@ -182,7 +182,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
182182
command = "sh ./jadx";
183183
}
184184
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
185-
command += " -r --escape-unicode -d " + new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath() + " " + new File(Constants.TEMP_CONVERTED_JAR);
185+
command += " -r --escape-unicode -d " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
186186
workingDirectory = new File(Constants.JADX_LIBRARY_FOLDER);
187187
break;
188188
case JDCMD:
@@ -196,7 +196,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
196196
command = "java -jar ./jd-cli.jar";
197197
}
198198
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
199-
command += " -od " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath() + " " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath();
199+
command += " -od " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
200200
workingDirectory = new File(Constants.JDCMD_LIBRARY_FOLDER);
201201
break;
202202
case CFR:
@@ -229,7 +229,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
229229
command = "java -jar " + cfrFileName;
230230
}
231231
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
232-
command += " " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath() + " --aexagg true --outputdir " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
232+
command += " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " --aexagg true --outputdir " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
233233
workingDirectory = new File(Constants.CFR_LIBRARY_FOLDER);
234234
break;
235235
case PROCYON:
@@ -247,7 +247,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
247247
command = "java -jar ./procyon-decompiler-0.5.30.jar";
248248
}
249249
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
250-
command += " -ci -eml --jar-file " + new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath() + " -o " + new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath();
250+
command += " -ci -eml --jar-file " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " -o " + encapsulate(new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
251251
workingDirectory = new File(Constants.PROCYON_LIBRARY_FOLDER);
252252
break;
253253
case JEB3:
@@ -265,7 +265,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
265265
} else {
266266
command = "java -jar ./bin/app/jeb.jar";
267267
}
268-
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();
268+
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());
269269
workingDirectory = argumentPackage.getJeb3Folder();
270270
}
271271
executeCommand(argumentPackage.getDecompilerType(), command, workingDirectory);
@@ -312,4 +312,14 @@ private void executeCommand(DecompilerType name, String commandString, File work
312312
throw new IOException("Something went wrong with the I/O during the decompilation. Check the permissions of the output directory and try again.");
313313
}
314314
}
315+
316+
/**
317+
* Encapsulates the given string between quotes
318+
*
319+
* @param value the string to encapsulate
320+
* @return the encapsulated string
321+
*/
322+
private String encapsulate(String value) {
323+
return "\"" + value + "\"";
324+
}
315325
}

target/AndroidProjectCreator-1.3-stable-jar-with-dependencies.jar renamed to target/AndroidProjectCreator-1.3.1-stable-jar-with-dependencies.jar

3.07 MB
Binary file not shown.

0 commit comments

Comments
 (0)