Fixes, API Changes, Cleanup, etc.
This commit is contained in:
Konloch 2021-07-11 05:33:18 -07:00
parent df0c978fa9
commit 21fe12b4a7
50 changed files with 436 additions and 372 deletions

View file

@ -8,14 +8,12 @@ import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.text.html.HTMLEditorKit;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.gui.components.HTMLPane;
import static the.bytecode.club.bytecodeviewer.Configuration.language;

View file

@ -89,7 +89,9 @@ import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
* + Make zipfile not include the decode shit
* + Add decompile as zip for krakatau-bytecode, jd-gui and smali for CLI
* + Add decompile all as zip for CLI
* + Console on the UI
* + Console on the Main Viewer UI
* + Plugin Console/System/ETC needs ctrl + mouse wheel
* + Font settings
*
* TODO IDEAS:
* + App Bundle Support
@ -116,7 +118,7 @@ public class BytecodeViewer
public static MainViewerGUI viewer;
//All of the opened resources (Files/Classes/Etc)
public static List<ResourceContainer> files = new ArrayList<>();
public static List<ResourceContainer> resourceContainers = new ArrayList<>();
//All of the created processes (Decompilers/etc)
public static List<Process> createdProcesses = new ArrayList<>();
@ -264,47 +266,13 @@ public class BytecodeViewer
for (String s : launchArgs)
openFiles(new File[]{new File(s)}, true);
}
/**
* Returns the java command it can use to launch the decompilers
*
* @return
*/
public static synchronized String getJavaCommand()
{
sm.pauseBlocking();
try
{
ProcessBuilder pb = new ProcessBuilder("java", "-version");
pb.start();
return "java"; //java is set
}
catch (Exception e) //ignore
{
sm.resumeBlocking();
boolean empty = Configuration.java.isEmpty();
while (empty)
{
showMessage("You need to set your Java path, this requires the JRE to be downloaded." +
nl + "(C:/Program Files/Java/JDK_xx/bin/java.exe)");
viewer.selectJava();
empty = Configuration.java.isEmpty();
}
}
finally
{
sm.resumeBlocking();
}
return Configuration.java;
}
/**
* Returns true if there is at least one file resource loaded
*/
public static boolean hasResources()
{
return !files.isEmpty();
return !resourceContainers.isEmpty();
}
/**
@ -353,7 +321,7 @@ public class BytecodeViewer
@Deprecated
public static ClassNode blindlySearchForClassNode(String name)
{
for (ResourceContainer container : files)
for (ResourceContainer container : resourceContainers)
{
ClassNode node = container.getClassNode(name);
if(node != null)
@ -368,7 +336,7 @@ public class BytecodeViewer
*/
public static ResourceContainer getFileContainer(String name)
{
for (ResourceContainer container : files)
for (ResourceContainer container : resourceContainers)
if (container.name.equals(name))
return container;
@ -378,8 +346,8 @@ public class BytecodeViewer
/**
* Returns all of the loaded File Containers
*/
public static List<ResourceContainer> getFiles() {
return files;
public static List<ResourceContainer> getResourceContainers() {
return resourceContainers;
}
/**
@ -390,7 +358,7 @@ public class BytecodeViewer
*/
public static byte[] getFileContents(String name)
{
for (ResourceContainer container : files)
for (ResourceContainer container : resourceContainers)
if (container.resourceFiles.containsKey(name))
return container.resourceFiles.get(name);
@ -414,7 +382,7 @@ public class BytecodeViewer
{
ArrayList<ClassNode> a = new ArrayList<>();
for (ResourceContainer container : files)
for (ResourceContainer container : resourceContainers)
for (ClassNode c : container.resourceClasses.values())
if (!a.contains(c))
a.add(c);
@ -631,7 +599,7 @@ public class BytecodeViewer
*/
public static void resetWorkspace()
{
BytecodeViewer.files.clear();
BytecodeViewer.resourceContainers.clear();
LazyNameUtil.reset();
BytecodeViewer.viewer.resourcePane.resetWorkspace();
BytecodeViewer.viewer.workPane.resetWorkspace();

View file

@ -14,7 +14,7 @@ import java.io.File;
*/
public class Configuration
{
public static String python = "";
public static String python2 = "";
public static String python3 = "";
public static String rt = "";
public static String library = "";

View file

@ -17,11 +17,14 @@ public class Constants
public static String krakatauVersion = "12";
public static String enjarifyVersion = "4";
public static final boolean BLOCK_TAB_MENU = true;
public static final boolean LAUNCH_DECOMPILERS_IN_NEW_PROCESS = false; //TODO
public static final boolean FAT_JAR = true; //could be automatic by checking if it's loaded a class named whatever for a library
public static final boolean OFFLINE_MODE = true; //disables the automatic updater
public static final String fs = System.getProperty("file.separator");
public static final String nl = System.getProperty("line.separator");
//TODO check if $HOME/.local/share exists, if so reference from there instead - #250
public static final File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
public static final File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar");

View file

@ -139,7 +139,7 @@ public class SettingsSerializer
save("deprecated");
save("deprecated");
save(Configuration.lastDirectory);
save(Configuration.python);
save(Configuration.python2);
save(Configuration.rt);
save("deprecated");
save("deprecated");
@ -301,7 +301,7 @@ public class SettingsSerializer
//86 is deprecated
//87 is deprecated
Configuration.lastDirectory = asString(88);
Configuration.python = asString(89);
Configuration.python2 = asString(89);
Configuration.rt = asString(90);
BytecodeViewer.viewer.decodeAPKResources.setSelected(asBoolean(106));

View file

@ -10,7 +10,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import static the.bytecode.club.bytecodeviewer.Constants.*;

View file

@ -9,6 +9,7 @@ import me.konloch.kontainer.io.DiskWriter;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -54,8 +55,8 @@ public class JavaCompiler extends InternalCompiler
new File(fileStart2).mkdirs();
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists()) {
BytecodeViewer.showMessage("You need to set your Javac path, this requires the JDK to be downloaded." + nl + "(C:/programfiles/Java/JDK_xx/bin/javac.exe)");
BytecodeViewer.viewer.selectJavac();
BytecodeViewer.showMessage("You need to set your Javac path, this requires the JDK to be downloaded." + nl + "(C:/Program Files/Java/JDK_xx/bin/javac.exe)");
ExternalResources.getSingleton().selectJavac();
}
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists()) {

View file

@ -12,7 +12,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler;
import the.bytecode.club.bytecodeviewer.util.BCVFileUtils;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -46,12 +46,12 @@ public class KrakatauAssembler extends InternalCompiler
@Override
public byte[] compile(String contents, String name) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return null;
}
@ -76,7 +76,7 @@ public class KrakatauAssembler extends InternalCompiler
try
{
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "assemble.py",
"-out",
@ -112,7 +112,8 @@ public class KrakatauAssembler extends InternalCompiler
log.append(nl).append(nl).append("Exit Value is ").append(exitValue);
System.err.println(log);
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(BCVFileUtils.findFile(tempDirectory, ".class")));
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(
ExternalResources.getSingleton().findFile(tempDirectory, ".class")));
tempDirectory.delete();
tempJar.delete();
return b;

View file

@ -9,7 +9,8 @@ import me.konloch.kontainer.io.DiskReader;
import org.apache.commons.lang3.ArrayUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
@ -47,7 +48,8 @@ public class FernFlowerDecompiler extends InternalDecompiler
{
@Override
public void decompileToZip(String sourceJar, String zipName) {
public void decompileToZip(String sourceJar, String zipName)
{
File tempZip = new File(sourceJar);
File f = new File(tempDirectory + fs + "temp" + fs);
@ -55,9 +57,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
try {
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), tempDirectory + "./temp/"));
} catch (StackOverflowError | Exception ignored) {
}
} catch (StackOverflowError | Exception ignored) { }
File tempZip2 = new File(tempDirectory + fs + "temp" + fs + tempZip.getName());
if (tempZip2.exists())
@ -86,10 +86,12 @@ public class FernFlowerDecompiler extends InternalDecompiler
}
if (!FAT_JAR) {
try {
if (LAUNCH_DECOMPILERS_IN_NEW_PROCESS)
{
try
{
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("fernflower")},
new String[]{ExternalResources.getSingleton().getJavaCommand(true), "-jar", ExternalResources.getSingleton().findLibrary("fernflower")},
generateMainMethod(tempClass.getAbsolutePath(),
new File(tempDirectory).getAbsolutePath())
));
@ -102,9 +104,12 @@ public class FernFlowerDecompiler extends InternalDecompiler
} finally {
BytecodeViewer.sm.resumeBlocking();
}
} else {
}
else
{
try {
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath()));
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(
generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath()));
} catch (Throwable e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));

