2019-04-17 06:45:15 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.util;
|
|
|
|
|
2015-11-11 04:16:45 +00:00
|
|
|
import java.io.File;
|
2021-04-12 20:19:12 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
2021-06-21 11:13:11 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.Configuration;
|
2021-07-11 12:33:18 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
|
2015-11-11 04:16:45 +00:00
|
|
|
|
2021-06-21 09:45:31 +00:00
|
|
|
import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory;
|
|
|
|
|
2015-11-11 04:16:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* 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
|
2015-11-11 04:16:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
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) {
|
2021-07-12 13:59:26 +00:00
|
|
|
if(!ExternalResources.getSingleton().hasSetPython3Command())
|
2018-01-31 15:41:24 +00:00
|
|
|
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(
|
2021-06-21 11:13:11 +00:00
|
|
|
Configuration.python3,
|
2018-01-31 15:41:24 +00:00
|
|
|
"-O",
|
|
|
|
"-m",
|
|
|
|
"enjarify.main",
|
|
|
|
input.getAbsolutePath(),
|
|
|
|
"-o",
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
"-f"
|
|
|
|
);
|
|
|
|
|
2021-06-21 09:45:31 +00:00
|
|
|
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);
|
2015-11-11 04:16:45 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2015-11-11 04:16:45 +00:00
|
|
|
}
|