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.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.IOException; import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import javax.swing.JScrollPane; 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.Configuration;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.gui.components.HTMLPane; import the.bytecode.club.bytecodeviewer.gui.components.HTMLPane;
import static the.bytecode.club.bytecodeviewer.Configuration.language; 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 * + Make zipfile not include the decode shit
* + Add decompile as zip for krakatau-bytecode, jd-gui and smali for CLI * + Add decompile as zip for krakatau-bytecode, jd-gui and smali for CLI
* + Add decompile all as zip 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: * TODO IDEAS:
* + App Bundle Support * + App Bundle Support
@ -116,7 +118,7 @@ public class BytecodeViewer
public static MainViewerGUI viewer; public static MainViewerGUI viewer;
//All of the opened resources (Files/Classes/Etc) //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) //All of the created processes (Decompilers/etc)
public static List<Process> createdProcesses = new ArrayList<>(); public static List<Process> createdProcesses = new ArrayList<>();
@ -264,47 +266,13 @@ public class BytecodeViewer
for (String s : launchArgs) for (String s : launchArgs)
openFiles(new File[]{new File(s)}, true); 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 * Returns true if there is at least one file resource loaded
*/ */
public static boolean hasResources() public static boolean hasResources()
{ {
return !files.isEmpty(); return !resourceContainers.isEmpty();
} }
/** /**
@ -353,7 +321,7 @@ public class BytecodeViewer
@Deprecated @Deprecated
public static ClassNode blindlySearchForClassNode(String name) public static ClassNode blindlySearchForClassNode(String name)
{ {
for (ResourceContainer container : files) for (ResourceContainer container : resourceContainers)
{ {
ClassNode node = container.getClassNode(name); ClassNode node = container.getClassNode(name);
if(node != null) if(node != null)
@ -368,7 +336,7 @@ public class BytecodeViewer
*/ */
public static ResourceContainer getFileContainer(String name) public static ResourceContainer getFileContainer(String name)
{ {
for (ResourceContainer container : files) for (ResourceContainer container : resourceContainers)
if (container.name.equals(name)) if (container.name.equals(name))
return container; return container;
@ -378,8 +346,8 @@ public class BytecodeViewer
/** /**
* Returns all of the loaded File Containers * Returns all of the loaded File Containers
*/ */
public static List<ResourceContainer> getFiles() { public static List<ResourceContainer> getResourceContainers() {
return files; return resourceContainers;
} }
/** /**
@ -390,7 +358,7 @@ public class BytecodeViewer
*/ */
public static byte[] getFileContents(String name) public static byte[] getFileContents(String name)
{ {
for (ResourceContainer container : files) for (ResourceContainer container : resourceContainers)
if (container.resourceFiles.containsKey(name)) if (container.resourceFiles.containsKey(name))
return container.resourceFiles.get(name); return container.resourceFiles.get(name);
@ -414,7 +382,7 @@ public class BytecodeViewer
{ {
ArrayList<ClassNode> a = new ArrayList<>(); ArrayList<ClassNode> a = new ArrayList<>();
for (ResourceContainer container : files) for (ResourceContainer container : resourceContainers)
for (ClassNode c : container.resourceClasses.values()) for (ClassNode c : container.resourceClasses.values())
if (!a.contains(c)) if (!a.contains(c))
a.add(c); a.add(c);
@ -631,7 +599,7 @@ public class BytecodeViewer
*/ */
public static void resetWorkspace() public static void resetWorkspace()
{ {
BytecodeViewer.files.clear(); BytecodeViewer.resourceContainers.clear();
LazyNameUtil.reset(); LazyNameUtil.reset();
BytecodeViewer.viewer.resourcePane.resetWorkspace(); BytecodeViewer.viewer.resourcePane.resetWorkspace();
BytecodeViewer.viewer.workPane.resetWorkspace(); BytecodeViewer.viewer.workPane.resetWorkspace();

View file

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

View file

@ -17,11 +17,14 @@ public class Constants
public static String krakatauVersion = "12"; public static String krakatauVersion = "12";
public static String enjarifyVersion = "4"; public static String enjarifyVersion = "4";
public static final boolean BLOCK_TAB_MENU = true; 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 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 boolean OFFLINE_MODE = true; //disables the automatic updater
public static final String fs = System.getProperty("file.separator"); public static final String fs = System.getProperty("file.separator");
public static final String nl = System.getProperty("line.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 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 = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + 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("deprecated"); save("deprecated");
save(Configuration.lastDirectory); save(Configuration.lastDirectory);
save(Configuration.python); save(Configuration.python2);
save(Configuration.rt); save(Configuration.rt);
save("deprecated"); save("deprecated");
save("deprecated"); save("deprecated");
@ -301,7 +301,7 @@ public class SettingsSerializer
//86 is deprecated //86 is deprecated
//87 is deprecated //87 is deprecated
Configuration.lastDirectory = asString(88); Configuration.lastDirectory = asString(88);
Configuration.python = asString(89); Configuration.python2 = asString(89);
Configuration.rt = asString(90); Configuration.rt = asString(90);
BytecodeViewer.viewer.decodeAPKResources.setSelected(asBoolean(106)); BytecodeViewer.viewer.decodeAPKResources.setSelected(asBoolean(106));

View file

@ -10,7 +10,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import the.bytecode.club.bytecodeviewer.Configuration; 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.*; 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.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -54,8 +55,8 @@ public class JavaCompiler extends InternalCompiler
new File(fileStart2).mkdirs(); new File(fileStart2).mkdirs();
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists()) { 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.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)");
BytecodeViewer.viewer.selectJavac(); ExternalResources.getSingleton().selectJavac();
} }
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists()) { 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.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -46,12 +46,12 @@ public class KrakatauAssembler extends InternalCompiler
@Override @Override
public byte[] compile(String contents, String name) { 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.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!"); BytecodeViewer.showMessage("You need to set Python!");
return null; return null;
} }
@ -76,7 +76,7 @@ public class KrakatauAssembler extends InternalCompiler
try try
{ {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "assemble.py", krakatauWorkingDirectory + fs + "assemble.py",
"-out", "-out",
@ -112,7 +112,8 @@ public class KrakatauAssembler extends InternalCompiler
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append("Exit Value is ").append(exitValue);
System.err.println(log); 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(); tempDirectory.delete();
tempJar.delete(); tempJar.delete();
return b; return b;

View file

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

View file

@ -10,11 +10,12 @@ import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskReader;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bootloader.resource.ExternalResource;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -65,20 +66,19 @@ public class KrakatauDecompiler extends InternalDecompiler
.map(File::getAbsolutePath).collect(Collectors.joining(";")); .map(File::getAbsolutePath).collect(Collectors.joining(";"));
} }
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) { 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."); if(!ExternalResources.getSingleton().hasSetPythonCommand())
BytecodeViewer.viewer.selectPythonC(); return "You need to set your Python 2.7 path!";
}
BCVResourceUtils.rtCheck(); ExternalResources.getSingleton().rtCheck();
if (Configuration.rt.isEmpty()) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library.\r\n(C:\\Program Files (x86)" BytecodeViewer.showMessage("You need to set your JRE RT Library.\r\n(C:\\Program Files (x86)"
+ "\\Java\\jre7\\lib\\rt.jar)"); + "\\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!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -94,7 +94,7 @@ public class KrakatauDecompiler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py", krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3 "-skip", //love you storyyeller <3
@ -149,17 +149,17 @@ public class KrakatauDecompiler extends InternalDecompiler
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] b) { 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.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()) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." + BytecodeViewer.showMessage("You need to set your JRE RT Library." +
"\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)"); "\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!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -182,7 +182,7 @@ public class KrakatauDecompiler extends InternalDecompiler
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py", krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3 "-skip", //love you storyyeller <3
@ -240,16 +240,16 @@ public class KrakatauDecompiler extends InternalDecompiler
@Override @Override
public void decompileToZip(String sourceJar, String zipName) { 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.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()) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." + BytecodeViewer.showMessage("You need to set your JRE RT Library." +
"\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)"); "\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.selectJRERTLibrary(); ExternalResources.getSingleton().selectJRERTLibrary();
} }
String ran = MiscUtils.randomString(32); String ran = MiscUtils.randomString(32);
@ -263,7 +263,7 @@ public class KrakatauDecompiler extends InternalDecompiler
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "decompile.py", krakatauWorkingDirectory + fs + "decompile.py",
"-skip", //love you storyyeller <3 "-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.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; 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.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils; 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) { 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.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!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -62,7 +63,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-path",
@ -115,12 +116,12 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] b) { 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.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!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -136,7 +137,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-path",
@ -188,9 +189,9 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override @Override
public void decompileToZip(String sourceJar, String zipName) { 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.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); String ran = MiscUtils.randomString(32);
@ -202,7 +203,7 @@ public class KrakatauDisassembler extends InternalDecompiler
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
Configuration.python, Configuration.python2,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-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.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.PluginTemplate; import the.bytecode.club.bytecodeviewer.plugin.PluginTemplate;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.*; 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.ResourceContainer;
import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.resources.exporting.Export; import the.bytecode.club.bytecodeviewer.resources.exporting.Export;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem; 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 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 allatoriStringDecrypter = new TranslatedJMenuItem("Allatori String Decrypter", Translation.ALLATORI_STRING_DECRYPTER);
public final JMenuItem zStringArrayDecrypter = new TranslatedJMenuItem("ZStringArray Decrypter", Translation.ZSTRINGARRAY_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 //all of the settings main menu components
public final ButtonGroup apkConversionGroup = new ButtonGroup(); public final ButtonGroup apkConversionGroup = new ButtonGroup();
@ -560,11 +564,11 @@ public class MainViewerGUI extends JFrame
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning()); deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync()); forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync());
setPython2.addActionListener(arg0 -> selectPythonC()); setPython2.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython2());
setJRERT.addActionListener(arg0 -> selectJRERTLibrary()); setJRERT.addActionListener(arg0 -> ExternalResources.getSingleton().selectJRERTLibrary());
setPython3.addActionListener(arg0 -> selectPythonC3()); setPython3.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython3());
setOptionalLibrary.addActionListener(arg0 -> selectOpenalLibraryFolder()); setOptionalLibrary.addActionListener(arg0 -> ExternalResources.getSingleton().selectOptionalLibraryFolder());
setJavac.addActionListener(arg0 -> selectJavac()); setJavac.addActionListener(arg0 -> ExternalResources.getSingleton().selectJavac());
showFileInTabTitle.addActionListener(arg0 -> { showFileInTabTitle.addActionListener(arg0 -> {
Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected(); Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
SettingsSerializer.saveSettingsAsync(); SettingsSerializer.saveSettingsAsync();
@ -586,7 +590,10 @@ public class MainViewerGUI extends JFrame
pluginsMainMenu.add(new JSeparator()); pluginsMainMenu.add(new JSeparator());
pluginsMainMenu.add(newJavaPlugin); pluginsMainMenu.add(newJavaPlugin);
pluginsMainMenu.add(newJavascriptPlugin); pluginsMainMenu.add(newJavascriptPlugin);
pluginsMainMenu.add(new JSeparator()); //android specific plugins first
pluginsMainMenu.add(viewAPKAndroidPermissions);
pluginsMainMenu.add(new JSeparator()); pluginsMainMenu.add(new JSeparator());
pluginsMainMenu.add(viewManifest);
pluginsMainMenu.add(codeSequenceDiagram); pluginsMainMenu.add(codeSequenceDiagram);
pluginsMainMenu.add(maliciousCodeScanner); pluginsMainMenu.add(maliciousCodeScanner);
pluginsMainMenu.add(showMainMethods); pluginsMainMenu.add(showMainMethods);
@ -594,10 +601,11 @@ public class MainViewerGUI extends JFrame
pluginsMainMenu.add(replaceStrings); pluginsMainMenu.add(replaceStrings);
pluginsMainMenu.add(stackFramesRemover); 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(mntmNewMenuItem_2);
//mnNewMenu_1.add(mntmStartZkmString); //mnNewMenu_1.add(mntmStartZkmString);
pluginsMainMenu.add(zStringArrayDecrypter); //pluginsMainMenu.add(zStringArrayDecrypter);
openExternalPlugin.addActionListener(arg0 -> openExternalPlugin()); openExternalPlugin.addActionListener(arg0 -> openExternalPlugin());
newJavaPlugin.addActionListener(arg0 -> PluginTemplate.JAVA.openEditorExceptionHandled()); newJavaPlugin.addActionListener(arg0 -> PluginTemplate.JAVA.openEditorExceptionHandled());
@ -611,6 +619,8 @@ public class MainViewerGUI extends JFrame
allatoriStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new AllatoriStringDecrypter.AllatoriStringDecrypterOptions())); allatoriStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new AllatoriStringDecrypter.AllatoriStringDecrypterOptions()));
ZKMStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new ZKMStringDecrypter())); ZKMStringDecrypter.addActionListener(e -> PluginManager.runPlugin(new ZKMStringDecrypter()));
zStringArrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter())); zStringArrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter()));
viewAPKAndroidPermissions.addActionListener(arg0 -> PluginManager.runPlugin(new ViewAPKAndroidPermissions()));
viewManifest.addActionListener(arg0 -> PluginManager.runPlugin(new ViewManifest()));
} }
public void buildObfuscateMenu() public void buildObfuscateMenu()
@ -803,7 +813,7 @@ public class MainViewerGUI extends JFrame
LazyNameUtil.reset(); LazyNameUtil.reset();
ArrayList<File> reopen = new ArrayList<>(); 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); File newFile = new File(container.file.getParent() + fs + container.name);
if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) && if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) &&
(container.file.getAbsolutePath().endsWith(".apk") || container.file.getAbsolutePath().endsWith(".dex"))) //APKs & dex get renamed (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); reopen.add(container.file);
} }
BytecodeViewer.files.clear(); BytecodeViewer.resourceContainers.clear();
for (File f : reopen) { for (File f : reopen) {
BytecodeViewer.openFiles(new File[]{f}, false); BytecodeViewer.openFiles(new File[]{f}, false);
@ -837,83 +847,6 @@ public class MainViewerGUI extends JFrame
BytecodeViewer.openFiles(new File[]{file}, true); BytecodeViewer.openFiles(new File[]{file}, true);
BytecodeViewer.updateBusyStatus(false); 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() public void openExternalPlugin()
{ {

View file

@ -4,15 +4,11 @@ import java.awt.*;
import java.io.IOException; import java.io.IOException;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import the.bytecode.club.bootloader.InitialBootScreen; import the.bytecode.club.bootloader.InitialBootScreen;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.resources.Resources;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources;
import static the.bytecode.club.bytecodeviewer.Configuration.*; import static the.bytecode.club.bytecodeviewer.Configuration.*;
import static the.bytecode.club.bytecodeviewer.Constants.*;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * 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("{java}", Configuration.java);
text = text.replace("{javac}", Configuration.javac); text = text.replace("{javac}", Configuration.javac);
text = text.replace("{bcvDir}", BCVDir.getAbsolutePath()); 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("{python3}", Configuration.python3);
text = text.replace("{rt}", Configuration.rt); text = text.replace("{rt}", Configuration.rt);
text = text.replace("{lib}", Configuration.library); text = text.replace("{lib}", Configuration.library);

View file

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

View file

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

View file

@ -7,7 +7,7 @@ import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JTextField; 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.api.ASMResourceUtil;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager; import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection;

View file

@ -1,8 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.components; package the.bytecode.club.bytecodeviewer.gui.components;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.GlobalHotKeys; 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.PressKeyListener;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener; import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener;
import the.bytecode.club.bytecodeviewer.translation.Translation; 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.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.RTextScrollPane;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.GlobalHotKeys; 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.PressKeyListener;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener; import the.bytecode.club.bytecodeviewer.gui.components.listeners.ReleaseKeyListener;
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;

View file

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

View file

@ -5,7 +5,7 @@ import java.awt.Dimension;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTabbedPane; 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 * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *

View file

@ -1,7 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.plugins; package the.bytecode.club.bytecodeviewer.gui.plugins;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.MalwareScanModule;
import the.bytecode.club.bytecodeviewer.malwarescanner.util.MaliciousCodeOptions; import the.bytecode.club.bytecodeviewer.malwarescanner.util.MaliciousCodeOptions;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager; import the.bytecode.club.bytecodeviewer.plugin.PluginManager;

View file

@ -8,7 +8,7 @@ import javax.swing.JLabel;
import javax.swing.JTextField; import javax.swing.JTextField;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.PluginManager;
import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ReplaceStrings; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ReplaceStrings;

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.resourcelist; 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.*;
import javax.swing.tree.DefaultTreeCellRenderer; 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 //used to remove resources from the resource list
public void removeFile(ResourceContainer resourceContainer) public void removeFile(ResourceContainer resourceContainer)
{ {
BytecodeViewer.files.remove(resourceContainer); BytecodeViewer.resourceContainers.remove(resourceContainer);
LazyNameUtil.removeName(resourceContainer.name); LazyNameUtil.removeName(resourceContainer.name);
} }
@ -160,7 +160,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
try try
{ {
treeRoot.removeAllChildren(); treeRoot.removeAllChildren();
for (ResourceContainer container : BytecodeViewer.files) for (ResourceContainer container : BytecodeViewer.resourceContainers)
{ {
ResourceTreeNode root = new ResourceTreeNode(container.name); ResourceTreeNode root = new ResourceTreeNode(container.name);
treeRoot.add(root); treeRoot.add(root);
@ -301,7 +301,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
String cheapHax = path.getPathComponent(1).toString(); String cheapHax = path.getPathComponent(1).toString();
ResourceContainer container = null; ResourceContainer container = null;
for (ResourceContainer c : BytecodeViewer.files) for (ResourceContainer c : BytecodeViewer.resourceContainers)
{ {
if (c.name.equals(cheapHax)) if (c.name.equals(cheapHax))
container = c; container = c;

View file

@ -44,7 +44,7 @@ public class ResourceListRightClickRemove extends AbstractAction
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
root.remove(node); root.remove(node);
for (ResourceContainer resourceContainer : BytecodeViewer.files) for (ResourceContainer resourceContainer : BytecodeViewer.resourceContainers)
{ {
if (resourceContainer.name.equals(selectNode.toString())) 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 org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.BackgroundSearchThread;
import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder; import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder;
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch; 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 the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
@ -42,7 +40,7 @@ class PerformSearch extends BackgroundSearchThread
BytecodeViewer.showMessage("You have an error in your regex syntax."); 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()) for (ClassNode c : container.resourceClasses.values())
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected()); 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 org.apache.commons.io.FilenameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.ExceptionUI;
import java.io.IOException; import java.io.IOException;

View file

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

View file

@ -8,7 +8,7 @@ import java.util.ArrayList;
import org.objectweb.asm.tree.*; import org.objectweb.asm.tree.*;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Constants; 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.api.*;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager; 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.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.api.Plugin;
import the.bytecode.club.bytecodeviewer.plugin.PluginManager; import the.bytecode.club.bytecodeviewer.plugin.PluginManager;

View file

@ -34,7 +34,16 @@ public class ViewAPKAndroidPermissions extends Plugin
String[] lines = manifest.split("\r?\n"); String[] lines = manifest.split("\r?\n");
for(String line : lines) for(String line : lines)
if(line.toLowerCase().contains("uses-permission")) 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 else
frame.appendText("Enable Settings>Decode APK Resources!"); frame.appendText("Enable Settings>Decode APK Resources!");

View file

@ -36,7 +36,7 @@ public class ViewManifest extends Plugin
if(jarManifest != null) if(jarManifest != null)
{ {
if(!frame.getTextArea().getText().isEmpty()) 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("Java Jar Manifest:\r");
frame.appendText(new String(jarManifest, StandardCharsets.UTF_8)); 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.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@ -15,6 +14,7 @@ import javax.swing.*;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.imgscalr.Scalr; import org.imgscalr.Scalr;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory; import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory;
@ -42,8 +42,8 @@ import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory;
* @author Konloch * @author Konloch
*/ */
public class Resources { public class Resources
{
public static List<BufferedImage> iconList; public static List<BufferedImage> iconList;
public static BufferedImage icon; public static BufferedImage icon;
public static ImageIcon nextIcon; public static ImageIcon nextIcon;
@ -134,13 +134,4 @@ public class Resources {
return image; 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()) if (BytecodeViewer.promptIfNoLoadedClasses())
return; return;
List<ResourceContainer> containers = BytecodeViewer.getFiles(); List<ResourceContainer> containers = BytecodeViewer.getResourceContainers();
List<ResourceContainer> validContainers = new ArrayList<>(); List<ResourceContainer> validContainers = new ArrayList<>();
List<String> validContainersNames = new ArrayList<>(); List<String> validContainersNames = new ArrayList<>();
ResourceContainer container; ResourceContainer container;

View file

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

View file

@ -38,6 +38,6 @@ public class ClassResourceImporter implements Importer
//TODO double check this //TODO double check this
container.resourceFiles.put(name, bytes); 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 @Override
public void open(File file) throws Exception public void open(File file) throws Exception
{ {
BytecodeViewer.updateBusyStatus(true);
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex"); File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex");
FileUtils.copyFile(file, tempCopy); //copy and rename to prevent unicode filenames FileUtils.copyFile(file, tempCopy); //copy and rename to prevent unicode filenames
@ -41,7 +39,6 @@ public class DEXResourceImporter implements Importer
container.copy(new ResourceContainerImporter( container.copy(new ResourceContainerImporter(
new ResourceContainer(output)).importAsZip().getContainer()); new ResourceContainer(output)).importAsZip().getContainer());
BytecodeViewer.updateBusyStatus(false); BytecodeViewer.resourceContainers.add(container);
BytecodeViewer.files.add(container);
} }
} }

View file

@ -88,6 +88,6 @@ public class DirectoryResourceImporter implements Importer
container.resourceClasses.putAll(allDirectoryClasses); container.resourceClasses.putAll(allDirectoryClasses);
container.resourceFiles = allDirectoryFiles; 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 //import the file into the file container
importer.importAsFile(); importer.importAsFile();
//add the file container to BCV's total loaded files //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 Configuration.silenceExceptionGUI--; //turn exceptions back on
BytecodeViewer.viewer.clearBusyStatus(); //clear errant busy signals from failed APK imports BytecodeViewer.viewer.clearBusyStatus(); //clear errant busy signals from failed APK imports
container.resourceFiles = allDirectoryFiles; //store the file resource 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) 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 //import the file as zip into the file container
importer.importAsZip(); importer.importAsZip();
//add the file container to BCV's total loaded files //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.HashedMap;
import org.apache.commons.collections4.map.LinkedMap; import org.apache.commons.collections4.map.LinkedMap;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; 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.io.IOException;
import java.util.Arrays; 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 java.io.File;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory; import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory;
@ -41,7 +42,7 @@ public class Enjarify {
public static synchronized void apk2Jar(File input, File output) { public static synchronized void apk2Jar(File input, File output) {
if (Configuration.python3.isEmpty()) { if (Configuration.python3.isEmpty()) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path."); 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()) { if (Configuration.python3.isEmpty()) {

View file

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

View file

@ -103,7 +103,7 @@ public class JarUtils
} }
jis.close(); jis.close();
container.resourceFiles = files; container.resourceFiles = files;
BytecodeViewer.files.add(container); BytecodeViewer.resourceContainers.add(container);
} }
@ -152,7 +152,7 @@ public class JarUtils
} }
container.resourceFiles = files; container.resourceFiles = files;
BytecodeViewer.files.add(container); BytecodeViewer.resourceContainers.add(container);
} }
public static ArrayList<ClassNode> loadClasses(final File jarFile) throws IOException 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.write((manifest.trim() + "\r\n\r\n").getBytes());
out.closeEntry(); out.closeEntry();
for (ResourceContainer container : BytecodeViewer.files) for (ResourceContainer container : BytecodeViewer.resourceContainers)
for (Entry<String, byte[]> entry : container.resourceFiles.entrySet()) { for (Entry<String, byte[]> entry : container.resourceFiles.entrySet()) {
String filename = entry.getKey(); String filename = entry.getKey();
if (!filename.startsWith("META-INF")) { 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()) { for (Entry<String, byte[]> entry : container.resourceFiles.entrySet()) {
String filename = entry.getKey(); String filename = entry.getKey();
if (!filename.startsWith("META-INF")) { 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.FernFlowerDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.JDGUIDecompiler") || executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.JDGUIDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.KrakatauAssembler") || 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.Enjarify") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") || executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") || executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") ||