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

74 lines
2.5 KiB
Java
Raw Normal View History

package the.bytecode.club.bytecodeviewer;
import java.io.File;
/***************************************************************************
* 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.
*
* @author Konloch
*
*/
public class Enjarify {
/**
* 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) {
2015-11-19 03:30:59 +00:00
if(Settings.PYTHON3_LOCATION.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
BytecodeViewer.viewer.pythonC3();
}
2015-11-19 03:30:59 +00:00
if(Settings.PYTHON3_LOCATION.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return;
}
BytecodeViewer.sm.stopBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
2015-11-19 03:30:59 +00:00
Settings.PYTHON3_LOCATION.get(),
"-O",
"-m",
"enjarify.main",
input.getAbsolutePath(),
"-o",
output.getAbsolutePath(),
"-f"
);
2015-11-19 03:30:59 +00:00
pb.directory(BytecodeViewer.enjarifyDirectory);
Process process = pb.start();
BytecodeViewer.createdProcesses.add(process);
process.waitFor();
MiscUtils.printProcess(process);
} catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally {
BytecodeViewer.sm.setBlocking();
}
}
}