Added a Configuration class

Moved the rest of the config-like variables from the main BytecodeViewer class to a new Configuration class
This commit is contained in:
Konloch 2021-06-21 04:13:11 -07:00
parent cb1c27f46c
commit 00a1bb539f
19 changed files with 205 additions and 219 deletions

View file

@ -14,6 +14,7 @@ import javax.swing.JProgressBar;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Resources;
/*************************************************************************** /***************************************************************************
@ -49,7 +50,7 @@ public class InitialBootScreen extends JFrame {
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
BytecodeViewer.canExit = true; Configuration.canExit = true;
System.exit(0); System.exit(0);
} }
}); });

View file

@ -80,6 +80,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
* Finish right-click tab menu detection * Finish right-click tab menu detection
* make it use that global last used inside of export as jar * make it use that global last used inside of export as jar
* Add https://github.com/ptnkjke/Java-Bytecode-Editor visualize as a plugin * Add https://github.com/ptnkjke/Java-Bytecode-Editor visualize as a plugin
* Add https://github.com/exbin/bined as the replacement Hed Viewer/Editor
* make zipfile not include the decode shit * make zipfile not include the decode shit
* add stackmapframes to bytecode decompiler * add stackmapframes to bytecode decompiler
* make ez-injection plugin console show all sys.out calls * make ez-injection plugin console show all sys.out calls
@ -96,28 +97,6 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
public class BytecodeViewer public class BytecodeViewer
{ {
public static String python = "";
public static String python3 = "";
public static String rt = "";
public static String library = "";
public static String javac = "";
public static String java = "";
private static File krakatauTempDir;
private static File krakatauTempJar;
public static boolean displayParentInTab = false; //also change in the main GUI
public static boolean currentlyDumping = false;
public static boolean needsReDump = true;
public static boolean warnForEditing = false;
public static boolean runningObfuscation = false;
private static final long start = System.currentTimeMillis();
public static String lastDirectory = ".";
public static boolean pingback = false;
public static boolean deleteForeignLibraries = true;
public static boolean canExit = false;
private static long last = System.currentTimeMillis();
public static boolean verify = false; //eventually may be a setting public static boolean verify = false; //eventually may be a setting
public static String[] args; public static String[] args;
public static MainViewerGUI viewer = null; public static MainViewerGUI viewer = null;
@ -127,7 +106,6 @@ public class BytecodeViewer
public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc
public static List<Process> createdProcesses = new ArrayList<>(); public static List<Process> createdProcesses = new ArrayList<>();
/** /**
* The version checker thread * The version checker thread
*/ */
@ -140,7 +118,7 @@ public class BytecodeViewer
try { try {
new HTTPRequest(new URL("https://bytecodeviewer.com/add.php")).read(); new HTTPRequest(new URL("https://bytecodeviewer.com/add.php")).read();
} catch (Exception e) { } catch (Exception e) {
pingback = false; Configuration.pingback = false;
} }
}); });
@ -248,9 +226,9 @@ public class BytecodeViewer
viewer.calledAfterLoad(); viewer.calledAfterLoad();
resetRecentFilesMenu(); resetRecentFilesMenu();
if (!pingback) { if (!Configuration.pingback) {
PingBack.start(); PingBack.start();
pingback = true; Configuration.pingback = true;
} }
if (viewer.chckbxmntmNewCheckItem_12.isSelected()) if (viewer.chckbxmntmNewCheckItem_12.isSelected())
@ -259,13 +237,12 @@ public class BytecodeViewer
if (!cli) if (!cli)
viewer.setVisible(true); viewer.setVisible(true);
System.out.println("Start up took " + ((System.currentTimeMillis() - start) / 1000) + " seconds"); System.out.println("Start up took " + ((System.currentTimeMillis() - Configuration.start) / 1000) + " seconds");
if (!cli) if (!cli)
if (args.length >= 1) if (args.length >= 1)
for (String s : args) { for (String s : args)
openFiles(new File[]{new File(s)}, true); openFiles(new File[]{new File(s)}, true);
}
} }
/** /**
@ -291,15 +268,15 @@ public class BytecodeViewer
return "java"; //java is set return "java"; //java is set
} catch (Exception e) { //ignore } catch (Exception e) { //ignore
sm.setBlocking(); sm.setBlocking();
boolean empty = java.isEmpty(); boolean empty = Configuration.java.isEmpty();
while (empty) { while (empty) {
showMessage("You need to set your Java path, this requires the JRE to be downloaded." + nl + showMessage("You need to set your Java path, this requires the JRE to be downloaded." + nl +
"(C:/programfiles/Java/JDK_xx/bin/java.exe)"); "(C:/Program Files/Java/JDK_xx/bin/java.exe)");
viewer.java(); viewer.java();
empty = java.isEmpty(); empty = Configuration.java.isEmpty();
} }
} }
return java; return Configuration.java;
} }
/** /**
@ -518,7 +495,7 @@ public class BytecodeViewer
BytecodeViewer.addRecentFile(f); BytecodeViewer.addRecentFile(f);
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
needsReDump = true; Configuration.needsReDump = true;
Thread t = new Thread(new OpenFile(files)); Thread t = new Thread(new OpenFile(files));
t.start(); t.start();
} }
@ -687,16 +664,15 @@ public class BytecodeViewer
* @param e * @param e
*/ */
public static void checkHotKey(KeyEvent e) { public static void checkHotKey(KeyEvent e) {
if (System.currentTimeMillis() - last <= (4000)) if (System.currentTimeMillis() - Configuration.lastHotKeyExecuted <= (4000))
return; return;
if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
try { try {
fc.setSelectedFile(new File(BytecodeViewer.lastDirectory)); fc.setSelectedFile(new File(Configuration.lastDirectory));
} catch (Exception ignored) { } catch (Exception ignored) {
} }
fc.setFileFilter(new FileFilter() { fc.setFileFilter(new FileFilter() {
@Override @Override
@ -721,7 +697,7 @@ public class BytecodeViewer
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer); int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION) { if (returnVal == JFileChooser.APPROVE_OPTION) {
BytecodeViewer.lastDirectory = fc.getSelectedFile().getAbsolutePath(); Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath();
try { try {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true); BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true);
@ -731,21 +707,21 @@ public class BytecodeViewer
} }
} }
} else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { } else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
BytecodeViewer.resetWorkSpace(true); BytecodeViewer.resetWorkSpace(true);
} else if ((e.getKeyCode() == KeyEvent.VK_T) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { } else if ((e.getKeyCode() == KeyEvent.VK_T) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
Thread t = new Thread(() -> BytecodeViewer.compile(true)); Thread t = new Thread(() -> BytecodeViewer.compile(true));
t.start(); t.start();
} else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { } else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
if (BytecodeViewer.getLoadedClasses().isEmpty()) { if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file."); BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
return; return;
} }
new RunOptions().setVisible(true); new RunOptions().setVisible(true);
} else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { } else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
if (BytecodeViewer.getLoadedClasses().isEmpty()) { if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file."); BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
@ -809,7 +785,7 @@ public class BytecodeViewer
}); });
t.start(); t.start();
} else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { } else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
last = System.currentTimeMillis(); Configuration.lastHotKeyExecuted = System.currentTimeMillis();
if (viewer.workPane.getCurrentViewer() != null) if (viewer.workPane.getCurrentViewer() != null)
viewer.workPane.tabs.remove(viewer.workPane.getCurrentViewer()); viewer.workPane.tabs.remove(viewer.workPane.getCurrentViewer());
} }
@ -819,13 +795,13 @@ public class BytecodeViewer
File[] files = new File[2]; File[] files = new File[2];
//currently won't optimize if you've got two containers with the same name, will need to add this later //currently won't optimize if you've got two containers with the same name, will need to add this later
if (!LazyNameUtil.SAME_NAME_JAR_WORKSPACE) { if (!LazyNameUtil.SAME_NAME_JAR_WORKSPACE) {
if (krakatauTempJar != null && !krakatauTempJar.exists()) { if (Configuration.krakatauTempJar != null && !Configuration.krakatauTempJar.exists()) {
needsReDump = true; Configuration.needsReDump = true;
} }
if (needsReDump && krakatauTempJar != null) { if (Configuration.needsReDump && Configuration.krakatauTempJar != null) {
krakatauTempDir = null; Configuration.krakatauTempDir = null;
krakatauTempJar = null; Configuration.krakatauTempJar = null;
} }
boolean passes = false; boolean passes = false;
@ -843,54 +819,42 @@ public class BytecodeViewer
else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel())) else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel()))
passes = true; passes = true;
if (krakatauTempJar != null || !passes) { if (Configuration.krakatauTempJar != null || !passes) {
files[0] = krakatauTempJar; files[0] = Configuration.krakatauTempJar;
files[1] = krakatauTempDir; files[1] = Configuration.krakatauTempDir;
return files; return files;
} }
} }
currentlyDumping = true; Configuration.currentlyDumping = true;
needsReDump = false; Configuration.needsReDump = false;
krakatauTempDir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs); Configuration.krakatauTempDir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs);
krakatauTempDir.mkdir(); Configuration.krakatauTempDir.mkdir();
krakatauTempJar = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); Configuration.krakatauTempJar = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
//krakatauTempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils //krakatauTempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils
// .randomString(32) + ".jar."+container.name); // .randomString(32) + ".jar."+container.name);
JarUtils.saveAsJarClassesOnly(container.classes, krakatauTempJar.getAbsolutePath()); JarUtils.saveAsJarClassesOnly(container.classes, Configuration.krakatauTempJar.getAbsolutePath());
currentlyDumping = false; Configuration.currentlyDumping = false;
files[0] = krakatauTempJar; files[0] = Configuration.krakatauTempJar;
files[1] = krakatauTempDir; files[1] = Configuration.krakatauTempDir;
return files; return files;
} }
public synchronized static void rtCheck() { public synchronized static void rtCheck() {
if (rt.equals("")) { if (Configuration.rt.isEmpty()) {
if (RT_JAR.exists()) { if (RT_JAR.exists()) {
rt = RT_JAR.getAbsolutePath(); Configuration.rt = RT_JAR.getAbsolutePath();
} else if (RT_JAR_DUMPED.exists()) { } else if (RT_JAR_DUMPED.exists()) {
rt = RT_JAR_DUMPED.getAbsolutePath(); Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
} else { } else {
try { try {
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath()); JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
rt = RT_JAR_DUMPED.getAbsolutePath(); Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
} }
} }
} }
public static int fileContainersHash(ArrayList<FileContainer> fileContainers) {
StringBuilder block = new StringBuilder();
for (FileContainer container : fileContainers) {
block.append(container.name);
for (ClassNode node : container.classes) {
block.append(node.name);
}
}
return block.hashCode();
}
} }

