Skip to content

Commit

Permalink
Version 1.5-stable released
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsLibra committed May 26, 2021
1 parent 7a4b029 commit 66d8fa1
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AndroidProjectCreator
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).

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)!
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)!
19 changes: 17 additions & 2 deletions 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.4-stable</version>
<version>1.5-stable</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -47,6 +47,21 @@
<artifactId>zip4j</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.3</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -65,4 +80,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
4 changes: 2 additions & 2 deletions src/main/java/apc/AndroidProjectCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public static void main(String[] args) {
*/
boolean debugging = false;
if (debugging) {
//installTest();
installTest();
//updateTest();
decompileTest(DecompilerType.FERNFLOWER);
//decompileTest(DecompilerType.FERNFLOWER);
System.exit(0);
}

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 @@ -173,9 +173,9 @@ private void showError(Exception ex) {
* Display the version information
*/
public void showVersion() {
String versionNumber = "1.4-stable";
String versionNumber = "1.5-stable";
StringBuilder version = new StringBuilder();
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]\n");
version.append("[+]AndroidProjectCreator " + versionNumber + " [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @Libranalysis on Twitter]\n");
System.out.println(version.toString());
}
}
4 changes: 2 additions & 2 deletions src/main/java/command/CompactInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public void install() throws IOException, InterruptedException, Exception {
RepositoryManager repositoryManager = new RepositoryManager();
System.out.println("[+]Starting cloning the repositories");
List<Repository> repository = new ArrayList<>();
String name = "CompactInstall version 1.0 (dated 28-07-2020)";
String name = "CompactInstall version 1.1 (dated 11-05-2021)";
String url = "https://github.com/thisislibra/apc-compact.git";
File directory = new File(Constants.LIBRARY_FOLDER);
String branch = "28-07-2020";
String branch = "11-05-2021";
repository.add(new Repository(name, url, directory, branch));
repositoryManager.cloneRepositories(repository);
System.out.println("[+]Cloning finished");
Expand Down
97 changes: 60 additions & 37 deletions src/main/java/command/Decompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,34 @@ public void decompile() throws IOException, InterruptedException, ZipException {
//TODO before the combine functionality is added, add a temporary "copy all classes[n].dex files to the template project's assets folder" method
//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
//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
//Convert the classes.dex to a JAR file for later use
/**
* Convert the classes.dex to a JAR (use the "sh" in front since the
* script is not executable by default)
*
* The '-n' is used to ignore exceptions that are thrown by dex2jar
*
* The '-f' is used to forcefully overwrite existing files on the
* destination location
*
* The '-o' is used to define the output location
* JADX can decompile an APK directly, therefore its more efficient to
* skip this step if the JADX decompiler has been selected.
*/
if (isWindows) {
command = "d2j-dex2jar.bat";
} else {
//Add extra shell here to avoid the need to chmod +x the shell script
command = "sh ./d2j-dex2jar.sh";
if (argumentPackage.getDecompilerType().equals(DecompilerType.JADX) == false) {
//Convert the classes.dex to a JAR file for later use
/**
* Convert the classes.dex to a JAR (use the "sh" in front since the
* script is not executable by default)
*
* The '-n' is used to ignore exceptions that are thrown by dex2jar
*
* The '-f' is used to forcefully overwrite existing files on the
* destination location
*
* The '-o' is used to define the output location
*/
if (isWindows) {
command = "d2j-dex2jar.bat";
} else {
//Add extra shell here to avoid the need to chmod +x the shell script
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 " + 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);
}
//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 " + 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);

//Ensure that the output directory for the source code exists
new File(Constants.TEMP_SOURCES_FOLDER).mkdir();
Expand All @@ -164,7 +170,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
/**
* -d sets output dir
*
* -r avoids resources (got these with APKTool alraedy
* -r avoids resources (got these with APKTool already)
*
* --escape-unicode to escape unicode characters
*
Expand All @@ -182,7 +188,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 " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(new File(Constants.TEMP_CONVERTED_JAR).getAbsolutePath());
command += " -r --escape-unicode -d " + encapsulate(new File(Constants.TEMP_LIBRARY_FOLDER).getAbsolutePath()) + " " + encapsulate(argumentPackage.getApk().getAbsolutePath());
workingDirectory = new File(Constants.JADX_LIBRARY_FOLDER);
break;
case JDCMD:
Expand Down Expand Up @@ -286,26 +292,43 @@ public void decompile() throws IOException, InterruptedException, ZipException {
*/
private void executeCommand(DecompilerType name, String commandString, File workingDirectory) throws IOException, InterruptedException, ZipException {
Command command = new Command(commandString, workingDirectory);
FileManager fileManager = new FileManager();
System.out.println("[+]Decompling JAR with " + name);
try {
command.execute();
if (name.equals(DecompilerType.FERNFLOWER)) {
new FileManager().extractArchive(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar").getAbsolutePath(), new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
new FileManager().delete(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar"));
} else if (name.equals(DecompilerType.JEB3)) {
/**
* If the JEB3 output folder exists, copy the contents to the
* TEMP_SOURCES_FOLDER and remove the JEB3 output folder. This
* way, the rest file handling can stay the same.
*/
File sourceLocation = new File(Constants.TEMP_SOURCES_FOLDER);
File jeb3Output = new File(sourceLocation.getAbsolutePath() + "/Bytecode_decompiled");
if (jeb3Output.exists() && jeb3Output.isDirectory()) {
for (File currentFileObject : sourceLocation.listFiles()) {
new FileManager().copyFolder(currentFileObject, sourceLocation);
switch (name) {
case FERNFLOWER:
fileManager.extractArchive(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar").getAbsolutePath(), new File(Constants.TEMP_SOURCES_FOLDER).getAbsolutePath());
fileManager.delete(new File(Constants.TEMP_SOURCES_FOLDER + "/output.jar"));
break;
case JEB3:
/**
* If the JEB3 output folder exists, copy the contents to
* the TEMP_SOURCES_FOLDER and remove the JEB3 output
* folder. This way, the rest file handling can stay the
* same.
*/
File sourceLocation = new File(Constants.TEMP_SOURCES_FOLDER);
File jeb3Output = new File(sourceLocation.getAbsolutePath() + "/Bytecode_decompiled");
if (jeb3Output.exists() && jeb3Output.isDirectory()) {
for (File currentFileObject : sourceLocation.listFiles()) {
fileManager.copyFolder(currentFileObject, sourceLocation);
}
fileManager.delete(jeb3Output);
}
new FileManager().delete(jeb3Output);
}
break;
case JADX:
File source = new File(Constants.TEMP_SOURCES_FOLDER);
File jadxOutput = new File(source.getAbsolutePath() + "/sources");
if (jadxOutput.exists() && jadxOutput.isDirectory()) {
for (File currentFileObject : source.listFiles()) {
fileManager.copyFolder(currentFileObject, source);
}
fileManager.delete(jadxOutput);
}
break;
default:
break;
}
System.out.println("[+]Decompilation finished");
} catch (IOException ex) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/library/Repositories.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static Repository getJdCmd() {
//String url = "https://github.com/kwart/jd-cmd.git";
String url = "https://github.com/ThisIsLibra/jdcmd.git";
File directory = new File(Constants.JDCMD_REPOSITORY_FOLDER);
String branch = "master";
String branch = "main";
return new Repository(name, url, directory, branch);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public static Repository getAndroidProject() {
//String name = "androidstudioproject";
String url = "https://github.com/ThisIsLibra/AndroidStudioProject.git";
File directory = new File(Constants.ANDROIDPROJECT_REPOSITORY_FOLDER);
String branch = "master";
String branch = "main";
return new Repository(name, url, directory, branch);
}

Expand Down Expand Up @@ -168,7 +168,7 @@ public static Repository getJeb3AndroidDecompilerScript() {
String name = DecompilerType.JEB3.toString().toLowerCase();
String url = "https://github.com/ThisIsLibra/jeb3-cli-android-decompiler.git";
File directory = new File(Constants.JEB3_CLI_ANDROID_SCRIPT_REPOSITORY_FOLDER);
String branch = "master";
String branch = "main";
return new Repository(name, url, directory, branch);
}
}
Binary file not shown.

0 comments on commit 66d8fa1

Please sign in to comment.