bcv-vf/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java

79 lines
3.1 KiB
Java
Raw Normal View History

2019-04-17 06:45:15 +00:00
package the.bytecode.club.bytecodeviewer.util;
import java.io.File;
2021-04-12 20:19:12 +00:00
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
2021-07-11 12:33:18 +00:00
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/**
* A simple wrapper for Enjarify.
*
2018-01-31 15:41:24 +00:00
* @author Konloch
*/
public class Enjarify {
2018-01-31 15:41:24 +00:00
/**
* Converts a .apk or .dex to .jar
*
* @param input the input .apk or .dex file
* @param output the output .jar file
*/
public static synchronized void apk2Jar(File input, File output) {
if (Configuration.python3.isEmpty()) {
2018-01-31 15:41:24 +00:00
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
2021-07-11 12:33:18 +00:00
ExternalResources.getSingleton().selectPython3();
2018-01-31 15:41:24 +00:00
}
if (Configuration.python3.isEmpty()) {
2018-01-31 15:41:24 +00:00
BytecodeViewer.showMessage("You need to set Python!");
return;
}
try {
2021-07-12 12:13:35 +00:00
BytecodeViewer.sm.pauseBlocking();
2018-01-31 15:41:24 +00:00
ProcessBuilder pb = new ProcessBuilder(
Configuration.python3,
2018-01-31 15:41:24 +00:00
"-O",
"-m",
"enjarify.main",
input.getAbsolutePath(),
"-o",
output.getAbsolutePath(),
"-f"
);
pb.directory(new File(enjarifyWorkingDirectory));
2018-01-31 15:41:24 +00:00
Process process = pb.start();
BytecodeViewer.createdProcesses.add(process);
process.waitFor();
MiscUtils.printProcess(process);
2018-01-31 15:41:24 +00:00
} catch (Exception e) {
2021-07-07 02:51:10 +00:00
BytecodeViewer.handleException(e);
2018-01-31 15:41:24 +00:00
} finally {
2021-07-07 03:42:48 +00:00
BytecodeViewer.sm.resumeBlocking();
2018-01-31 15:41:24 +00:00
}
}
}