View file

@ -327,7 +327,7 @@ public class CommandLineInput {
System.out.println("Finished."); System.out.println("Finished.");
System.out.println("Bytecode Viewer CLI v" + VERSION + " by @Konloch - " System.out.println("Bytecode Viewer CLI v" + VERSION + " by @Konloch - "
+ "https://bytecodeviewer.com"); + "https://bytecodeviewer.com");
BytecodeViewer.canExit = true; Configuration.canExit = true;
System.exit(0); System.exit(0);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);

View file

@ -0,0 +1,31 @@
package the.bytecode.club.bytecodeviewer;
import java.io.File;
/**
* @author Konloch
* @since 6/21/2021
*/
public class Configuration
{
public static String python = "";
public static String python3 = "";
public static String rt = "";
public static String library = "";
public static String javac = "";
public static String java = "";
public static File krakatauTempDir;
public static File krakatauTempJar;
public static boolean displayParentInTab = false; //also change in the main GUI
public static boolean currentlyDumping = false;
public static boolean needsReDump = true;
public static boolean warnForEditing = false;
public static boolean runningObfuscation = false;
public static final long start = System.currentTimeMillis();
public static String lastDirectory = ".";
public static boolean pingback = false;
public static boolean deleteForeignLibraries = true;
public static boolean canExit = false;
public static long lastHotKeyExecuted = System.currentTimeMillis();
}