View file

@ -10,11 +10,12 @@ import java.util.Arrays;
import java.util.stream.Collectors;
import me.konloch.kontainer.io.DiskReader;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bootloader.resource.ExternalResource;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.util.BCVResourceUtils;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -65,20 +66,19 @@ public class KrakatauDecompiler extends InternalDecompiler
.map(File::getAbsolutePath).collect(Collectors.joining(";"));
}
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) {
if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
}
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn)
{
if(!ExternalResources.getSingleton().hasSetPythonCommand())
return "You need to set your Python 2.7 path!";
BCVResourceUtils.rtCheck();
ExternalResources.getSingleton().rtCheck();
if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library.\r\n(C:\\Program Files (x86)"
+ "\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.selectJRERTLibrary();
ExternalResources.getSingleton().selectJRERTLibrary();
}
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths";
}
@ -94,7 +94,7 @@ public class KrakatauDecompiler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3
@ -149,17 +149,17 @@ public class KrakatauDecompiler extends InternalDecompiler
@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." +
"\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.selectJRERTLibrary();
ExternalResources.getSingleton().selectJRERTLibrary();
}
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths";
}
@ -182,7 +182,7 @@ public class KrakatauDecompiler extends InternalDecompiler
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3
@ -240,16 +240,16 @@ public class KrakatauDecompiler extends InternalDecompiler
@Override
public void decompileToZip(String sourceJar, String zipName) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
BCVResourceUtils.rtCheck();
ExternalResources.getSingleton().rtCheck();
if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." +
"\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.selectJRERTLibrary();
ExternalResources.getSingleton().selectJRERTLibrary();
}
String ran = MiscUtils.randomString(32);
@ -263,7 +263,7 @@ public class KrakatauDecompiler extends InternalDecompiler
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3

