Skip to content

Commit 66d8fa1

Browse files
committed
Version 1.5-stable released
1 parent 7a4b029 commit 66d8fa1

File tree

8 files changed

+87
-49
lines changed

8 files changed

+87
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# AndroidProjectCreator
22
Convert an APK to an Android Studio Project using multiple open-source tools. Tools that are unavailable are mirrored using repositories on my own Github account (copyright remains with the original creators, those repositories only serve as a mirror).
33

4-
For more information, refer to [this](https://maxkersten.nl/projects/androidprojectcreator/) page on my website. If you've got any questions, please contact me on Twitter [@LibraAnalysis](https://twitter.com/LibraAnalysis)!
4+
For more information, refer to [this](https://maxkersten.nl/projects/androidprojectcreator/) page on my website. If you've got any questions, please contact me on Twitter [@Libranalysis](https://twitter.com/Libranalysis)!

pom.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>libra</groupId>
55
<artifactId>AndroidProjectCreator</artifactId>
6-
<version>1.4-stable</version>
6+
<version>1.5-stable</version>
77
<packaging>jar</packaging>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -47,6 +47,21 @@
4747
<artifactId>zip4j</artifactId>
4848
<version>1.3.2</version>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-api</artifactId>
53+
<version>2.13.3</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.apache.logging.log4j</groupId>
57+
<artifactId>log4j-core</artifactId>
58+
<version>2.13.3</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.logging.log4j</groupId>
62+
<artifactId>log4j-slf4j-impl</artifactId>
63+
<version>2.13.3</version>
64+
</dependency>
5065
</dependencies>
5166
<build>
5267
<plugins>
@@ -65,4 +80,4 @@
6580
</plugin>
6681
</plugins>
6782
</build>
68-
</project>
83+
</project>

src/main/java/apc/AndroidProjectCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public static void main(String[] args) {
4747
*/
4848
boolean debugging = false;
4949
if (debugging) {
50-
//installTest();
50+
installTest();
5151
//updateTest();
52-
decompileTest(DecompilerType.FERNFLOWER);
52+
//decompileTest(DecompilerType.FERNFLOWER);
5353
System.exit(0);
5454
}
5555

src/main/java/apc/ArgumentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ private void showError(Exception ex) {
173173
* Display the version information
174174
*/
175175
public void showVersion() {
176-
String versionNumber = "1.4-stable";
176+
String versionNumber = "1.5-stable";
177177
StringBuilder version = new StringBuilder();
178-
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]\n");
178+
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @Libranalysis on Twitter]\n");
179179
System.out.println(version.toString());
180180
}
181181
}

src/main/java/command/CompactInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public void install() throws IOException, InterruptedException, Exception {
4141
RepositoryManager repositoryManager = new RepositoryManager();
4242
System.out.println("[+]Starting cloning the repositories");
4343
List<Repository> repository = new ArrayList<>();
44-
String name = "CompactInstall version 1.0 (dated 28-07-2020)";
44+
String name = "CompactInstall version 1.1 (dated 11-05-2021)";
4545
String url = "https://github.com/thisislibra/apc-compact.git";
4646
File directory = new File(Constants.LIBRARY_FOLDER);
47-
String branch = "28-07-2020";
47+
String branch = "11-05-2021";
4848
repository.add(new Repository(name, url, directory, branch));
4949
repositoryManager.cloneRepositories(repository);
5050
System.out.println("[+]Cloning finished");

src/main/java/command/Decompiler.java

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,34 @@ public void decompile() throws IOException, InterruptedException, ZipException {
120120
//TODO before the combine functionality is added, add a temporary "copy all classes[n].dex files to the template project's assets folder" method
121121
//TODO Combine classes[N].dex files into classes.dex to decompile every part of the binary, should be optional since it can exceed 64k functions. Use /Users/[name]/Library/Android/sdk/build-tools/28.0.2/lib/dx.jar com.android.dx.merge.DexMerger output.dex part1.dex part2.dex
122122
//Source for code: https://stackoverflow.com/questions/11257378/is-there-a-way-to-merge-two-or-more-dex-files-into-one-dex-file-using-scala
123-
//Convert the classes.dex to a JAR file for later use
124123
/**
125-
* Convert the classes.dex to a JAR (use the "sh" in front since the
126-
* script is not executable by default)
127-
*
128-
* The '-n' is used to ignore exceptions that are thrown by dex2jar
129-
*
130-
* The '-f' is used to forcefully overwrite existing files on the
131-
* destination location
132-
*
133-
* The '-o' is used to define the output location
124+
* JADX can decompile an APK directly, therefore its more efficient to
125+
* skip this step if the JADX decompiler has been selected.
134126
*/
135-
if (isWindows) {
136-
command = "d2j-dex2jar.bat";
137-
} else {
138-
//Add extra shell here to avoid the need to chmod +x the shell script
139-
command = "sh ./d2j-dex2jar.sh";
127+
if (argumentPackage.getDecompilerType().equals(DecompilerType.JADX) == false) {
128+
//Convert the classes.dex to a JAR file for later use
129+
/**
130+
* Convert the classes.dex to a JAR (use the "sh" in front since the
131+
* script is not executable by default)
132+
*
133+
* The '-n' is used to ignore exceptions that are thrown by dex2jar
134+
*
135+
* The '-f' is used to forcefully overwrite existing files on the
136+
* destination location
137+
*
138+
* The '-o' is used to define the output location
139+
*/
140+
if (isWindows) {
141+
command = "d2j-dex2jar.bat";
142+
} else {
143+
//Add extra shell here to avoid the need to chmod +x the shell script
144+
command = "sh ./d2j-dex2jar.sh";
145+
}
146+
//Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
147+
command += " -n -f -o " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool/classes.dex").getAbsolutePath());
148+
workingDirectory = new File(Constants.DEX2JAR_LIBRARY_FOLDER);
149+
executeCommand(DecompilerType.DEX2JAR, command, workingDirectory);
140150
}
141-
//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 " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER + "/apktool/classes.dex").getAbsolutePath());
143-
workingDirectory = new File(Constants.DEX2JAR_LIBRARY_FOLDER);
144-
executeCommand(DecompilerType.DEX2JAR, command, workingDirectory);
145151

146152
//Ensure that the output directory for the source code exists
147153
new File(Constants.TEMP_SOURCES_FOLDER).mkdir();
@@ -164,7 +170,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
164170
/**
165171
* -d sets output dir
166172
*
167-
* -r avoids resources (got these with APKTool alraedy
173+
* -r avoids resources (got these with APKTool already)
168174
*
169175
* --escape-unicode to escape unicode characters
170176
*
@@ -182,7 +188,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
182188
command = "sh ./jadx";
183189
}
184190
//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 " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
191+
command += " -r --escape-unicode -d " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(argumentPackage.getApk().getAbsolutePath());
186192
workingDirectory = new File(Constants.JADX_LIBRARY_FOLDER);
187193
break;
188194
case JDCMD:
@@ -286,26 +292,43 @@ public void decompile() throws IOException, InterruptedException, ZipException {
286292
*/
287293
private void executeCommand(DecompilerType name, String commandString, File workingDirectory) throws IOException, InterruptedException, ZipException {
288294
Command command = new Command(commandString, workingDirectory);
295+
FileManager fileManager = new FileManager();
289296
System.out.println("[+]Decompling JAR with " + name);
290297
try {
291298
command.execute();
292-
if (name.equals(DecompilerType.FERNFLOWER)) {
293-
new FileManager().extractArchive(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar").getAbsolutePath(), new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
294-
new FileManager().delete(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar"));
295-
} else if (name.equals(DecompilerType.JEB3)) {
296-
/**
297-
* If the JEB3 output folder exists, copy the contents to the
298-
* TEMP_SOURCES_FOLDER and remove the JEB3 output folder. This
299-
* way, the rest file handling can stay the same.
300-
*/
301-
File sourceLocation = new File(Constants.TEMP_SOURCES_FOLDER);
302-
File jeb3Output = new File(sourceLocation.getAbsolutePath() + "/Bytecode_decompiled");
303-
if (jeb3Output.exists() && jeb3Output.isDirectory()) {
304-
for (File currentFileObject : sourceLocation.listFiles()) {
305-
new FileManager().copyFolder(currentFileObject, sourceLocation);
299+
switch (name) {
300+
case FERNFLOWER:
301+
fileManager.extractArchive(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar").getAbsolutePath(), new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
302+
fileManager.delete(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar"));
303+
break;
304+
case JEB3:
305+
/**
306+
* If the JEB3 output folder exists, copy the contents to
307+
* the TEMP_SOURCES_FOLDER and remove the JEB3 output
308+
* folder. This way, the rest file handling can stay the
309+
* same.
310+
*/
311+
File sourceLocation = new File(Constants.TEMP_SOURCES_FOLDER);
312+
File jeb3Output = new File(sourceLocation.getAbsolutePath() + "/Bytecode_decompiled");
313+
if (jeb3Output.exists() && jeb3Output.isDirectory()) {
314+
for (File currentFileObject : sourceLocation.listFiles()) {
315+
fileManager.copyFolder(currentFileObject, sourceLocation);
316+
}
317+
fileManager.delete(jeb3Output);
306318
}
307-
new FileManager().delete(jeb3Output);
308-
}
319+
break;
320+
case JADX:
321+
File source = new File(Constants.TEMP_SOURCES_FOLDER);
322+
File jadxOutput = new File(source.getAbsolutePath() + "/sources");
323+
if (jadxOutput.exists() && jadxOutput.isDirectory()) {
324+
for (File currentFileObject : source.listFiles()) {
325+
fileManager.copyFolder(currentFileObject, source);
326+
}
327+
fileManager.delete(jadxOutput);
328+
}
329+
break;
330+
default:
331+
break;
309332
}
310333
System.out.println("[+]Decompilation finished");
311334
} catch (IOException ex) {

src/main/java/library/Repositories.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static Repository getJdCmd() {
8989
//String url = "https://github.com/kwart/jd-cmd.git";
9090
String url = "https://github.com/ThisIsLibra/jdcmd.git";
9191
File directory = new File(Constants.JDCMD_REPOSITORY_FOLDER);
92-
String branch = "master";
92+
String branch = "main";
9393
return new Repository(name, url, directory, branch);
9494
}
9595

@@ -129,7 +129,7 @@ public static Repository getAndroidProject() {
129129
//String name = "androidstudioproject";
130130
String url = "https://github.com/ThisIsLibra/AndroidStudioProject.git";
131131
File directory = new File(Constants.ANDROIDPROJECT_REPOSITORY_FOLDER);
132-
String branch = "master";
132+
String branch = "main";
133133
return new Repository(name, url, directory, branch);
134134
}
135135

@@ -168,7 +168,7 @@ public static Repository getJeb3AndroidDecompilerScript() {
168168
String name = DecompilerType.JEB3.toString().toLowerCase();
169169
String url = "https://github.com/ThisIsLibra/jeb3-cli-android-decompiler.git";
170170
File directory = new File(Constants.JEB3_CLI_ANDROID_SCRIPT_REPOSITORY_FOLDER);
171-
String branch = "master";
171+
String branch = "main";
172172
return new Repository(name, url, directory, branch);
173173
}
174174
}

target/AndroidProjectCreator-1.4-stable-jar-with-dependencies.jar renamed to target/AndroidProjectCreator-1.5-stable-jar-with-dependencies.jar

3.07 MB
Binary file not shown.

0 commit comments

Comments
 (0)