View file

@ -281,11 +281,11 @@ public class Settings {
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
"deprecated", false); "deprecated", false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.lastDirectory, false); Configuration.lastDirectory, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.python, false); Configuration.python, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.rt, false); Configuration.rt, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.panel1Proc_E.isSelected()), false); String.valueOf(BytecodeViewer.viewer.panel1Proc_E.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
@ -319,9 +319,9 @@ public class Settings {
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false); String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.library, false); Configuration.library, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.pingback), false); String.valueOf(Configuration.pingback), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.panel1JDGUI_E.isSelected()), false); String.valueOf(BytecodeViewer.viewer.panel1JDGUI_E.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
@ -331,7 +331,7 @@ public class Settings {
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.fontSpinner.getValue()), false); String.valueOf(BytecodeViewer.viewer.fontSpinner.getValue()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.deleteForeignLibraries), false); String.valueOf(Configuration.deleteForeignLibraries), false);
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
DiskWriter.writeNewLine(settingsName, "0", false); DiskWriter.writeNewLine(settingsName, "0", false);
@ -339,17 +339,17 @@ public class Settings {
DiskWriter.writeNewLine(settingsName, "1", false); DiskWriter.writeNewLine(settingsName, "1", false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.python3, false); Configuration.python3, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.javac, false); Configuration.javac, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
BytecodeViewer.java, false); Configuration.java, false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.compileOnSave.isSelected()), false); String.valueOf(BytecodeViewer.viewer.compileOnSave.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false); String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.warnForEditing), false); String.valueOf(Configuration.warnForEditing), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
String.valueOf(BytecodeViewer.viewer.showFileInTabTitle.isSelected()), false); String.valueOf(BytecodeViewer.viewer.showFileInTabTitle.isSelected()), false);
DiskWriter.writeNewLine(settingsName, DiskWriter.writeNewLine(settingsName,
@ -534,9 +534,9 @@ public class Settings {
} }
//86 is deprecated //86 is deprecated
//87 is deprecated //87 is deprecated
BytecodeViewer.lastDirectory = DiskReader.loadString(settingsName, 88, false); Configuration.lastDirectory = DiskReader.loadString(settingsName, 88, false);
BytecodeViewer.python = DiskReader.loadString(settingsName, 89, false); Configuration.python = DiskReader.loadString(settingsName, 89, false);
BytecodeViewer.rt = DiskReader.loadString(settingsName, 90, false); Configuration.rt = DiskReader.loadString(settingsName, 90, false);
BytecodeViewer.viewer.panel1Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 91, false))); BytecodeViewer.viewer.panel1Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 91, false)));
BytecodeViewer.viewer.panel1CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 92, false))); BytecodeViewer.viewer.panel1CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 92, false)));
BytecodeViewer.viewer.panel1Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 93, false))); BytecodeViewer.viewer.panel1Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 93, false)));
@ -553,13 +553,13 @@ public class Settings {
BytecodeViewer.viewer.panel3Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 104, false))); BytecodeViewer.viewer.panel3Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 104, false)));
BytecodeViewer.viewer.panel3Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 105, false))); BytecodeViewer.viewer.panel3Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 105, false)));
BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 106, false))); BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 106, false)));
BytecodeViewer.library = DiskReader.loadString(settingsName, 107, false); Configuration.library = DiskReader.loadString(settingsName, 107, false);
BytecodeViewer.pingback = Boolean.parseBoolean(DiskReader.loadString(settingsName, 108, false)); Configuration.pingback = Boolean.parseBoolean(DiskReader.loadString(settingsName, 108, false));
BytecodeViewer.viewer.panel1JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 109, false))); BytecodeViewer.viewer.panel1JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 109, false)));
BytecodeViewer.viewer.panel2JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 110, false))); BytecodeViewer.viewer.panel2JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 110, false)));
BytecodeViewer.viewer.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 111, false))); BytecodeViewer.viewer.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 111, false)));
BytecodeViewer.viewer.fontSpinner.setValue(Integer.parseInt(DiskReader.loadString(settingsName, 112, false))); BytecodeViewer.viewer.fontSpinner.setValue(Integer.parseInt(DiskReader.loadString(settingsName, 112, false)));
BytecodeViewer.deleteForeignLibraries = Boolean.parseBoolean(DiskReader.loadString(settingsName, 113, false)); Configuration.deleteForeignLibraries = Boolean.parseBoolean(DiskReader.loadString(settingsName, 113, false));
decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 114, false)); decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 114, false));
if (decompiler == 0) if (decompiler == 0)
@ -567,14 +567,14 @@ public class Settings {
else if (decompiler == 1) else if (decompiler == 1)
BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel(), true); BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel(), true);
BytecodeViewer.python3 = DiskReader.loadString(settingsName, 115, false); Configuration.python3 = DiskReader.loadString(settingsName, 115, false);
BytecodeViewer.javac = DiskReader.loadString(settingsName, 116, false); Configuration.javac = DiskReader.loadString(settingsName, 116, false);
BytecodeViewer.java = DiskReader.loadString(settingsName, 117, false); Configuration.java = DiskReader.loadString(settingsName, 117, false);
BytecodeViewer.viewer.compileOnSave.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 118, false))); BytecodeViewer.viewer.compileOnSave.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 118, false)));
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 119, false))); BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 119, false)));
BytecodeViewer.warnForEditing = Boolean.parseBoolean(DiskReader.loadString(settingsName, 120, false)); Configuration.warnForEditing = Boolean.parseBoolean(DiskReader.loadString(settingsName, 120, false));
BytecodeViewer.viewer.showFileInTabTitle.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 121, false))); BytecodeViewer.viewer.showFileInTabTitle.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 121, false)));
BytecodeViewer.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected(); Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
BytecodeViewer.viewer.forcePureAsciiAsText.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 122, false))); BytecodeViewer.viewer.forcePureAsciiAsText.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 122, false)));
BytecodeViewer.viewer.synchronizedViewing.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 123, false))); BytecodeViewer.viewer.synchronizedViewing.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 123, false)));
BytecodeViewer.viewer.showClassMethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 124, false))); BytecodeViewer.viewer.showClassMethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 124, false)));