View file

@ -12,6 +12,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -46,12 +47,12 @@ public class KrakatauDisassembler extends InternalDecompiler
{
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths";
}
@ -62,7 +63,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py",
"-path",
@ -115,12 +116,12 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths";
}
@ -136,7 +137,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py",
"-path",
@ -188,9 +189,9 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override
public void decompileToZip(String sourceJar, String zipName) {
if (Configuration.python.isEmpty()) {
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.selectPythonC();
ExternalResources.getSingleton().selectPython2();
}
String ran = MiscUtils.randomString(32);
@ -202,7 +203,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
Configuration.python2,
"-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py",
"-path",

View file

@ -25,7 +25,9 @@ import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.PluginTemplate;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.*;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.resources.exporting.Export;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem;
@ -115,6 +117,8 @@ public class MainViewerGUI extends JFrame
public final JMenuItem ZKMStringDecrypter = new TranslatedJMenuItem("ZKM String Decrypter", Translation.ZKM_STRING_DECRYPTER);
public final JMenuItem allatoriStringDecrypter = new TranslatedJMenuItem("Allatori String Decrypter", Translation.ALLATORI_STRING_DECRYPTER);
public final JMenuItem zStringArrayDecrypter = new TranslatedJMenuItem("ZStringArray Decrypter", Translation.ZSTRINGARRAY_DECRYPTER);
public final JMenuItem viewAPKAndroidPermissions = new JMenuItem("View Android Permissions");
public final JMenuItem viewManifest = new JMenuItem("View Manifest");
//all of the settings main menu components
public final ButtonGroup apkConversionGroup = new ButtonGroup();
@ -560,11 +564,11 @@ public class MainViewerGUI extends JFrame
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync());
setPython2.addActionListener(arg0 -> selectPythonC());
setJRERT.addActionListener(arg0 -> selectJRERTLibrary());
setPython3.addActionListener(arg0 -> selectPythonC3());
setOptionalLibrary.addActionListener(arg0 -> selectOpenalLibraryFolder());
setJavac.addActionListener(arg0 -> selectJavac());
setPython2.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython2());
setJRERT.addActionListener(arg0 -> ExternalResources.getSingleton().selectJRERTLibrary());
setPython3.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython3());
setOptionalLibrary.addActionListener(arg0 -> ExternalResources.getSingleton().selectOptionalLibraryFolder());
setJavac.addActionListener(arg0 -> ExternalResources.getSingleton().selectJavac());
showFileInTabTitle.addActionListener(arg0 -> {
Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
SettingsSerializer.saveSettingsAsync();
@ -586,7 +590,10 @@ public class MainViewerGUI extends JFrame
pluginsMainMenu.add(new JSeparator());
pluginsMainMenu.add(newJavaPlugin);
pluginsMainMenu.add(newJavascriptPlugin);
pluginsMainMenu.add(new JSeparator()); //android specific plugins first
pluginsMainMenu.add(viewAPKAndroidPermissions);
pluginsMainMenu.add(new JSeparator());
pluginsMainMenu.add(viewManifest);
pluginsMainMenu.add(codeSequenceDiagram);
pluginsMainMenu.add(maliciousCodeScanner);
pluginsMainMenu.add(showMainMethods);
@ -594,10 +601,11 @@ public class MainViewerGUI extends JFrame
pluginsMainMenu.add(replaceStrings);
pluginsMainMenu.add(stackFramesRemover);
//allatori and ZKM are disabled since they are just placeholders
//allatori is disabled since they are just placeholders
//ZKM and ZStringArray decrypter are disabled until deobfuscation has been extended
//mnNewMenu_1.add(mntmNewMenuItem_2);
//mnNewMenu_1.add(mntmStartZkmString);
pluginsMainMenu.add(zStringArrayDecrypter);
//pluginsMainMenu.add(zStringArrayDecrypter);
openExternalPlugin.addActionListener(arg0 -> openExternalPlugin());
newJavaPlugin.addActionListener(arg0 -> PluginTemplate.JAVA.openEditorExceptionHandled());
@ -611,6 +619,8 @@ public class MainViewerGUI extends JFrame
allatoriStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new AllatoriStringDecrypter.AllatoriStringDecrypterOptions()));
ZKMStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new ZKMStringDecrypter()));
zStringArrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter()));
viewAPKAndroidPermissions.addActionListener(arg0 -> PluginManager.runPlugin(new ViewAPKAndroidPermissions()));
viewManifest.addActionListener(arg0 -> PluginManager.runPlugin(new ViewManifest()));
}
public void buildObfuscateMenu()
@ -803,7 +813,7 @@ public class MainViewerGUI extends JFrame
LazyNameUtil.reset();
ArrayList<File> reopen = new ArrayList<>();
for (ResourceContainer container : BytecodeViewer.files) {
for (ResourceContainer container : BytecodeViewer.resourceContainers) {
File newFile = new File(container.file.getParent() + fs + container.name);
if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) &&
(container.file.getAbsolutePath().endsWith(".apk") || container.file.getAbsolutePath().endsWith(".dex"))) //APKs & dex get renamed
@ -814,7 +824,7 @@ public class MainViewerGUI extends JFrame
reopen.add(container.file);
}
BytecodeViewer.files.clear();
BytecodeViewer.resourceContainers.clear();
for (File f : reopen) {
BytecodeViewer.openFiles(new File[]{f}, false);
@ -837,83 +847,6 @@ public class MainViewerGUI extends JFrame
BytecodeViewer.openFiles(new File[]{file}, true);
BytecodeViewer.updateBusyStatus(false);
}
public void selectPythonC()
{
final File file = DialogueUtils.fileChooser("Select Python 2.7 Executable",
"Python (Or PyPy for speed) 2.7 Executable",
"everything");
if(file == null)
return;
Configuration.python = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJavac()
{
final File file = DialogueUtils.fileChooser("Select Javac Executable",
"Javac Executable (Requires JDK 'C:/programfiles/Java/JDK_xx/bin/javac.exe)",
"everything");
if(file == null)
return;
Configuration.javac = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJava()
{
final File file = DialogueUtils.fileChooser("Select Java Executable",
"Java Executable (Inside Of JRE/JDK 'C:/programfiles/Java/JDK_xx/bin/java.exe')",
"everything");
if(file == null)
return;
Configuration.java = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectPythonC3()
{
final File file = DialogueUtils.fileChooser("Select Python 3.x Executable",
"Python (Or PyPy for speed) 3.x Executable",
"everything");
if(file == null)
return;
Configuration.python3 = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectOpenalLibraryFolder()
{
final File file = DialogueUtils.fileChooser("Select Library Folder",
"Optional Library Folder",
"everything");
if(file == null)
return;
Configuration.library = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJRERTLibrary() {
final File file = DialogueUtils.fileChooser("Select JRE RT Jar",
"JRE RT Library",
"everything");
if(file == null)
return;
Configuration.rt = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void openExternalPlugin()
{

View file

@ -4,15 +4,11 @@ import java.awt.*;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import the.bytecode.club.bootloader.InitialBootScreen;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import static the.bytecode.club.bytecodeviewer.Configuration.*;
import static the.bytecode.club.bytecodeviewer.Constants.*;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *

View file

@ -34,7 +34,7 @@ public class HTMLPane extends JEditorPane
text = text.replace("{java}", Configuration.java);
text = text.replace("{javac}", Configuration.javac);
text = text.replace("{bcvDir}", BCVDir.getAbsolutePath());
text = text.replace("{python}", Configuration.python);
text = text.replace("{python}", Configuration.python2);
text = text.replace("{python3}", Configuration.python3);
text = text.replace("{rt}", Configuration.rt);
text = text.replace("{lib}", Configuration.library);

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.components;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import javax.swing.*;
import java.awt.*;

View file

@ -106,11 +106,7 @@ public class JFrameConsolePrintStream extends JFrameConsole
String content = getTextArea().getText();
if(content.contains("File `"))
{
String[] test;
if (content.split("\n").length >= 2)
test = content.split("\n");
else
test = content.split("\r");
String[] test = content.split("\r?\n");
StringBuilder replace = new StringBuilder();
for (String s : test)

View file

@ -7,7 +7,7 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.api.ASMResourceUtil;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection;

View file

@ -1,8 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.components;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.GlobalHotKeys;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.PressKeyListener;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener;
import the.bytecode.club.bytecodeviewer.translation.Translation;

View file

@ -2,10 +2,9 @@ package the.bytecode.club.bytecodeviewer.gui.components;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.RTextScrollPane;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.GlobalHotKeys;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.PressKeyListener;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener;
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.components;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import javax.swing.*;

View file

@ -5,7 +5,7 @@ import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *

View file

@ -1,7 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.plugins;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScanModule;
import the.bytecode.club.bytecodeviewer.malwarescanner.util.MaliciousCodeOptions;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;

View file

@ -8,7 +8,7 @@ import javax.swing.JLabel;
import javax.swing.JTextField;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ReplaceStrings;

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;

View file

@ -111,7 +111,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
//used to remove resources from the resource list
public void removeFile(ResourceContainer resourceContainer)
{
BytecodeViewer.files.remove(resourceContainer);
BytecodeViewer.resourceContainers.remove(resourceContainer);
LazyNameUtil.removeName(resourceContainer.name);
}
@ -160,7 +160,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
try
{
treeRoot.removeAllChildren();
for (ResourceContainer container : BytecodeViewer.files)
for (ResourceContainer container : BytecodeViewer.resourceContainers)
{
ResourceTreeNode root = new ResourceTreeNode(container.name);
treeRoot.add(root);
@ -301,7 +301,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
String cheapHax = path.getPathComponent(1).toString();
ResourceContainer container = null;
for (ResourceContainer c : BytecodeViewer.files)
for (ResourceContainer c : BytecodeViewer.resourceContainers)
{
if (c.name.equals(cheapHax))
container = c;

View file

@ -44,7 +44,7 @@ public class ResourceListRightClickRemove extends AbstractAction
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
root.remove(node);
for (ResourceContainer resourceContainer : BytecodeViewer.files)
for (ResourceContainer resourceContainer : BytecodeViewer.resourceContainers)
{
if (resourceContainer.name.equals(selectNode.toString()))
{

View file

@ -2,7 +2,6 @@ package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
@ -11,7 +10,6 @@ import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import javax.swing.tree.TreePath;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@ -42,7 +40,7 @@ class PerformSearch extends BackgroundSearchThread
BytecodeViewer.showMessage("You have an error in your regex syntax.");
}
for (ResourceContainer container : BytecodeViewer.files)
for (ResourceContainer container : BytecodeViewer.resourceContainers)
for (ClassNode c : container.resourceClasses.values())
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected());

View file

@ -2,8 +2,7 @@ package the.bytecode.club.bytecodeviewer.plugin;
import org.apache.commons.io.FilenameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import java.io.IOException;

View file

@ -4,8 +4,7 @@ import me.konloch.kontainer.io.DiskWriter;
import org.apache.commons.compress.utils.FileNameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
import the.bytecode.club.bytecodeviewer.translation.Translation;

View file

@ -8,7 +8,7 @@ import java.util.ArrayList;
import org.objectweb.asm.tree.*;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.api.*;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;

View file

@ -13,7 +13,7 @@ import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;

View file

@ -34,7 +34,16 @@ public class ViewAPKAndroidPermissions extends Plugin
String[] lines = manifest.split("\r?\n");
for(String line : lines)
if(line.toLowerCase().contains("uses-permission"))
frame.appendText(line.trim());
{
String cleaned = line.trim();
if(cleaned.startsWith("<"))
cleaned = cleaned.substring(1);
if(cleaned.contains(" android:name=\""))
cleaned = cleaned.replace(" android:name=\"", ": ");
if(cleaned.endsWith("\"/>"))
cleaned = cleaned.substring(0, cleaned.length()-3);
frame.appendText(cleaned);
}
}
else
frame.appendText("Enable Settings>Decode APK Resources!");

View file

@ -36,7 +36,7 @@ public class ViewManifest extends Plugin
if(jarManifest != null)
{
if(!frame.getTextArea().getText().isEmpty())
frame.appendText("\r\r\r\r");
frame.appendText("\r\n\r\n");
frame.appendText("Java Jar Manifest:\r");
frame.appendText(new String(jarManifest, StandardCharsets.UTF_8));

View file

@ -0,0 +1,281 @@
package the.bytecode.club.bytecodeviewer.resources;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.SettingsSerializer;
import the.bytecode.club.bytecodeviewer.util.DialogueUtils;
import the.bytecode.club.bytecodeviewer.util.JRTExtractor;
import java.io.File;
import java.util.Objects;
import static the.bytecode.club.bytecodeviewer.Constants.*;
/***************************************************************************
* 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/>. *
***************************************************************************/
/**
* Anything that isn't accessible from inside of the JVM is here
*
* @author Konloch
* @since 7/11/2021
*/
public class ExternalResources
{
private static final ExternalResources SINGLETON = new ExternalResources();
public static ExternalResources getSingleton()
{
return SINGLETON;
}
/**
* Auto-detect the Java command
*/
public String getJavaCommand(boolean blockTillSelected)
{
boolean empty = Configuration.java.isEmpty();
if(!empty)
return Configuration.java;
BytecodeViewer.sm.pauseBlocking();
try
{
//TODO read the version output to verify it exists
ProcessBuilder pb = new ProcessBuilder("java", "-version");
pb.start();
Configuration.java = "java"; //java is set
return Configuration.java;
}
catch (Exception e) { } //ignore
finally
{
BytecodeViewer.sm.resumeBlocking();
}
//TODO auto-detect the Java path
boolean block = true;
while (Configuration.java.isEmpty() && block)
{
BytecodeViewer.showMessage("You need to set your Java path, this requires the JRE to be downloaded." +
nl + "(C:/Program Files/Java/JDK_xx/bin/java.exe)");
ExternalResources.getSingleton().selectJava();
block = !blockTillSelected; //signal block flag off
}
return Configuration.java;
}
/**
* Check if the python command has been set
*/
public boolean hasSetPythonCommand()
{
return !getPythonCommand(false).isEmpty();
}
/**
* Auto-detect the Java command
*/
public String getPythonCommand(boolean blockTillSelected)
{
boolean empty = Configuration.java.isEmpty();
if(!empty)
return Configuration.java;
BytecodeViewer.sm.pauseBlocking();
//check using python CLI flag
try
{
//TODO read the version output to verify python 2
ProcessBuilder pb = new ProcessBuilder("python", "-2", "--version");
pb.start();
Configuration.python2 = "python -2"; //python is set
return Configuration.python2;
}
catch (Exception e) { } //ignore
finally
{
BytecodeViewer.sm.resumeBlocking();
}
//check if 'python' command is bound as python 2.X
try
{
//TODO read the version output to verify python 2
ProcessBuilder pb = new ProcessBuilder("python", "--version");
pb.start();
Configuration.python2 = "python"; //python is set
return Configuration.python2;
}
catch (Exception e) { } //ignore
finally
{
BytecodeViewer.sm.resumeBlocking();
}
//TODO auto-detect the Python path
boolean block = true;
while (Configuration.python2.isEmpty() && block)
{
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
selectPython2();
block = !blockTillSelected; //signal block flag off
}
return Configuration.python2;
}
//rt.jar check
public synchronized void rtCheck()
{
if (Configuration.rt.isEmpty())
{
if (RT_JAR.exists())
Configuration.rt = RT_JAR.getAbsolutePath();
else if (RT_JAR_DUMPED.exists())
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
else try {
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
public void selectPython2()
{
final File file = DialogueUtils.fileChooser("Select Python 2.7 Executable",
"Python (Or PyPy for speed) 2.7 Executable",
"everything");
if(file == null)
return;
Configuration.python2 = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectPython3()
{
final File file = DialogueUtils.fileChooser("Select Python 3.x Executable",
"Python (Or PyPy for speed) 3.x Executable",
"everything");
if(file == null)
return;
Configuration.python3 = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJavac()
{
final File file = DialogueUtils.fileChooser("Select Javac Executable",
"Javac Executable (Requires JDK 'C:/Program Files/Java/JDK_xx/bin/javac.exe)",
"everything");
if(file == null)
return;
Configuration.javac = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJava()
{
final File file = DialogueUtils.fileChooser("Select Java Executable",
"Java Executable (Inside Of JRE/JDK 'C:/Program Files/Java/JDK_xx/bin/java.exe')",
"everything");
if(file == null)
return;
Configuration.java = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectOptionalLibraryFolder()
{
final File file = DialogueUtils.fileChooser("Select Library Folder",
"Optional Library Folder",
"everything");
if(file == null)
return;
Configuration.library = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJRERTLibrary()
{
final File file = DialogueUtils.fileChooser("Select JRE RT Jar",
"JRE RT Library",
"everything");
if(file == null)
return;
Configuration.rt = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
/**
* Finds a library from the library folder
*/
public String findLibrary(String nameContains)
{
for (File f : Objects.requireNonNull(new File(libsDirectory).listFiles()))
if (f.getName().contains(nameContains))
return f.getAbsolutePath();
return null;
}
/**
* Searches a directory until the extension is found
*/
public File findFile(File basePath, String extension)
{
for(File f : basePath.listFiles())
{
if(f.isDirectory())
{
File child = findFile(f, extension);
if(child != null)
return child;
continue;
}
if(f.getName().endsWith(extension))
return f;
}
return null;
}
}

View file

@ -1,6 +1,5 @@
package the.bytecode.club.bytecodeviewer;
package the.bytecode.club.bytecodeviewer.resources;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -15,6 +14,7 @@ import javax.swing.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.imgscalr.Scalr;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory;
@ -42,8 +42,8 @@ import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory;
* @author Konloch
*/
public class Resources {
public class Resources
{
public static List<BufferedImage> iconList;
public static BufferedImage icon;
public static ImageIcon nextIcon;
@ -134,13 +134,4 @@ public class Resources {
return image;
}
public static String findLibrary(String nameContains) {
for (File f : Objects.requireNonNull(new File(libsDirectory).listFiles())) {
if (f.getName().contains(nameContains))
return f.getAbsolutePath();
}
return null;
}
}

View file

@ -28,7 +28,7 @@ public class APKExport implements Exporter
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
List<ResourceContainer> containers = BytecodeViewer.getFiles();
List<ResourceContainer> containers = BytecodeViewer.getResourceContainers();
List<ResourceContainer> validContainers = new ArrayList<>();
List<String> validContainersNames = new ArrayList<>();
ResourceContainer container;

View file

@ -22,17 +22,15 @@ public class APKResourceImporter implements Importer
@Override
public void open(File file) throws Exception
{
BytecodeViewer.updateBusyStatus(true);
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
FileUtils.copyFile(file, tempCopy);
ResourceContainer container = new ResourceContainer(tempCopy, file.getName());
if (BytecodeViewer.viewer.decodeAPKResources.isSelected()) {
File decodedResources =
new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
//APK Resource Decoding Here
if (BytecodeViewer.viewer.decodeAPKResources.isSelected())
{
File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
APKTool.decodeResources(tempCopy, decodedResources, container);
container.resourceFiles = JarUtils.loadResources(decodedResources);
}
@ -52,7 +50,6 @@ public class APKResourceImporter implements Importer
container.copy(new ResourceContainerImporter(
new ResourceContainer(output)).importAsZip().getContainer());
BytecodeViewer.updateBusyStatus(false);
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -38,6 +38,6 @@ public class ClassResourceImporter implements Importer
//TODO double check this
container.resourceFiles.put(name, bytes);
}
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -21,8 +21,6 @@ public class DEXResourceImporter implements Importer
@Override
public void open(File file) throws Exception
{
BytecodeViewer.updateBusyStatus(true);
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex");
FileUtils.copyFile(file, tempCopy); //copy and rename to prevent unicode filenames
@ -41,7 +39,6 @@ public class DEXResourceImporter implements Importer
container.copy(new ResourceContainerImporter(
new ResourceContainer(output)).importAsZip().getContainer());
BytecodeViewer.updateBusyStatus(false);
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -88,6 +88,6 @@ public class DirectoryResourceImporter implements Importer
container.resourceClasses.putAll(allDirectoryClasses);
container.resourceFiles = allDirectoryFiles;
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -23,6 +23,6 @@ public class FileResourceImporter implements Importer
//import the file into the file container
importer.importAsFile();
//add the file container to BCV's total loaded files
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -72,7 +72,7 @@ public class XAPKResourceImporter implements Importer
Configuration.silenceExceptionGUI--; //turn exceptions back on
BytecodeViewer.viewer.clearBusyStatus(); //clear errant busy signals from failed APK imports
container.resourceFiles = allDirectoryFiles; //store the file resource
BytecodeViewer.files.add(container); //add the file container to BCV's total loaded files
BytecodeViewer.resourceContainers.add(container); //add the file container to BCV's total loaded files
}
public File exportTo(File original, String extension, byte[] bytes)

View file

@ -23,6 +23,6 @@ public class ZipResourceImporter implements Importer
//import the file as zip into the file container
importer.importAsZip();
//add the file container to BCV's total loaded files
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
}

View file

@ -4,7 +4,7 @@ import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.collections4.map.LinkedMap;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import java.io.IOException;
import java.util.Arrays;

View file

@ -1,54 +0,0 @@
package the.bytecode.club.bytecodeviewer.util;
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/>. *
***************************************************************************/
/**
* @author Konloch
* @since 7/4/2021
*/
public class BCVFileUtils
{
/**
* Searches a directory until the extension is found
*/
public static File findFile(File basePath, String extension)
{
for(File f : basePath.listFiles())
{
if(f.isDirectory())
{
File child = findFile(f, extension);
if(child != null)
return child;
continue;
}
if(f.getName().endsWith(extension))
{
return f;
}
}
return null;
}
}

View file

@ -1,53 +0,0 @@
package the.bytecode.club.bytecodeviewer.util;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.api.BCV;
import java.io.File;
import static the.bytecode.club.bytecodeviewer.Constants.*;
import static the.bytecode.club.bytecodeviewer.Constants.RT_JAR_DUMPED;
/***************************************************************************
* 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/>. *
***************************************************************************/
/**
* @author Konloch
* @since 7/6/2021
*/
public class BCVResourceUtils
{
//rt.jar check
public synchronized static void rtCheck()
{
if (Configuration.rt.isEmpty())
{
if (RT_JAR.exists())
Configuration.rt = RT_JAR.getAbsolutePath();
else if (RT_JAR_DUMPED.exists())
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
else try {
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.util;
import java.io.File;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory;
@ -41,7 +42,7 @@ public class Enjarify {
public static synchronized void apk2Jar(File input, File output) {
if (Configuration.python3.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
BytecodeViewer.viewer.selectPythonC3();
ExternalResources.getSingleton().selectPython3();
}
if (Configuration.python3.isEmpty()) {

View file

@ -56,9 +56,7 @@ public class JTextAreaUtils
int currentLine = 1;
boolean canSearch = false;
String[] test = (textArea.getText().split("\n").length >= 2
? textArea.getText().split("\n")
: textArea.getText().split("\r"));
String[] test = textArea.getText().split("\r?\n");
int lastGoodLine = -1;
int firstPos = -1;

View file

@ -103,7 +103,7 @@ public class JarUtils
}
jis.close();
container.resourceFiles = files;
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
@ -152,7 +152,7 @@ public class JarUtils
}
container.resourceFiles = files;
BytecodeViewer.files.add(container);
BytecodeViewer.resourceContainers.add(container);
}
public static ArrayList<ClassNode> loadClasses(final File jarFile) throws IOException
@ -262,7 +262,7 @@ public class JarUtils
out.write((manifest.trim() + "\r\n\r\n").getBytes());
out.closeEntry();
for (ResourceContainer container : BytecodeViewer.files)
for (ResourceContainer container : BytecodeViewer.resourceContainers)
for (Entry<String, byte[]> entry : container.resourceFiles.entrySet()) {
String filename = entry.getKey();
if (!filename.startsWith("META-INF")) {
@ -366,7 +366,7 @@ public class JarUtils
}
}
for (ResourceContainer container : BytecodeViewer.files)
for (ResourceContainer container : BytecodeViewer.resourceContainers)
for (Entry<String, byte[]> entry : container.resourceFiles.entrySet()) {
String filename = entry.getKey();
if (!filename.startsWith("META-INF")) {

View file

@ -49,6 +49,7 @@ public class SecurityMan extends SecurityManager
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.FernFlowerDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.JDGUIDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.KrakatauAssembler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.resources.ExternalResources") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.Enjarify") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") ||