View file

@ -7,6 +7,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import me.konloch.kontainer.io.DiskWriter; 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.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -50,12 +51,12 @@ public class JavaCompiler extends Compiler {
tempD.mkdirs(); tempD.mkdirs();
new File(fileStart2).mkdirs(); new File(fileStart2).mkdirs();
if (BytecodeViewer.javac.equals("") || !new File(BytecodeViewer.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:/programfiles/Java/JDK_xx/bin/javac.exe)");
BytecodeViewer.viewer.javac(); BytecodeViewer.viewer.javac();
} }
if (BytecodeViewer.javac.equals("") || !new File(BytecodeViewer.javac).exists()) { if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists()) {
BytecodeViewer.showMessage("You need to set Javac!"); BytecodeViewer.showMessage("You need to set Javac!");
return null; return null;
} }
@ -69,19 +70,19 @@ public class JavaCompiler extends Compiler {
StringBuilder log = new StringBuilder(); StringBuilder log = new StringBuilder();
ProcessBuilder pb; ProcessBuilder pb;
if (BytecodeViewer.library.isEmpty()) { if (Configuration.library.isEmpty()) {
pb = new ProcessBuilder( pb = new ProcessBuilder(
BytecodeViewer.javac, Configuration.javac,
"-d", fileStart2, "-d", fileStart2,
"-classpath", cp.getAbsolutePath(), "-classpath", cp.getAbsolutePath(),
java.getAbsolutePath() java.getAbsolutePath()
); );
} else { } else {
pb = new ProcessBuilder( pb = new ProcessBuilder(
BytecodeViewer.javac, Configuration.javac,
"-d", fileStart2, "-d", fileStart2,
"-classpath", "-classpath",
cp.getAbsolutePath() + System.getProperty("path.separator") + BytecodeViewer.library, cp.getAbsolutePath() + System.getProperty("path.separator") + Configuration.library,
java.getAbsolutePath() java.getAbsolutePath()
); );
} }

View file

@ -6,6 +6,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import me.konloch.kontainer.io.DiskWriter; 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.Constants; import the.bytecode.club.bytecodeviewer.Constants;
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;
@ -39,12 +40,12 @@ public class KrakatauAssembler extends Compiler {
@Override @Override
public byte[] compile(String contents, String name) { public byte[] compile(String contents, String name) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
if (BytecodeViewer.python.equals("")) { if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return null; return null;
} }
@ -68,7 +69,7 @@ public class KrakatauAssembler extends Compiler {
StringBuilder log = new StringBuilder(); StringBuilder log = new StringBuilder();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "assemble.py", krakatauWorkingDirectory + fs + "assemble.py",
"-out", "-out",

View file

@ -9,6 +9,7 @@ import java.io.StringWriter;
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.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
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;
@ -42,31 +43,31 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
public class KrakatauDecompiler extends Decompiler { public class KrakatauDecompiler extends Decompiler {
public String quick() { public String quick() {
if (BytecodeViewer.library.isEmpty()) if (Configuration.library.isEmpty())
return ""; return "";
else else
return ";" + BytecodeViewer.library; return ";" + Configuration.library;
} }
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) { public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
BytecodeViewer.rtCheck(); BytecodeViewer.rtCheck();
if (BytecodeViewer.rt.equals("")) { 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.rtC(); BytecodeViewer.viewer.rtC();
} }
if (BytecodeViewer.python.equals("")) { if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
if (BytecodeViewer.rt.equals("")) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set RT.jar!"); BytecodeViewer.showMessage("You need to set RT.jar!");
return "Set your paths"; return "Set your paths";
} }
@ -77,13 +78,13 @@ public class KrakatauDecompiler extends Decompiler {
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-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
"-nauto", "-nauto",
"-path", "-path",
BytecodeViewer.rt + ";" + krakatauTempJar.getAbsolutePath() + quick(), Configuration.rt + ";" + krakatauTempJar.getAbsolutePath() + quick(),
"-out", "-out",
krakatauTempDir.getAbsolutePath(), krakatauTempDir.getAbsolutePath(),
cn.name + ".class" cn.name + ".class"
@ -132,22 +133,22 @@ public class KrakatauDecompiler extends Decompiler {
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] b) { public String decompileClassNode(ClassNode cn, byte[] b) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
if (BytecodeViewer.rt.equals("")) { 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." +
+ "\\Java\\jre7\\lib\\rt.jar)"); "\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.rtC(); BytecodeViewer.viewer.rtC();
} }
if (BytecodeViewer.python.equals("")) { if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
if (BytecodeViewer.rt.equals("")) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set RT.jar!"); BytecodeViewer.showMessage("You need to set RT.jar!");
return "Set your paths"; return "Set your paths";
} }
@ -165,13 +166,13 @@ public class KrakatauDecompiler extends Decompiler {
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-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
"-nauto", "-nauto",
"-path", "-path",
BytecodeViewer.rt + ";" + tempJar.getAbsolutePath() + quick(), Configuration.rt + ";" + tempJar.getAbsolutePath() + quick(),
"-out", "-out",
tempDirectory.getAbsolutePath(), tempDirectory.getAbsolutePath(),
cn.name + ".class" cn.name + ".class"
@ -223,14 +224,14 @@ public class KrakatauDecompiler extends Decompiler {
@Override @Override
public void decompileToZip(String sourceJar, String zipName) { public void decompileToZip(String sourceJar, String zipName) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
BytecodeViewer.rtCheck(); BytecodeViewer.rtCheck();
if (BytecodeViewer.rt.equals("")) { 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." +
+ "\\Java\\jre7\\lib\\rt.jar)"); "\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
BytecodeViewer.viewer.rtC(); BytecodeViewer.viewer.rtC();
} }
@ -245,13 +246,13 @@ public class KrakatauDecompiler extends Decompiler {
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-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
"-nauto", "-nauto",
"-path", "-path",
BytecodeViewer.rt + ";" + tempJar.getAbsolutePath(), Configuration.rt + ";" + tempJar.getAbsolutePath(),
"-out", "-out",
tempDirectory.getAbsolutePath(), tempDirectory.getAbsolutePath(),
tempJar.getAbsolutePath() tempJar.getAbsolutePath()

View file

@ -9,6 +9,7 @@ import java.io.StringWriter;
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.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
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;
@ -43,12 +44,12 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
public class KrakatauDisassembler extends Decompiler { public class KrakatauDisassembler extends Decompiler {
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) { public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
if (BytecodeViewer.python.equals("")) { if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -59,7 +60,7 @@ public class KrakatauDisassembler extends Decompiler {
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-path",
@ -112,12 +113,12 @@ public class KrakatauDisassembler extends Decompiler {
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] b) { public String decompileClassNode(ClassNode cn, byte[] b) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
if (BytecodeViewer.python.equals("")) { if (Configuration.python.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths"; return "Set your paths";
} }
@ -133,7 +134,7 @@ public class KrakatauDisassembler extends Decompiler {
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-path",
@ -185,7 +186,7 @@ public class KrakatauDisassembler extends Decompiler {
@Override @Override
public void decompileToZip(String sourceJar, String zipName) { public void decompileToZip(String sourceJar, String zipName) {
if (BytecodeViewer.python.equals("")) { if (Configuration.python.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.pythonC(); BytecodeViewer.viewer.pythonC();
} }
@ -199,11 +200,11 @@ public class KrakatauDisassembler extends Decompiler {
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, Configuration.python,
"-O", //love you storyyeller <3 "-O", //love you storyyeller <3
krakatauWorkingDirectory + fs + "disassemble.py", krakatauWorkingDirectory + fs + "disassemble.py",
"-path", "-path",
BytecodeViewer.rt + ";" + tempJar.getAbsolutePath(), Configuration.rt + ";" + tempJar.getAbsolutePath(),
"-out", "-out",
tempDirectory.getAbsolutePath(), tempDirectory.getAbsolutePath(),
tempJar.getAbsolutePath() tempJar.getAbsolutePath()

View file

@ -152,7 +152,7 @@ public class InstructionPrinter {
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " " line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
+ ain; + ain;
} }
if (!line.equals("")) { if (!line.isEmpty()) {
if (match) if (match)
if (matchedInsns.contains(ain)) if (matchedInsns.contains(ain))
line = " -> " + line; line = " -> " + line;

View file

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

View file

@ -47,6 +47,7 @@ import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
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.Configuration;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.Settings; import the.bytecode.club.bytecodeviewer.Settings;
import the.bytecode.club.bytecodeviewer.decompilers.Decompilers; import the.bytecode.club.bytecodeviewer.decompilers.Decompilers;
@ -1620,7 +1621,7 @@ public class ClassViewer extends Viewer {
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
while (BytecodeViewer.currentlyDumping) { while (Configuration.currentlyDumping) {
//wait until it's not dumping //wait until it's not dumping
try { try {
Thread.sleep(100); Thread.sleep(100);
@ -1642,8 +1643,8 @@ public class ClassViewer extends Viewer {
t.start(); t.start();
if (isPanel1Editable() || isPanel2Editable() || isPanel3Editable()) { if (isPanel1Editable() || isPanel2Editable() || isPanel3Editable()) {
if (!BytecodeViewer.warnForEditing) { if (!Configuration.warnForEditing) {
BytecodeViewer.warnForEditing = true; Configuration.warnForEditing = true;
if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected() && !BytecodeViewer.viewer.compileOnSave.isSelected()) { if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected() && !BytecodeViewer.viewer.compileOnSave.isSelected()) {
BytecodeViewer.showMessage("Make sure to compile (File>Compile or Ctrl + T) whenever you want to " BytecodeViewer.showMessage("Make sure to compile (File>Compile or Ctrl + T) whenever you want to "
+ "test or export your changes.\nYou can set compile automatically on refresh or on save " + "test or export your changes.\nYou can set compile automatically on refresh or on save "

View file

@ -35,6 +35,7 @@ import me.konloch.kontainer.io.DiskWriter;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
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.Configuration;
import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Resources;
import the.bytecode.club.bytecodeviewer.Settings; import the.bytecode.club.bytecodeviewer.Settings;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
@ -412,14 +413,13 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public final JRadioButtonMenuItem asmText3 = new JRadioButtonMenuItem("ASM Textify"); public final JRadioButtonMenuItem asmText3 = new JRadioButtonMenuItem("ASM Textify");
public final JSpinner fontSpinner = new JSpinner(); public final JSpinner fontSpinner = new JSpinner();
private final JCheckBoxMenuItem chckbxmntmDeleteForeignOutdatedLibs = new JCheckBoxMenuItem("Delete " private final JCheckBoxMenuItem chckbxmntmDeleteForeignOutdatedLibs = new JCheckBoxMenuItem("Delete Foreign/Outdated Libs");
+ "Foreign/Outdated Libs");
public final ButtonGroup apkConversionGroup = new ButtonGroup(); public final ButtonGroup apkConversionGroup = new ButtonGroup();
public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar"); public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar");
public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify"); public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify");
public void calledAfterLoad() { public void calledAfterLoad() {
chckbxmntmDeleteForeignOutdatedLibs.setSelected(BytecodeViewer.deleteForeignLibraries); chckbxmntmDeleteForeignOutdatedLibs.setSelected(Configuration.deleteForeignLibraries);
} }
public MainViewerGUI() { public MainViewerGUI() {
@ -463,7 +463,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
BytecodeViewer.canExit = true; Configuration.canExit = true;
System.exit(0); System.exit(0);
} }
}); });
@ -483,7 +483,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
final JFileChooser fc = new JFileChooser(); final JFileChooser fc = new JFileChooser();
try { try {
File f = new File(BytecodeViewer.lastDirectory); File f = new File(Configuration.lastDirectory);
if (f.exists()) if (f.exists())
fc.setSelectedFile(f); fc.setSelectedFile(f);
} catch (Exception ignored) { } catch (Exception ignored) {
@ -515,7 +515,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer); int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION) { if (returnVal == JFileChooser.APPROVE_OPTION) {
BytecodeViewer.lastDirectory = fc.getSelectedFile().getAbsolutePath(); Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath();
try { try {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true); BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true);
@ -1345,7 +1345,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
result = k; result = k;
if (result == 0) { if (result == 0) {
BytecodeViewer.canExit = true; Configuration.canExit = true;
System.exit(0); System.exit(0);
} }
}); });
@ -1410,22 +1410,21 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
panel1Fern.addActionListener(listener); panel1Fern.addActionListener(listener);
mnFernflower.add(separator_20); mnFernflower.add(separator_20);
mnFernflower.add(panel1Fern_E); mnFernflower.add(panel1Fern_E);
mnNewMenu_7.add(mnKrakatau); mnNewMenu_7.add(mnKrakatau);
mnKrakatau.add(panel1Krakatau); mnKrakatau.add(panel1Krakatau);
panel1Krakatau.addActionListener(listener); panel1Krakatau.addActionListener(listener);
mnKrakatau.add(panel1KrakatauBytecode); mnKrakatau.add(panel1KrakatauBytecode);
panel1KrakatauBytecode.addActionListener(listener); panel1KrakatauBytecode.addActionListener(listener);
mnKrakatau.add(separator_21); mnKrakatau.add(separator_21);
mnKrakatau.add(panel1Krakatau_E); mnKrakatau.add(panel1Krakatau_E);
mnNewMenu_7.add(separator_8); mnNewMenu_7.add(separator_8);
mnNewMenu_7.add(mnSmalidex); mnNewMenu_7.add(mnSmalidex);
mnSmalidex.add(panel1Smali); mnSmalidex.add(panel1Smali);
panel1Smali.addActionListener(listener); panel1Smali.addActionListener(listener);
@ -1435,35 +1434,25 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
panel1Bytecode.addActionListener(listener); panel1Bytecode.addActionListener(listener);
mnNewMenu_7.add(separator_15); mnNewMenu_7.add(separator_15);
mnNewMenu_7.add(panel1Bytecode); mnNewMenu_7.add(panel1Bytecode);
mnNewMenu_7.add(panel1Hexcode); mnNewMenu_7.add(panel1Hexcode);
mnNewMenu_7.add(asmText1); mnNewMenu_7.add(asmText1);
mnNewMenu_6.add(mnPane); mnNewMenu_6.add(mnPane);
mnPane.add(panel2None); mnPane.add(panel2None);
mnPane.add(separator_9); mnPane.add(separator_9);
mnPane.add(menu_1); mnPane.add(menu_1);
menu_1.add(panel2Proc); menu_1.add(panel2Proc);
menu_1.add(separator_10); menu_1.add(separator_10);
menu_1.add(panel2Proc_E); menu_1.add(panel2Proc_E);
mnPane.add(menu_2); mnPane.add(menu_2);
mnPane.add(jadx2); mnPane.add(jadx2);
menu_2.add(panel2CFR); menu_2.add(panel2CFR);
menu_2.add(separator_11); menu_2.add(separator_11);
menu_2.add(panel2CFR_E); menu_2.add(panel2CFR_E);
JMenu menu = new JMenu("JD-GUI"); JMenu menu = new JMenu("JD-GUI");
@ -1471,45 +1460,32 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
menu.add(panel2JDGUI); menu.add(panel2JDGUI);
JSeparator separator_34 = new JSeparator(); menu.add(new JSeparator());
menu.add(separator_34);
menu.add(panel2JDGUI_E); menu.add(panel2JDGUI_E);
mnPane.add(menu_3); mnPane.add(menu_3);
menu_3.add(panel2Fern); menu_3.add(panel2Fern);
menu_3.add(separator_12); menu_3.add(separator_12);
menu_3.add(panel2Fern_E); menu_3.add(panel2Fern_E);
mnPane.add(menu_4); mnPane.add(menu_4);
menu_4.add(panel2Krakatau); menu_4.add(panel2Krakatau);
menu_4.add(panel2KrakatauBytecode); menu_4.add(panel2KrakatauBytecode);
menu_4.add(separator_16); menu_4.add(separator_16);
menu_4.add(panel2Krakatau_E); menu_4.add(panel2Krakatau_E);
mnPane.add(separator_17); mnPane.add(separator_17);
mnPane.add(menu_5); mnPane.add(menu_5);
menu_5.add(panel2Smali); menu_5.add(panel2Smali);
menu_5.add(separator_23); menu_5.add(separator_23);
menu_5.add(panel2Smali_E); menu_5.add(panel2Smali_E);
mnPane.add(separator_24); mnPane.add(separator_24);
mnPane.add(panel2Bytecode); mnPane.add(panel2Bytecode);
mnPane.add(panel2Hexcode); mnPane.add(panel2Hexcode);
mnPane.add(asmText2); mnPane.add(asmText2);
mnNewMenu_6.add(mnPane_1); mnNewMenu_6.add(mnPane_1);
@ -1622,7 +1598,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
BytecodeViewer.showMessage("WARNING: With this being toggled off outdated libraries will NOT be " BytecodeViewer.showMessage("WARNING: With this being toggled off outdated libraries will NOT be "
+ "removed. It's also a security issue. ONLY TURN IT OFF IF YOU KNOW WHAT YOU'RE DOING."); + "removed. It's also a security issue. ONLY TURN IT OFF IF YOU KNOW WHAT YOU'RE DOING.");
} }
BytecodeViewer.deleteForeignLibraries = chckbxmntmDeleteForeignOutdatedLibs.isSelected(); Configuration.deleteForeignLibraries = chckbxmntmDeleteForeignOutdatedLibs.isSelected();
}); });
mnSettings.add(forcePureAsciiAsText); mnSettings.add(forcePureAsciiAsText);
forcePureAsciiAsText.setSelected(true); forcePureAsciiAsText.setSelected(true);
@ -1874,9 +1850,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
menuBar.add(mnNewMenu_5); menuBar.add(mnNewMenu_5);
mntmNewMenuItem_6.addActionListener(arg0 -> { mntmNewMenuItem_6.addActionListener(arg0 -> {
if (BytecodeViewer.runningObfuscation) { if (Configuration.runningObfuscation) {
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
+ ".");
return; return;
} }
new RenameFields().start(); new RenameFields().start();
@ -1895,7 +1870,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnNewMenu_5.add(mntmNewMenuItem_6); mnNewMenu_5.add(mntmNewMenuItem_6);
mntmNewMenuItem_7.addActionListener(arg0 -> { mntmNewMenuItem_7.addActionListener(arg0 -> {
if (BytecodeViewer.runningObfuscation) { if (Configuration.runningObfuscation) {
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish"
+ "."); + ".");
return; return;
@ -1907,7 +1882,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnNewMenu_5.add(mntmNewMenuItem_7); mnNewMenu_5.add(mntmNewMenuItem_7);
mntmNewMenuItem_11.addActionListener(arg0 -> { mntmNewMenuItem_11.addActionListener(arg0 -> {
if (BytecodeViewer.runningObfuscation) { if (Configuration.runningObfuscation) {
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish"
+ "."); + ".");
return; return;
@ -1919,10 +1894,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnNewMenu_5.add(mntmNewMenuItem_11); mnNewMenu_5.add(mntmNewMenuItem_11);
mntmNewMenuItem_9.setEnabled(false); mntmNewMenuItem_9.setEnabled(false);
mnNewMenu_5.add(mntmNewMenuItem_9); mnNewMenu_5.add(mntmNewMenuItem_9);
mntmNewMenuItem_10.setEnabled(false); mntmNewMenuItem_10.setEnabled(false);
mnNewMenu_5.add(mntmNewMenuItem_10); mnNewMenu_5.add(mntmNewMenuItem_10);
menuBar.add(mnNewMenu_1); menuBar.add(mnNewMenu_1);
@ -1957,7 +1930,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
//mnNewMenu_1.add(mntmStartZkmString); //mnNewMenu_1.add(mntmStartZkmString);
mntmZstringarrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter())); mntmZstringarrayDecrypter.addActionListener(arg0 -> PluginManager.runPlugin(new ZStringArrayDecrypter()));
mntmStackFramesRemover.addActionListener(e -> PluginManager.runPlugin(new StackFramesRemover())); mntmStackFramesRemover.addActionListener(e -> PluginManager.runPlugin(new StackFramesRemover()));
mnNewMenu_1.add(mntmZstringarrayDecrypter); mnNewMenu_1.add(mntmZstringarrayDecrypter);
@ -1997,19 +1969,15 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
new MaliciousCodeScannerOptions().setVisible(true); new MaliciousCodeScannerOptions().setVisible(true);
}); });
mntmShowAllStrings.addActionListener(e -> PluginManager.runPlugin(new ShowAllStrings())); mntmShowAllStrings.addActionListener(e -> PluginManager.runPlugin(new ShowAllStrings()));
mntmShowMainMethods.addActionListener(e -> PluginManager.runPlugin(new ShowMainMethods())); mntmShowMainMethods.addActionListener(e -> PluginManager.runPlugin(new ShowMainMethods()));
setSize(new Dimension(800, 400)); setSize(new Dimension(800, 400));
if (PREVIEW_COPY) if (PREVIEW_COPY)
setTitle("Bytecode Viewer " + VERSION + " Preview - https://bytecodeviewer.com | " setTitle("Bytecode Viewer " + VERSION + " Preview - https://bytecodeviewer.com | https://the.bytecode.club - @Konloch");
+ "https://the.bytecode.club - @Konloch");
else else
setTitle("Bytecode Viewer " + VERSION + " - https://bytecodeviewer.com | https://the" setTitle("Bytecode Viewer " + VERSION + " - https://bytecodeviewer.com | https://the.bytecode.club - @Konloch");
+ ".bytecode.club - @Konloch");
getContentPane().setLayout( getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
// scrollPane.setViewportView(tree); // scrollPane.setViewportView(tree);
cn.setMinimumSize(new Dimension(200, 50)); cn.setMinimumSize(new Dimension(200, 50));
@ -2087,7 +2055,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
visualSettings.add(showFileInTabTitle); visualSettings.add(showFileInTabTitle);
showFileInTabTitle.setSelected(false); showFileInTabTitle.setSelected(false);
showFileInTabTitle.addActionListener(arg0 -> { showFileInTabTitle.addActionListener(arg0 -> {
BytecodeViewer.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected(); Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
Settings.saveSettings(); Settings.saveSettings();
}); });
@ -2146,7 +2114,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.python = fc.getSelectedFile().getAbsolutePath(); Configuration.python = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }
@ -2171,7 +2139,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.javac = fc.getSelectedFile().getAbsolutePath(); Configuration.javac = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }
@ -2196,7 +2164,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.java = fc.getSelectedFile().getAbsolutePath(); Configuration.java = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }
@ -2221,7 +2189,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.python3 = fc.getSelectedFile().getAbsolutePath(); Configuration.python3 = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }
@ -2247,7 +2215,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.library = fc.getSelectedFile().getAbsolutePath(); Configuration.library = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }
@ -2273,7 +2241,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (returnVal == JFileChooser.APPROVE_OPTION) if (returnVal == JFileChooser.APPROVE_OPTION)
try { try {
BytecodeViewer.rt = fc.getSelectedFile().getAbsolutePath(); Configuration.rt = fc.getSelectedFile().getAbsolutePath();
} catch (Exception e1) { } catch (Exception e1) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
} }

View file

@ -19,6 +19,7 @@ import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
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.Configuration;
import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier;
import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.FileContainer;
@ -204,7 +205,7 @@ public class WorkPane extends VisibleComponent implements ActionListener {
String workingName = container.name + ">" + name; String workingName = container.name + ">" + name;
String containerName = name; String containerName = name;
if (BytecodeViewer.displayParentInTab) if (Configuration.displayParentInTab)
containerName = container.name + ">" + name; containerName = container.name + ">" + name;
if (!workingOn.containsKey(workingName)) { if (!workingOn.containsKey(workingName)) {
@ -224,7 +225,7 @@ public class WorkPane extends VisibleComponent implements ActionListener {
public void addFile(final FileContainer container, String name, byte[] contents) { public void addFile(final FileContainer container, String name, byte[] contents) {
String workingName = container.name + ">" + name; String workingName = container.name + ">" + name;
if (BytecodeViewer.displayParentInTab) if (Configuration.displayParentInTab)
name = container.name + ">" + name; name = container.name + ">" + name;
if (contents == null) //a directory if (contents == null) //a directory

View file

@ -2,6 +2,7 @@ package the.bytecode.club.bytecodeviewer.obfuscators;
import java.util.ArrayList; import java.util.ArrayList;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
/*************************************************************************** /***************************************************************************
@ -33,16 +34,15 @@ public abstract class JavaObfuscator extends Thread {
@Override @Override
public void run() { public void run() {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
BytecodeViewer.runningObfuscation = true; Configuration.runningObfuscation = true;
obfuscate(); obfuscate();
BytecodeViewer.refactorer.run(); BytecodeViewer.refactorer.run();
BytecodeViewer.runningObfuscation = false; Configuration.runningObfuscation = false;
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} }
public int getStringLength() { public int getStringLength() {
if (BytecodeViewer.viewer.obfuscatorGroup if (BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.strongObf.getModel())) {
.isSelected(BytecodeViewer.viewer.strongObf.getModel())) {
return MAX_STRING_LENGTH; return MAX_STRING_LENGTH;
} else { // if(BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.lightObf.getModel())) } else { // if(BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.lightObf.getModel()))
// { // {

View file

@ -2,6 +2,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 static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory; import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory;
@ -38,12 +39,12 @@ public class Enjarify {
* @param output the output .jar file * @param output the output .jar file
*/ */
public static synchronized void apk2Jar(File input, File output) { public static synchronized void apk2Jar(File input, File output) {
if (BytecodeViewer.python3.equals("")) { 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.pythonC3(); BytecodeViewer.viewer.pythonC3();
} }
if (BytecodeViewer.python3.equals("")) { if (Configuration.python3.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!"); BytecodeViewer.showMessage("You need to set Python!");
return; return;
} }
@ -51,7 +52,7 @@ public class Enjarify {
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python3, Configuration.python3,
"-O", "-O",
"-m", "-m",
"enjarify.main", "enjarify.main",

View file

@ -1,5 +1,7 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import org.objectweb.asm.tree.ClassNode;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@ -158,6 +160,18 @@ public class MiscUtils {
return path; return path;
} }
public static int fileContainersHash(ArrayList<FileContainer> fileContainers) {
StringBuilder block = new StringBuilder();
for (FileContainer container : fileContainers) {
block.append(container.name);
for (ClassNode node : container.classes) {
block.append(node.name);
}
}
return block.hashCode();
}
/** /**
* Converts an array list to a string * Converts an array list to a string
* *
@ -167,6 +181,7 @@ public class MiscUtils {
public static String listToString(List<String> a) { public static String listToString(List<String> a) {
return gson.toJson(a); return gson.toJson(a);
} }
/** /**
* @author JoshTheWolfe * @author JoshTheWolfe
*/ */

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.net.InetAddress; import java.net.InetAddress;
@ -126,7 +126,7 @@ public class SecurityMan extends SecurityManager {
@Override @Override
public void checkExit(int status) { public void checkExit(int status) {
if (!BytecodeViewer.canExit) { if (!Configuration.canExit) {
throw new SecurityException("BCV is awesome, blocking System.exit(" + status + ");"); throw new SecurityException("BCV is awesome, blocking System.exit(" + status + ");");
} }
} }

View file

@ -201,7 +201,7 @@ public final class ZipUtils {
File folder = new File(srcFolder); File folder = new File(srcFolder);
for (String fileName : Objects.requireNonNull(folder.list())) { for (String fileName : Objects.requireNonNull(folder.list())) {
if (path.equals("")) { if (path.isEmpty()) {
addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip, ignore); addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip, ignore);
} else { } else {
addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip, ignore); addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip, ignore);
@ -213,7 +213,7 @@ public final class ZipUtils {
File folder = new File(srcFolder); File folder = new File(srcFolder);
for (String fileName : Objects.requireNonNull(folder.list())) { for (String fileName : Objects.requireNonNull(folder.list())) {
if (path.equals("")) { if (path.isEmpty()) {
addFileToZipAPKTool(folder.getName(), srcFolder + "/" + fileName, zip); addFileToZipAPKTool(folder.getName(), srcFolder + "/" + fileName, zip);
} else { } else {
addFileToZipAPKTool(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip); addFileToZipAPKTool(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip);