diff --git a/pom.xml b/pom.xml index 2a855af3..e27d3b87 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ club.bytecode.the bytecodeviewer - 2.10.0 + 2.10.10 8 diff --git a/src/main/java/the/bytecode/club/bootloader/Boot.java b/src/main/java/the/bytecode/club/bootloader/Boot.java index 60f0aac4..a6d01823 100644 --- a/src/main/java/the/bytecode/club/bootloader/Boot.java +++ b/src/main/java/the/bytecode/club/bootloader/Boot.java @@ -14,9 +14,12 @@ import org.apache.commons.io.FileUtils; import the.bytecode.club.bootloader.resource.EmptyExternalResource; import the.bytecode.club.bootloader.resource.ExternalResource; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.util.ZipUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -161,7 +164,7 @@ public class Boot { setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "..."); System.out.println("Verifying " + fileName + "..."); - File f = new File(BytecodeViewer.tempDirectory, "temp"); + File f = new File(Constants.tempDirectory, "temp"); if (!f.exists()) { f.getParentFile().mkdirs(); } @@ -181,7 +184,7 @@ public class Boot { setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "..."); System.out.println("Verifying " + fileName + "..."); - File f = new File(BytecodeViewer.tempDirectory, "temp"); + File f = new File(Constants.tempDirectory, "temp"); ZipUtils.zipFile(file, f); f.delete(); @@ -302,11 +305,9 @@ public class Boot { } public static void dropKrakatau() { - File temp = - new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion + ".zip"); - File krakatauDirectory = new File(BytecodeViewer.krakatauWorkingDirectory); - BytecodeViewer.krakatauWorkingDirectory = BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + - "Krakatau-master"; + File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip"); + File krakatauDirectory = new File(krakatauWorkingDirectory); + Constants.krakatauWorkingDirectory = krakatauWorkingDirectory + fs + "Krakatau-master"; if (!krakatauDirectory.exists() || temp.exists()) { if (temp.exists()) temp.delete(); @@ -318,8 +319,7 @@ public class Boot { while (temp.exists()) temp.delete(); - InputStream is = - BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + BytecodeViewer.krakatauVersion + ".zip"); + InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + Constants.krakatauVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp); int r; @@ -340,23 +340,22 @@ public class Boot { } public static void dropEnjarify() { - File temp = - new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify" + BytecodeViewer.enjarifyVersion + ".zip"); - File enjarifyDirectory = new File(BytecodeViewer.enjarifyWorkingDirectory); - BytecodeViewer.enjarifyWorkingDirectory = BytecodeViewer.enjarifyWorkingDirectory + BytecodeViewer.fs + - "enjarify-master"; + File temp = new File(getBCVDirectory() + fs + "enjarify" + Constants.enjarifyVersion + ".zip"); + File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory); + Constants.enjarifyWorkingDirectory = Constants.enjarifyWorkingDirectory + fs + "enjarify-master"; if (!enjarifyDirectory.exists() || temp.exists()) { if (temp.exists()) temp.delete(); + setState("Bytecode Viewer Boot Screen - Extracting Enjarify"); System.out.println("Extracting Enjarify"); + try { - while (temp.exists()) temp.delete(); InputStream is = - BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + BytecodeViewer.enjarifyVersion + ".zip"); + BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + Constants.enjarifyVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp); int r; @@ -432,7 +431,7 @@ public class Boot { setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "..."); System.out.println("Verifying " + fileName + "..."); - File f = new File(BytecodeViewer.tempDirectory, "temp"); + File f = new File(Constants.tempDirectory, "temp"); ZipUtils.zipFile(file, f); f.delete(); @@ -454,15 +453,15 @@ public class Boot { setState("Bytecode Viewer Boot Screen - Checking Enjarify..."); System.out.println("Checking enjarify"); File enjarifyZip = null; - for (File f : Objects.requireNonNull(new File(BytecodeViewer.libsDirectory).listFiles())) { + for (File f : Objects.requireNonNull(new File(Constants.libsDirectory).listFiles())) { if (f.getName().toLowerCase().startsWith("enjarify-")) { - BytecodeViewer.enjarifyVersion = f.getName().split("-")[1].split("\\.")[0]; + Constants.enjarifyVersion = f.getName().split("-")[1].split("\\.")[0]; enjarifyZip = f; } } - for (File f : Objects.requireNonNull(new File(BytecodeViewer.getBCVDirectory()).listFiles())) { - if (f.getName().toLowerCase().startsWith("enjarify_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.enjarifyVersion)) { + for (File f : Objects.requireNonNull(new File(getBCVDirectory()).listFiles())) { + if (f.getName().toLowerCase().startsWith("enjarify_") && !f.getName().split("_")[1].split("\\.")[0].equals(Constants.enjarifyVersion)) { setState("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "..."); System.out.println("Removing oudated " + f.getName()); try { @@ -472,20 +471,18 @@ public class Boot { } } } - - BytecodeViewer.enjarifyWorkingDirectory = - BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion + BytecodeViewer.fs + "enjarify-master"; - File enjarifyDirectory = - new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion); + + Constants.enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + Constants.enjarifyVersion + fs + "enjarify-master"; + File enjarifyDirectory = new File(getBCVDirectory() + fs + "enjarify_" + Constants.enjarifyVersion); if (!enjarifyDirectory.exists()) { try { setState("Bytecode Viewer Boot Screen - Updating to " + enjarifyDirectory.getName() + "..."); ZipUtils.unzipFilesToPath(Objects.requireNonNull(enjarifyZip).getAbsolutePath(), enjarifyDirectory.getAbsolutePath()); - System.out.println("Updated to enjarify v" + BytecodeViewer.enjarifyVersion); + System.out.println("Updated to enjarify v" + Constants.enjarifyVersion); } catch (Exception e) { BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart " - + "BCV." + BytecodeViewer.nl + + + "BCV." + nl + "If the error persists contact @Konloch."); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); Objects.requireNonNull(enjarifyZip).delete(); @@ -499,16 +496,16 @@ public class Boot { System.out.println("Checking krakatau"); File krakatauZip = null; - for (File f : Objects.requireNonNull(new File(BytecodeViewer.libsDirectory).listFiles())) { + for (File f : Objects.requireNonNull(new File(Constants.libsDirectory).listFiles())) { if (f.getName().toLowerCase().startsWith("krakatau-")) { //System.out.println(f.getName()); - BytecodeViewer.krakatauVersion = f.getName().split("-")[1].split("\\.")[0]; + Constants.krakatauVersion = f.getName().split("-")[1].split("\\.")[0]; krakatauZip = f; } } - for (File f : Objects.requireNonNull(new File(BytecodeViewer.getBCVDirectory()).listFiles())) { - if (f.getName().toLowerCase().startsWith("krakatau_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.krakatauVersion)) { + for (File f : Objects.requireNonNull(new File(getBCVDirectory()).listFiles())) { + if (f.getName().toLowerCase().startsWith("krakatau_") && !f.getName().split("_")[1].split("\\.")[0].equals(Constants.krakatauVersion)) { setState("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "..."); System.out.println("Removing oudated " + f.getName()); try { @@ -519,20 +516,18 @@ public class Boot { } } - BytecodeViewer.krakatauWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + - BytecodeViewer.krakatauVersion + BytecodeViewer.fs + "Krakatau-master"; + Constants.krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + Constants.krakatauVersion + fs + "Krakatau-master"; - File krakatauDirectory = - new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion); + File krakatauDirectory = new File(getBCVDirectory() + fs + "krakatau_" + Constants.krakatauVersion); if (!krakatauDirectory.exists()) { try { setState("Bytecode Viewer Boot Screen - Updating to " + krakatauDirectory.getName() + "..."); ZipUtils.unzipFilesToPath(Objects.requireNonNull(krakatauZip).getAbsolutePath(), krakatauDirectory.getAbsolutePath()); - System.out.println("Updated to krakatau v" + BytecodeViewer.krakatauVersion); + System.out.println("Updated to krakatau v" + Constants.krakatauVersion); } catch (Exception e) { BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly " - + "corrupt). Restart BCV." + BytecodeViewer.nl + + + "corrupt). Restart BCV." + nl + "If the error persists contact @Konloch."); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); Objects.requireNonNull(krakatauZip).delete(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index f0264eae..470dc4e4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -1,21 +1,11 @@ package the.bytecode.club.bytecodeviewer; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import java.awt.Desktop; import java.awt.event.KeyEvent; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,17 +16,12 @@ import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.filechooser.FileFilter; -import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; import me.konloch.kontainer.io.HTTPRequest; import org.apache.commons.io.FileUtils; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bootloader.Boot; -import the.bytecode.club.bootloader.ILoader; -import the.bytecode.club.bootloader.resource.EmptyExternalResource; -import the.bytecode.club.bootloader.resource.ExternalResource; import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader; -import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.compilers.Compilers; import the.bytecode.club.bytecodeviewer.gui.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.FileNavigationPane; @@ -47,14 +32,9 @@ import the.bytecode.club.bytecodeviewer.gui.SystemErrConsole; import the.bytecode.club.bytecodeviewer.gui.WorkPane; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer; import the.bytecode.club.bytecodeviewer.plugin.PluginManager; -import the.bytecode.club.bytecodeviewer.util.APKTool; -import the.bytecode.club.bytecodeviewer.util.Dex2Jar; -import the.bytecode.club.bytecodeviewer.util.Enjarify; -import the.bytecode.club.bytecodeviewer.util.FileContainer; -import the.bytecode.club.bytecodeviewer.util.JRTExtractor; -import the.bytecode.club.bytecodeviewer.util.JarUtils; -import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; -import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import the.bytecode.club.bytecodeviewer.util.*; + +import static the.bytecode.club.bytecodeviewer.Constants.*; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -75,66 +55,47 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils; ***************************************************************************/ /** - * TODO: - * open as folder doesn't actually work - * smali compile - *

* A lightweight Java Reverse Engineering suite, developed by Konloch - http://konloch.me - *

+ * * All you have to do is add a jar or class file into the workspace, * select the file you want then it will start decompiling the class in the background. * When it's done it will show the Source code, Bytecode and Hexcode of the class file you chose. - *

+ * * There is also a plugin system that will allow you to interact with the loaded classfiles. * For example you can write a String deobfuscator, a malicious code searcher, * or anything else you can think of. - *

+ * * You can either use one of the pre-written plugins, or write your own. It supports java scripting. * Once a plugin is activated, it will send a ClassNode ArrayList of every single class loaded in the * file system to the execute function, this allows the user to handle it completely using ASM. - *

+ * * Are you a Java Reverse Engineer? Or maybe you want to learn Java Reverse Engineering? * Join The Bytecode Club, we're noob friendly, and censorship free. * http://the.bytecode.club - *

+ * * TODO: - * Finish dragging code - * Finish right-click tab menu detection - * make it use that global last used inside of export as jar - * Add https://github.com/ptnkjke/Java-Bytecode-Editor visualize as a plugin - * make zipfile not include the decode shit - * add stackmapframes to bytecode decompiler - * make ez-injection plugin console show all sys.out calls - * add JEB decompiler optionally, requires them to add jeb library jar externally and disable update check ? - * add decompile as zip for krakatau-bytecode, jd-gui and smali for CLI - * add decompile all as zip for CLI - * fix hook inject for EZ-Injection - * fix classfile searcher - * make the decompilers launch in a separate process + * open as folder doesn't actually work + * smali compile + * Finish dragging code + * Finish right-click tab menu detection + * make it use that global last used inside of export as jar + * Add https://github.com/ptnkjke/Java-Bytecode-Editor visualize as a plugin + * make zipfile not include the decode shit + * add stackmapframes to bytecode decompiler + * make ez-injection plugin console show all sys.out calls + * add JEB decompiler optionally, requires them to add jeb library jar externally and disable update check ? + * add decompile as zip for krakatau-bytecode, jd-gui and smali for CLI + * add decompile all as zip for CLI + * fix hook inject for EZ-Injection + * fix classfile searcher + * make the decompilers launch in a separate process * * @author Konloch * @author The entire BCV community */ -public class BytecodeViewer { - /*per version*/ - public static final String VERSION = "2.10.10"; - public static String krakatauVersion = "12"; - public static String enjarifyVersion = "4"; - public static final boolean BLOCK_TAB_MENU = true; - public static final boolean PREVIEW_COPY = false; - 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 - - /*the rest*/ - public static boolean verify = false; //eventually may be a setting - public static String[] args; - public static MainViewerGUI viewer = null; - public static ClassNodeLoader loader = new ClassNodeLoader(); //might be insecure due to assholes targeting BCV, - // however that's highly unlikely. - public static SecurityMan sm = new SecurityMan(); //might be insecure due to assholes targeting BCV, however - // that's highly unlikely. +public class BytecodeViewer +{ public static String python = ""; public static String python3 = ""; public static String rt = ""; @@ -147,242 +108,28 @@ public class BytecodeViewer { public static boolean currentlyDumping = false; public static boolean needsReDump = true; public static boolean warnForEditing = false; - public static List files = new ArrayList<>(); //all of BCV's loaded files/classes/etc - private static final int maxRecentFiles = 25; - public static String fs = System.getProperty("file.separator"); - public static String nl = System.getProperty("line.separator"); - private static final File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer"); - public static File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar"); - public static File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar"); - private static final String filesName = getBCVDirectory() + fs + "recentfiles.json"; - private static final String pluginsName = getBCVDirectory() + fs + "recentplugins.json"; - public static String settingsName = getBCVDirectory() + fs + "settings.bcv"; - public static String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs; - public static String libsDirectory = getBCVDirectory() + fs + "libs" + fs; - public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion; - public static String enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + enjarifyVersion; public static boolean runningObfuscation = false; private static final long start = System.currentTimeMillis(); public static String lastDirectory = "."; - public static List createdProcesses = new ArrayList<>(); - public static Refactorer refactorer = new Refactorer(); public static boolean pingback = false; public static boolean deleteForeignLibraries = true; public static boolean canExit = false; - public static Gson gson; + + + public static boolean verify = false; //eventually may be a setting + public static String[] args; + public static MainViewerGUI viewer = null; + public static ClassNodeLoader loader = new ClassNodeLoader(); //might be insecure due to assholes targeting BCV, + public static SecurityMan sm = new SecurityMan(); //might be insecure due to assholes targeting BCV, however + public static Refactorer refactorer = new Refactorer(); + public static List files = new ArrayList<>(); //all of BCV's loaded files/classes/etc + public static List createdProcesses = new ArrayList<>(); - private static List recentPlugins; - private static List recentFiles; - - static { - try { - gson = new GsonBuilder().setPrettyPrinting().create(); - if (new File(filesName).exists()) - recentFiles = gson.fromJson(DiskReader.loadAsString(filesName), new TypeToken>() { - }.getType()); - else - recentFiles = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentfiles.bcv", false); - - if (new File(pluginsName).exists()) - recentPlugins = gson.fromJson(DiskReader.loadAsString(pluginsName), new TypeToken>() { - }.getType()); - else - recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentplugins.bcv", false); - } catch (Exception e) { - e.printStackTrace(); - } - } /** * The version checker thread */ - private static final Thread versionChecker = new Thread(() -> { - try { - HTTPRequest r = new HTTPRequest(new URL("https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/VERSION")); - final String version = r.readSingle(); - final String localVersion = BytecodeViewer.VERSION + 0; - try { - int simplemaths = Integer.parseInt(version.replace(".", "")); - int simplemaths2 = Integer.parseInt(localVersion.replace(".", "")); - System.out.println("DEBUG: " + simplemaths + " vs " + simplemaths2); - if (simplemaths2 > simplemaths) - return; //developer version - } catch (Exception ignored) { - - } - - if (!BytecodeViewer.VERSION.equals(version)) { - JOptionPane pane = new JOptionPane("Your version: " - + BytecodeViewer.VERSION - + ", latest version: " - + version - + nl - + "What would you like to do?"); - Object[] options = new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"}; - pane.setOptions(options); - JDialog dialog = pane.createDialog(BytecodeViewer.viewer, - "Bytecode Viewer - Outdated Version"); - dialog.setVisible(true); - Object obj = pane.getValue(); - int result = -1; - for (int k = 0; k < options.length; k++) - if (options[k].equals(obj)) - result = k; - - if (result == 0) { - if (Desktop.isDesktopSupported()) { - Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases")); - } else { - showMessage("Cannot open the page, please manually type it." + nl + "https://github" - + ".com/Konloch/bytecode-viewer/releases"); - } - } - if (result == 1) { - JFileChooser fc = new JFileChooser(); - try { - fc.setCurrentDirectory(new File(".").getAbsoluteFile()); //set the current working directory - } catch (Exception e) { - new ExceptionUI(e); - } - fc.setFileFilter(new FileFilter() { - @Override - public boolean accept(File f) { - return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("zip"); - } - - @Override - public String getDescription() { - return "Zip Archives"; - } - }); - fc.setFileHidingEnabled(false); - fc.setAcceptAllFileFilterUsed(false); - int returnVal = fc.showSaveDialog(viewer); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - if (!file.getAbsolutePath().endsWith(".zip")) - file = new File(file.getAbsolutePath() + ".zip"); - - if (file.exists()) { - pane = new JOptionPane("The file " + file + " exists, would you like to overwrite it?"); - options = new String[]{"Yes", "No"}; - pane.setOptions(options); - dialog = pane.createDialog(BytecodeViewer.viewer, - "Bytecode Viewer - Overwrite File"); - dialog.setVisible(true); - obj = pane.getValue(); - result = -1; - for (int k = 0; k < options.length; k++) - if (options[k].equals(obj)) - result = k; - - if (result != 0) - return; - - file.delete(); - } - - final File finalFile = file; - Thread downloadThread = new Thread(() -> { - try { - InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases" - + "/download/v" + version + "/BytecodeViewer." + version + ".zip").openConnection().getInputStream(); - FileOutputStream fos = new FileOutputStream(finalFile); - try { - System.out.println("Downloading from https://github" - + ".com/Konloch/bytecode-viewer/releases/download/v" + version + - "/BytecodeViewer." + version + ".zip"); - byte[] buffer = new byte[8192]; - int len; - int downloaded = 0; - boolean flag = false; - showMessage("Downloading the jar in the background, when it's finished " - + "you will be alerted with another message box." + nl + nl + - "Expect this to take several minutes."); - while ((len = is.read(buffer)) > 0) { - fos.write(buffer, 0, len); - fos.flush(); - downloaded += 8192; - int mbs = downloaded / 1048576; - if (mbs % 5 == 0 && mbs != 0) { - if (!flag) - System.out.println("Downloaded " + mbs + "MBs so far"); - flag = true; - } else - flag = false; - } - } finally { - try { - if (is != null) { - is.close(); - } - } finally { - fos.flush(); - fos.close(); - } - } - System.out.println("Download finished!"); - showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath()); - } catch (FileNotFoundException e) { - try { - InputStream is = new URL("https://github.com/Konloch/bytecode-viewer" - + "/releases/download/v" + version + "/BytecodeViewer." + version + ".jar" - ).openConnection().getInputStream(); - FileOutputStream fos = new FileOutputStream(finalFile); - try { - System.out.println("Downloading from https://github" - + ".com/Konloch/bytecode-viewer/releases/download/v" + version + - "/BytecodeViewer." + version + ".jar"); - byte[] buffer = new byte[8192]; - int len; - int downloaded = 0; - boolean flag = false; - showMessage("Downloading the jar in the background, when it's " - + "finished you will be alerted with another message box." + nl + nl + "Expect this to take several minutes."); - while ((len = is.read(buffer)) > 0) { - fos.write(buffer, 0, len); - fos.flush(); - downloaded += 8192; - int mbs = downloaded / 1048576; - if (mbs % 5 == 0 && mbs != 0) { - if (!flag) - System.out.println("Downloaded " + mbs + "MBs so far"); - flag = true; - } else - flag = false; - } - } finally { - try { - if (is != null) { - is.close(); - } - } finally { - fos.flush(); - fos.close(); - } - } - System.out.println("Download finished!"); - showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath()); - } catch (FileNotFoundException ex) { - showMessage("Unable to download, the zip file has not been uploaded yet, " - + "please try again in about 10 minutes."); - } catch (Exception ex) { - new ExceptionUI(ex); - } - - } catch (Exception e) { - new ExceptionUI(e); - } - - }); - downloadThread.start(); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - }); + private static final Thread versionChecker = new Thread(new VersionChecker()); /** * Pings back to bytecodeviewer.com to be added into the total running statistics @@ -400,7 +147,7 @@ public class BytecodeViewer { */ private static final Thread InstallFatJar = new Thread(() -> { try { - if (BytecodeViewer.OFFLINE_MODE) { + if (OFFLINE_MODE) { Boot.dropKrakatau(); Boot.dropEnjarify(); } else { @@ -418,85 +165,7 @@ public class BytecodeViewer { /** * Used to check incase booting failed for some reason, this kicks in as a fail safe */ - private static final Thread bootCheck = new Thread() { - boolean finished = false; - - @Override - @SuppressWarnings({"rawtypes", "unchecked"}) - public void run() { - long start = System.currentTimeMillis(); - - while (!finished) { - if (System.currentTimeMillis() - start >= 7000) { //7 second failsafe - if (!Boot.completedboot && !Boot.downloading) { - File libsDir = Boot.libsDir(); - File[] listFiles = libsDir.listFiles(); - if (listFiles == null || listFiles.length <= 0) { - BytecodeViewer.showMessage( - "Github is loading extremely slow, BCV needs to download libraries from github in" - + " order" + nl + - "to work, please try adjusting your network settings or manually " - + "downloading these libraries" + nl + - "if this error persists."); - finished = true; - return; - } - - Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Unable to connect to github, " - + "force booting..."); - System.out.println("Unable to connect to github, force booting..."); - List libsFileList = new ArrayList<>(); - for (File f : listFiles) { - libsFileList.add(f.getAbsolutePath()); - } - - ILoader loader = Boot.findLoader(); - - for (String s : libsFileList) { - if (s.endsWith(".jar")) { - File f = new File(s); - if (f.exists()) { - Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Force Loading Library" - + " " + f.getName()); - System.out.println("Force loading library " + f.getName()); - - try { - ExternalResource res = new EmptyExternalResource<>(f.toURI().toURL()); - loader.bind(res); - System.out.println("Successfully loaded " + f.getName()); - } catch (Exception e) { - e.printStackTrace(); - f.delete(); - JOptionPane.showMessageDialog(null, "Error, Library " + f.getName() + " is " - + "corrupt, please restart to redownload it.", - "Error", JOptionPane.ERROR_MESSAGE); - } - } - } - } - - Boot.checkEnjarify(); - Boot.checkKrakatau(); - - Boot.globalstop = false; - Boot.hide(); - - if (CommandLineInput.parseCommandLine(args) == CommandLineInput.OPEN_FILE) - BytecodeViewer.BOOT(false); - else { - BytecodeViewer.BOOT(true); - CommandLineInput.executeCommandLine(args); - } - } - finished = true; - } - try { - Thread.sleep(100); - } catch (InterruptedException ignored) { - } - } - } - }; + private static final Thread bootCheck = new Thread(new BootCheck()); /** * Grab the byte array from the loaded Class object @@ -523,17 +192,16 @@ public class BytecodeViewer { */ public static void main(String[] args) { BytecodeViewer.args = args; - System.out.println("https://the.bytecode.club - Created by @Konloch - Bytecode Viewer " + VERSION + ", " - + "Fat-Jar: " + FAT_JAR); + System.out.println("https://the.bytecode.club - Created by @Konloch - Bytecode Viewer " + VERSION + ", " + "Fat-Jar: " + FAT_JAR); System.setSecurityManager(sm); + try { UIManager.put("MenuItem.disabledAreNavigable", Boolean.FALSE); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (PREVIEW_COPY && !CommandLineInput.containsCommand(args)) showMessage("WARNING: This is a preview/dev copy, you WON'T be alerted when " + VERSION + " is " + "actually out if you use this." + nl + - "Make sure to watch the repo: https://github.com/Konloch/bytecode-viewer for " + VERSION + - "'s release"); + "Make sure to watch the repo: https://github.com/Konloch/bytecode-viewer for " + VERSION + "'s release"); viewer = new MainViewerGUI(); Settings.loadSettings(); @@ -623,7 +291,7 @@ public class BytecodeViewer { sm.setBlocking(); boolean empty = java.isEmpty(); while (empty) { - showMessage("You need to set your Java path, this requires the JRE to be downloaded." + BytecodeViewer.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)"); viewer.java(); empty = java.isEmpty(); @@ -835,8 +503,6 @@ public class BytecodeViewer { return true; } - private static boolean update = true; - /** * Opens a file, optional if it should append to the recent files menu * @@ -850,178 +516,8 @@ public class BytecodeViewer { BytecodeViewer.addRecentFile(f); BytecodeViewer.viewer.setIcon(true); - update = true; needsReDump = true; - - Thread t = new Thread(() -> { - try { - for (final File f : files) { - final String fn = f.getName(); - if (!f.exists()) { - update = false; - showMessage("The file " + f.getAbsolutePath() + " could not be found."); - } else { - if (f.isDirectory()) { - FileContainer container = new FileContainer(f); - HashMap files1 = new HashMap<>(); - boolean finished = false; - ArrayList totalFiles = new ArrayList<>(); - totalFiles.add(f); - String dir = f.getAbsolutePath();//f.getAbsolutePath().substring(0, f.getAbsolutePath - // ().length()-f.getName().length()); - - while (!finished) { - boolean added = false; - for (int i = 0; i < totalFiles.size(); i++) { - File child = totalFiles.get(i); - if (child.listFiles() != null) - for (File rocket : Objects.requireNonNull(child.listFiles())) - if (!totalFiles.contains(rocket)) { - totalFiles.add(rocket); - added = true; - } - } - - if (!added) { - for (File child : totalFiles) - if (child.isFile()) { - String fileName = child.getAbsolutePath().substring(dir.length() + 1 - ).replaceAll("\\\\", "\\/"); - - - files1.put(fileName, - Files.readAllBytes(Paths.get(child.getAbsolutePath()))); - } - finished = true; - } - } - container.files = files1; - BytecodeViewer.files.add(container); - } else { - if (fn.endsWith(".jar") || fn.endsWith(".zip") || fn.endsWith(".war")) { - try { - JarUtils.put(f); - } catch (IOException z) { - try { - JarUtils.put2(f); - } catch (final Exception e) { - new ExceptionUI(e); - update = false; - } - } catch (final Exception e) { - new ExceptionUI(e); - update = false; - } - - } else if (fn.endsWith(".class")) { - try { - byte[] bytes = JarUtils.getBytes(new FileInputStream(f)); - String cafebabe = String.format("%02X", bytes[0]) + String.format("%02X", - bytes[1]) + String.format("%02X", bytes[2]) + String.format("%02X", - bytes[3]); - if (cafebabe.equalsIgnoreCase("cafebabe")) { - final ClassNode cn = JarUtils.getNode(bytes); - - FileContainer container = new FileContainer(f); - container.classes.add(cn); - BytecodeViewer.files.add(container); - } else { - showMessage(fn + ": Header does not start with CAFEBABE, ignoring."); - update = false; - } - } catch (final Exception e) { - new ExceptionUI(e); - update = false; - } - } else if (fn.endsWith(".apk")) { - try { - BytecodeViewer.viewer.setIcon(true); - - File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + - ".apk"); - - FileUtils.copyFile(f, tempCopy); - - FileContainer container = new FileContainer(tempCopy, f.getName()); - - if (viewer.decodeAPKResources.isSelected()) { - File decodedResources = - new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); - APKTool.decodeResources(tempCopy, decodedResources, container); - container.files = JarUtils.loadResources(decodedResources); - } - - Objects.requireNonNull(container.files).putAll(JarUtils.loadResources(tempCopy)); //copy and rename - // to prevent unicode filenames - - String name = getRandomizedName() + ".jar"; - File output = new File(tempDirectory + fs + name); - - if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) - Dex2Jar.dex2Jar(tempCopy, output); - else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) - Enjarify.apk2Jar(tempCopy, output); - - container.classes = JarUtils.loadClasses(output); - - BytecodeViewer.viewer.setIcon(false); - BytecodeViewer.files.add(container); - } catch (final Exception e) { - new ExceptionUI(e); - } - return; - } else if (fn.endsWith(".dex")) { - try { - BytecodeViewer.viewer.setIcon(true); - - File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + - ".dex"); - - FileUtils.copyFile(f, tempCopy); //copy and rename to prevent unicode filenames - - FileContainer container = new FileContainer(tempCopy, f.getName()); - - String name = getRandomizedName() + ".jar"; - File output = new File(tempDirectory + fs + name); - - if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) - Dex2Jar.dex2Jar(tempCopy, output); - else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) - Enjarify.apk2Jar(tempCopy, output); - - container.classes = JarUtils.loadClasses(output); - - BytecodeViewer.viewer.setIcon(false); - BytecodeViewer.files.add(container); - } catch (final Exception e) { - new ExceptionUI(e); - } - return; - } else { - HashMap files1 = new HashMap<>(); - byte[] bytes = JarUtils.getBytes(new FileInputStream(f)); - files1.put(f.getName(), bytes); - - - FileContainer container = new FileContainer(f); - container.files = files1; - BytecodeViewer.files.add(container); - } - } - } - } - } catch (final Exception e) { - new ExceptionUI(e); - } finally { - BytecodeViewer.viewer.setIcon(false); - - if (update) - try { - Objects.requireNonNull(MainViewerGUI.getComponent(FileNavigationPane.class)).updateTree(); - } catch (NullPointerException ignored) { - } - } - }); + Thread t = new Thread(new OpenFile(files)); t.start(); } @@ -1204,46 +700,6 @@ public class BytecodeViewer { return name; } - /** - * Returns the BCV directory - * - * @return the static BCV directory - */ - public static String getBCVDirectory() { - while (!BCVDir.exists()) - BCVDir.mkdirs(); - - if (!BCVDir.isHidden() && isWindows()) - hideFile(BCVDir); - - return BCVDir.getAbsolutePath(); - } - - /** - * Checks if the OS contains 'win' - * - * @return true if the os.name property contains 'win' - */ - private static boolean isWindows() { - return System.getProperty("os.name").toLowerCase().contains("win"); - } - - /** - * Runs the windows command to hide files - * - * @param f file you want hidden - */ - private static void hideFile(File f) { - sm.stopBlocking(); - try { - // Hide file by running attrib system command (on Windows) - Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); - } catch (Exception e) { - new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); - } - sm.setBlocking(); - } - /** * Converts an array list to a string * @@ -1427,12 +883,9 @@ public class BytecodeViewer { currentlyDumping = true; needsReDump = false; - krakatauTempDir = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + krakatauTempDir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs); krakatauTempDir.mkdir(); - krakatauTempJar = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(32) + - ".jar"); + krakatauTempJar = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); //krakatauTempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils // .randomString(32) + ".jar."+container.name); JarUtils.saveAsJarClassesOnly(container.classes, krakatauTempJar.getAbsolutePath()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/CommandLineInput.java b/src/main/java/the/bytecode/club/bytecodeviewer/CommandLineInput.java index 84ca16d9..edda10aa 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/CommandLineInput.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/CommandLineInput.java @@ -11,6 +11,8 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.decompilers.Decompilers; import the.bytecode.club.bytecodeviewer.util.JarUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -47,7 +49,7 @@ public class CommandLineInput { static { options.addOption("help", false, "prints the help menu."); - options.addOption("list", false, "lists all the available decompilers for BCV " + BytecodeViewer.VERSION + "."); + options.addOption("list", false, "lists all the available decompilers for BCV " + VERSION + "."); options.addOption("decompiler", true, "sets the decompiler, procyon by default."); options.addOption("i", true, "sets the input."); options.addOption("o", true, "sets the output."); @@ -184,7 +186,7 @@ public class CommandLineInput { //if its just class allow any File tempZip = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar"); + new File(tempDirectory + fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar"); if (tempZip.exists()) tempZip.delete(); @@ -322,7 +324,7 @@ public class CommandLineInput { } System.out.println("Finished."); - System.out.println("Bytecode Viewer CLI v" + BytecodeViewer.VERSION + " by @Konloch - " + System.out.println("Bytecode Viewer CLI v" + VERSION + " by @Konloch - " + "https://bytecodeviewer.com"); BytecodeViewer.canExit = true; System.exit(0); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java new file mode 100644 index 00000000..0f5be61e --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java @@ -0,0 +1,101 @@ +package the.bytecode.club.bytecodeviewer; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import me.konloch.kontainer.io.DiskReader; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Konloch + * @since 6/21/2021 + */ +public class Constants +{ + /*per version*/ + public static final String VERSION = "2.10.10"; //could be loaded from the pom + public static String krakatauVersion = "12"; + public static String enjarifyVersion = "4"; + public static final boolean BLOCK_TAB_MENU = true; + public static final boolean PREVIEW_COPY = false; + 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 int maxRecentFiles = 25; + public static final String fs = System.getProperty("file.separator"); + public static final String nl = System.getProperty("line.separator"); + public static final File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer"); + public static final File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar"); + public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar"); + public static final String filesName = getBCVDirectory() + fs + "recentfiles.json"; + public static final String pluginsName = getBCVDirectory() + fs + "recentplugins.json"; + public static final String settingsName = getBCVDirectory() + fs + "settings.bcv"; + public static final String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs; + public static final String libsDirectory = getBCVDirectory() + fs + "libs" + fs; + public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion; + public static String enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + enjarifyVersion; + + public static List recentPlugins; + public static List recentFiles; + public static Gson gson; + + static { + try { + gson = new GsonBuilder().setPrettyPrinting().create(); + if (new File(filesName).exists()) + recentFiles = gson.fromJson(DiskReader.loadAsString(filesName), new TypeToken>() {}.getType()); + else + recentFiles = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentfiles.bcv", false); + + if (new File(pluginsName).exists()) + recentPlugins = gson.fromJson(DiskReader.loadAsString(pluginsName), new TypeToken>() {}.getType()); + else + recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentplugins.bcv", false); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Returns the BCV directory + * + * @return the static BCV directory + */ + public static String getBCVDirectory() { + while (!BCVDir.exists()) + BCVDir.mkdirs(); + + if (!BCVDir.isHidden() && isWindows()) + hideFile(BCVDir); + + return BCVDir.getAbsolutePath(); + } + + /** + * Checks if the OS contains 'win' + * + * @return true if the os.name property contains 'win' + */ + private static boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("win"); + } + + /** + * Runs the windows command to hide files + * + * @param f file you want hidden + */ + private static void hideFile(File f) { + BytecodeViewer.sm.stopBlocking(); + try { + // Hide file by running attrib system command (on Windows) + Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); + } catch (Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + } + BytecodeViewer.sm.setBlocking(); + } +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Resources.java b/src/main/java/the/bytecode/club/bytecodeviewer/Resources.java index 700f4d43..e78a0fcd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Resources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Resources.java @@ -11,6 +11,8 @@ import javax.swing.ImageIcon; import org.apache.commons.codec.binary.Base64; import org.imgscalr.Scalr; +import static the.bytecode.club.bytecodeviewer.Constants.libsDirectory; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -126,7 +128,7 @@ public class Resources { } public static String findLibrary(String nameContains) { - for (File f : Objects.requireNonNull(new File(BytecodeViewer.libsDirectory).listFiles())) { + for (File f : Objects.requireNonNull(new File(libsDirectory).listFiles())) { if (f.getName().contains(nameContains)) return f.getAbsolutePath(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java b/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java index 5b3a55f9..be557922 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java @@ -4,6 +4,8 @@ import javax.swing.JFrame; import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -32,315 +34,315 @@ public class Settings { public static void saveSettings() { try { - DiskWriter.replaceFile(BytecodeViewer.settingsName, "BCV: " + BytecodeViewer.VERSION, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.replaceFile(settingsName, "BCV: " + VERSION, false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.rbr.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.rsy.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.din.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.dc4.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.das.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hes.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hdc.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.dgs.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.ner.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.den.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.rgn.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.bto.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.nns.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.uto.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.udv.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.rer.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.fdi.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.asc.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.decodeenumswitch.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.sugarenums.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.decodestringswitch.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.arrayiter.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.collectioniter.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.innerclasses.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.removeboilerplate.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.removeinnerclasssynthetics.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.decodelambdas.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hidebridgemethods.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.liftconstructorinit.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.removedeadmethods.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.removebadgenerics.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.sugarasserts.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.sugarboxing.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.showversion.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.decodefinally.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.tidymonitors.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.lenient.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.dumpclasspath.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.comments.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forcetopsort.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forcetopsortaggress.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.stringbuffer.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.stringbuilder.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.silent.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.recover.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.eclipse.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.override.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.showinferrable.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.aexagg.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forcecondpropagate.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hideutf.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hidelongstrings.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.commentmonitor.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.allowcorrecting.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.labelledblocks.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.j14classobj.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.hidelangimports.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.recoverytypeclash.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.recoverytypehints.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forceturningifs.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forloopaggcapture.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forceexceptionprune.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmShowDebugLine.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.mnMergeVariables.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.debugHelpers.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, "deprecated", false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.isSelected()), false); if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1None.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + DiskWriter.writeNewLine(settingsName, "0", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Proc.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + DiskWriter.writeNewLine(settingsName, "1", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1CFR.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + DiskWriter.writeNewLine(settingsName, "2", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Fern.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + DiskWriter.writeNewLine(settingsName, "3", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + DiskWriter.writeNewLine(settingsName, "4", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + DiskWriter.writeNewLine(settingsName, "5", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Smali.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "6", false); + DiskWriter.writeNewLine(settingsName, "6", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1Krakatau.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); + DiskWriter.writeNewLine(settingsName, "7", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); + DiskWriter.writeNewLine(settingsName, "8", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.panel1JDGUI.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false); + DiskWriter.writeNewLine(settingsName, "9", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.jadxJ1.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "10", false); + DiskWriter.writeNewLine(settingsName, "10", false); else if (BytecodeViewer.viewer.panelGroup1.isSelected(BytecodeViewer.viewer.asmText1.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false); + DiskWriter.writeNewLine(settingsName, "11", false); if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2None.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + DiskWriter.writeNewLine(settingsName, "0", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Proc.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + DiskWriter.writeNewLine(settingsName, "1", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2CFR.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + DiskWriter.writeNewLine(settingsName, "2", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Fern.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + DiskWriter.writeNewLine(settingsName, "3", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + DiskWriter.writeNewLine(settingsName, "4", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + DiskWriter.writeNewLine(settingsName, "5", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Smali.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "6", false); + DiskWriter.writeNewLine(settingsName, "6", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2Krakatau.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); + DiskWriter.writeNewLine(settingsName, "7", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); + DiskWriter.writeNewLine(settingsName, "8", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.panel2JDGUI.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false); + DiskWriter.writeNewLine(settingsName, "9", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.jadxJ2.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "10", false); + DiskWriter.writeNewLine(settingsName, "10", false); else if (BytecodeViewer.viewer.panelGroup2.isSelected(BytecodeViewer.viewer.asmText2.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false); + DiskWriter.writeNewLine(settingsName, "11", false); if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3None.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + DiskWriter.writeNewLine(settingsName, "0", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Proc.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); + DiskWriter.writeNewLine(settingsName, "1", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3CFR.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "2", false); + DiskWriter.writeNewLine(settingsName, "2", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Fern.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "3", false); + DiskWriter.writeNewLine(settingsName, "3", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "4", false); + DiskWriter.writeNewLine(settingsName, "4", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "5", false); + DiskWriter.writeNewLine(settingsName, "5", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Smali.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "6", false); + DiskWriter.writeNewLine(settingsName, "6", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3Krakatau.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "7", false); + DiskWriter.writeNewLine(settingsName, "7", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "8", false); + DiskWriter.writeNewLine(settingsName, "8", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel3JDGUI.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "9", false); + DiskWriter.writeNewLine(settingsName, "9", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.jadxJ3.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "10", false); + DiskWriter.writeNewLine(settingsName, "10", false); else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.asmText3.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "11", false); + DiskWriter.writeNewLine(settingsName, "11", false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.lastDirectory, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.rt, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, "deprecated", false); + DiskWriter.writeNewLine(settingsName, "deprecated", false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.lastDirectory, false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.python, false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.rt, false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1Proc_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1CFR_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1Fern_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1Krakatau_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1Smali_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2Proc_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2CFR_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2Fern_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2Krakatau_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2Smali_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3Proc_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3CFR_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3Fern_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3Krakatau_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3Smali_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.decodeAPKResources.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.library, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.pingback), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, BytecodeViewer.library, false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.pingback), false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel1JDGUI_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel2JDGUI_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.panel3JDGUI_E.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.fontSpinner.getValue()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.deleteForeignLibraries), false); if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false); + DiskWriter.writeNewLine(settingsName, "0", false); else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) - DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python3, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.javac, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.java, false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, "1", false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.python3, false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.javac, false); + DiskWriter.writeNewLine(settingsName, BytecodeViewer.java, false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.compileOnSave.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.warnForEditing), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.warnForEditing), false); + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.showFileInTabTitle.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.forcePureAsciiAsText.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.synchronizedViewing.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.showClassMethods.isSelected()), false); - DiskWriter.writeNewLine(BytecodeViewer.settingsName, + DiskWriter.writeNewLine(settingsName, String.valueOf(BytecodeViewer.viewer.ren.isSelected()), false); } catch (Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); @@ -349,87 +351,87 @@ public class Settings { public static void loadSettings() { //utilizes the Disk Reader's caching system. try { - BytecodeViewer.viewer.rbr.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 1, true))); - BytecodeViewer.viewer.rsy.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 2, false))); - BytecodeViewer.viewer.din.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 3, false))); - BytecodeViewer.viewer.dc4.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 4, false))); - BytecodeViewer.viewer.das.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 5, false))); - BytecodeViewer.viewer.hes.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 6, false))); - BytecodeViewer.viewer.hdc.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 7, false))); - BytecodeViewer.viewer.dgs.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 8, false))); - BytecodeViewer.viewer.ner.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 9, false))); - BytecodeViewer.viewer.den.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 10, false))); - BytecodeViewer.viewer.rgn.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 11, false))); - BytecodeViewer.viewer.bto.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 12, false))); - BytecodeViewer.viewer.nns.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 13, false))); - BytecodeViewer.viewer.uto.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 14, false))); - BytecodeViewer.viewer.udv.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 15, false))); - BytecodeViewer.viewer.rer.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 16, false))); - BytecodeViewer.viewer.fdi.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 17, false))); - BytecodeViewer.viewer.asc.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 18, false))); - BytecodeViewer.viewer.decodeenumswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 19, false))); - BytecodeViewer.viewer.sugarenums.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 20, false))); - BytecodeViewer.viewer.decodestringswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 21, false))); - BytecodeViewer.viewer.arrayiter.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 22, false))); - BytecodeViewer.viewer.collectioniter.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 23, false))); - BytecodeViewer.viewer.innerclasses.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 24, false))); - BytecodeViewer.viewer.removeboilerplate.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 25, false))); - BytecodeViewer.viewer.removeinnerclasssynthetics.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 26, false))); - BytecodeViewer.viewer.decodelambdas.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 27, false))); - BytecodeViewer.viewer.hidebridgemethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 28, false))); - BytecodeViewer.viewer.liftconstructorinit.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 29, false))); - BytecodeViewer.viewer.removedeadmethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 30, false))); - BytecodeViewer.viewer.removebadgenerics.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 31, false))); - BytecodeViewer.viewer.sugarasserts.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 32, false))); - BytecodeViewer.viewer.sugarboxing.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 33, false))); - BytecodeViewer.viewer.showversion.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 34, false))); - BytecodeViewer.viewer.decodefinally.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 35, false))); - BytecodeViewer.viewer.tidymonitors.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 36, false))); - BytecodeViewer.viewer.lenient.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 37, false))); - BytecodeViewer.viewer.dumpclasspath.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 38, false))); - BytecodeViewer.viewer.comments.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 39, false))); - BytecodeViewer.viewer.forcetopsort.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 40, false))); - BytecodeViewer.viewer.forcetopsortaggress.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 41, false))); - BytecodeViewer.viewer.stringbuffer.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 42, false))); - BytecodeViewer.viewer.stringbuilder.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 43, false))); - BytecodeViewer.viewer.silent.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 44, false))); - BytecodeViewer.viewer.recover.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 45, false))); - BytecodeViewer.viewer.eclipse.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 46, false))); - BytecodeViewer.viewer.override.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 47, false))); - BytecodeViewer.viewer.showinferrable.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 48, false))); - BytecodeViewer.viewer.aexagg.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 49, false))); - BytecodeViewer.viewer.forcecondpropagate.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 50, false))); - BytecodeViewer.viewer.hideutf.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 51, false))); - BytecodeViewer.viewer.hidelongstrings.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 52, false))); - BytecodeViewer.viewer.commentmonitor.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 53, false))); - BytecodeViewer.viewer.allowcorrecting.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 54, false))); - BytecodeViewer.viewer.labelledblocks.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 55, false))); - BytecodeViewer.viewer.j14classobj.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 56, false))); - BytecodeViewer.viewer.hidelangimports.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 57, false))); - BytecodeViewer.viewer.recoverytypeclash.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 58, false))); - BytecodeViewer.viewer.recoverytypehints.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 59, false))); - BytecodeViewer.viewer.forceturningifs.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 60, false))); - BytecodeViewer.viewer.forloopaggcapture.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 61, false))); - BytecodeViewer.viewer.forceexceptionprune.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 62, false))); - BytecodeViewer.viewer.chckbxmntmShowDebugLine.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 63, false))); - BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 64, false))); - BytecodeViewer.viewer.mnMergeVariables.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 65, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 66, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 67, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 68, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 69, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 70, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 71, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 72, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 73, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 74, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 75, false))); - BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 76, false))); - BytecodeViewer.viewer.chckbxmntmAppendBrackets.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 77, false))); - BytecodeViewer.viewer.debugHelpers.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 78, false))); + BytecodeViewer.viewer.rbr.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 1, true))); + BytecodeViewer.viewer.rsy.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 2, false))); + BytecodeViewer.viewer.din.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 3, false))); + BytecodeViewer.viewer.dc4.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 4, false))); + BytecodeViewer.viewer.das.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 5, false))); + BytecodeViewer.viewer.hes.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 6, false))); + BytecodeViewer.viewer.hdc.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 7, false))); + BytecodeViewer.viewer.dgs.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 8, false))); + BytecodeViewer.viewer.ner.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 9, false))); + BytecodeViewer.viewer.den.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 10, false))); + BytecodeViewer.viewer.rgn.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 11, false))); + BytecodeViewer.viewer.bto.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 12, false))); + BytecodeViewer.viewer.nns.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 13, false))); + BytecodeViewer.viewer.uto.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 14, false))); + BytecodeViewer.viewer.udv.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 15, false))); + BytecodeViewer.viewer.rer.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 16, false))); + BytecodeViewer.viewer.fdi.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 17, false))); + BytecodeViewer.viewer.asc.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 18, false))); + BytecodeViewer.viewer.decodeenumswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 19, false))); + BytecodeViewer.viewer.sugarenums.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 20, false))); + BytecodeViewer.viewer.decodestringswitch.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 21, false))); + BytecodeViewer.viewer.arrayiter.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 22, false))); + BytecodeViewer.viewer.collectioniter.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 23, false))); + BytecodeViewer.viewer.innerclasses.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 24, false))); + BytecodeViewer.viewer.removeboilerplate.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 25, false))); + BytecodeViewer.viewer.removeinnerclasssynthetics.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 26, false))); + BytecodeViewer.viewer.decodelambdas.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 27, false))); + BytecodeViewer.viewer.hidebridgemethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 28, false))); + BytecodeViewer.viewer.liftconstructorinit.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 29, false))); + BytecodeViewer.viewer.removedeadmethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 30, false))); + BytecodeViewer.viewer.removebadgenerics.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 31, false))); + BytecodeViewer.viewer.sugarasserts.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 32, false))); + BytecodeViewer.viewer.sugarboxing.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 33, false))); + BytecodeViewer.viewer.showversion.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 34, false))); + BytecodeViewer.viewer.decodefinally.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 35, false))); + BytecodeViewer.viewer.tidymonitors.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 36, false))); + BytecodeViewer.viewer.lenient.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 37, false))); + BytecodeViewer.viewer.dumpclasspath.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 38, false))); + BytecodeViewer.viewer.comments.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 39, false))); + BytecodeViewer.viewer.forcetopsort.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 40, false))); + BytecodeViewer.viewer.forcetopsortaggress.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 41, false))); + BytecodeViewer.viewer.stringbuffer.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 42, false))); + BytecodeViewer.viewer.stringbuilder.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 43, false))); + BytecodeViewer.viewer.silent.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 44, false))); + BytecodeViewer.viewer.recover.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 45, false))); + BytecodeViewer.viewer.eclipse.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 46, false))); + BytecodeViewer.viewer.override.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 47, false))); + BytecodeViewer.viewer.showinferrable.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 48, false))); + BytecodeViewer.viewer.aexagg.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 49, false))); + BytecodeViewer.viewer.forcecondpropagate.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 50, false))); + BytecodeViewer.viewer.hideutf.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 51, false))); + BytecodeViewer.viewer.hidelongstrings.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 52, false))); + BytecodeViewer.viewer.commentmonitor.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 53, false))); + BytecodeViewer.viewer.allowcorrecting.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 54, false))); + BytecodeViewer.viewer.labelledblocks.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 55, false))); + BytecodeViewer.viewer.j14classobj.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 56, false))); + BytecodeViewer.viewer.hidelangimports.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 57, false))); + BytecodeViewer.viewer.recoverytypeclash.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 58, false))); + BytecodeViewer.viewer.recoverytypehints.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 59, false))); + BytecodeViewer.viewer.forceturningifs.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 60, false))); + BytecodeViewer.viewer.forloopaggcapture.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 61, false))); + BytecodeViewer.viewer.forceexceptionprune.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 62, false))); + BytecodeViewer.viewer.chckbxmntmShowDebugLine.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 63, false))); + BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 64, false))); + BytecodeViewer.viewer.mnMergeVariables.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 65, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 66, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 67, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 68, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 69, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 70, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 71, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 72, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 73, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 74, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 75, false))); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 76, false))); + BytecodeViewer.viewer.chckbxmntmAppendBrackets.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 77, false))); + BytecodeViewer.viewer.debugHelpers.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 78, false))); //79 is deprecated - BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 80, false))); - int decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 81, false)); + BytecodeViewer.viewer.chckbxmntmNewCheckItem_12.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 80, false))); + int decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 81, false)); if (decompiler == 0) BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1None.getModel(), true); else if (decompiler == 1) @@ -456,7 +458,7 @@ public class Settings { else if (decompiler == 11) BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.asmText1.getModel(), true); - decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false)); + decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 82, false)); if (decompiler == 0) BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2None.getModel(), true); else if (decompiler == 1) @@ -483,7 +485,7 @@ public class Settings { else if (decompiler == 11) BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.asmText2.getModel(), true); - decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false)); + decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 83, false)); if (decompiler == 0) BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3None.getModel(), true); else if (decompiler == 1) @@ -510,61 +512,61 @@ public class Settings { else if (decompiler == 11) BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.asmText3.getModel(), true); - BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 84, false))); + BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 84, false))); - boolean bool = Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 85, false)); + boolean bool = Boolean.parseBoolean(DiskReader.loadString(settingsName, 85, false)); if (bool) { BytecodeViewer.viewer.setExtendedState(JFrame.MAXIMIZED_BOTH); BytecodeViewer.viewer.isMaximized = true; } //86 is deprecated //87 is deprecated - BytecodeViewer.lastDirectory = DiskReader.loadString(BytecodeViewer.settingsName, 88, false); - BytecodeViewer.python = DiskReader.loadString(BytecodeViewer.settingsName, 89, false); - BytecodeViewer.rt = DiskReader.loadString(BytecodeViewer.settingsName, 90, false); - BytecodeViewer.viewer.panel1Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 91, false))); - BytecodeViewer.viewer.panel1CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 92, false))); - BytecodeViewer.viewer.panel1Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 93, false))); - BytecodeViewer.viewer.panel1Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 94, false))); - BytecodeViewer.viewer.panel1Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 95, false))); - BytecodeViewer.viewer.panel2Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 96, false))); - BytecodeViewer.viewer.panel2CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 97, false))); - BytecodeViewer.viewer.panel2Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 98, false))); - BytecodeViewer.viewer.panel2Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 99, false))); - BytecodeViewer.viewer.panel2Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 100, false))); - BytecodeViewer.viewer.panel3Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 101, false))); - BytecodeViewer.viewer.panel3CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 101, false))); - BytecodeViewer.viewer.panel3Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 103, false))); - BytecodeViewer.viewer.panel3Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 104, false))); - BytecodeViewer.viewer.panel3Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 105, false))); - BytecodeViewer.viewer.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 106, false))); - BytecodeViewer.library = DiskReader.loadString(BytecodeViewer.settingsName, 107, false); - BytecodeViewer.pingback = Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 108, + BytecodeViewer.lastDirectory = DiskReader.loadString(settingsName, 88, false); + BytecodeViewer.python = DiskReader.loadString(settingsName, 89, false); + BytecodeViewer.rt = DiskReader.loadString(settingsName, 90, 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.panel1Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 93, false))); + BytecodeViewer.viewer.panel1Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 94, false))); + BytecodeViewer.viewer.panel1Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 95, false))); + BytecodeViewer.viewer.panel2Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 96, false))); + BytecodeViewer.viewer.panel2CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 97, false))); + BytecodeViewer.viewer.panel2Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 98, false))); + BytecodeViewer.viewer.panel2Krakatau_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 99, false))); + BytecodeViewer.viewer.panel2Smali_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 100, false))); + BytecodeViewer.viewer.panel3Proc_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 101, false))); + BytecodeViewer.viewer.panel3CFR_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 101, false))); + BytecodeViewer.viewer.panel3Fern_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 103, 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.decodeAPKResources.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 106, false))); + BytecodeViewer.library = DiskReader.loadString(settingsName, 107, false); + BytecodeViewer.pingback = Boolean.parseBoolean(DiskReader.loadString(settingsName, 108, false)); - BytecodeViewer.viewer.panel1JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 109, false))); - BytecodeViewer.viewer.panel2JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 110, false))); - BytecodeViewer.viewer.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 111, false))); - BytecodeViewer.viewer.fontSpinner.setValue(Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 112, 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.panel3JDGUI_E.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 111, false))); + BytecodeViewer.viewer.fontSpinner.setValue(Integer.parseInt(DiskReader.loadString(settingsName, 112, false))); BytecodeViewer.deleteForeignLibraries = - Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 113, false)); - decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 114, false)); + Boolean.parseBoolean(DiskReader.loadString(settingsName, 113, false)); + decompiler = Integer.parseInt(DiskReader.loadString(settingsName, 114, false)); if (decompiler == 0) BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionDex.getModel(), true); else if (decompiler == 1) BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel(), true); - BytecodeViewer.python3 = DiskReader.loadString(BytecodeViewer.settingsName, 115, false); - BytecodeViewer.javac = DiskReader.loadString(BytecodeViewer.settingsName, 116, false); - BytecodeViewer.java = DiskReader.loadString(BytecodeViewer.settingsName, 117, false); - BytecodeViewer.viewer.compileOnSave.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 118, false))); - BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 119, false))); - BytecodeViewer.warnForEditing = Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, + BytecodeViewer.python3 = DiskReader.loadString(settingsName, 115, false); + BytecodeViewer.javac = DiskReader.loadString(settingsName, 116, false); + BytecodeViewer.java = DiskReader.loadString(settingsName, 117, false); + BytecodeViewer.viewer.compileOnSave.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 118, false))); + BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 119, false))); + BytecodeViewer.warnForEditing = Boolean.parseBoolean(DiskReader.loadString(settingsName, 120, false)); - BytecodeViewer.viewer.showFileInTabTitle.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 121, false))); + BytecodeViewer.viewer.showFileInTabTitle.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 121, false))); BytecodeViewer.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected(); - BytecodeViewer.viewer.forcePureAsciiAsText.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 122, false))); - BytecodeViewer.viewer.synchronizedViewing.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 123, false))); - BytecodeViewer.viewer.showClassMethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 124, false))); - BytecodeViewer.viewer.ren.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 125, 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.showClassMethods.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 124, false))); + BytecodeViewer.viewer.ren.setSelected(Boolean.parseBoolean(DiskReader.loadString(settingsName, 125, false))); } catch (Exception e) { //ignore because errors are expected, first start up and outdated settings. //e.printStackTrace(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java index c8b6a373..4365689b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java @@ -15,6 +15,8 @@ import the.bytecode.club.bytecodeviewer.decompilers.Decompilers; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.EZInjection; import the.bytecode.club.bytecodeviewer.util.JarUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -70,10 +72,7 @@ public class BytecodeViewer { */ public static List> loadClassesIntoClassLoader() { try { - File f = new File( - the.bytecode.club.bytecodeviewer.BytecodeViewer.tempDirectory + - the.bytecode.club.bytecodeviewer.BytecodeViewer.fs + - "loaded_temp.jar"); + File f = new File(tempDirectory + fs + "loaded_temp.jar"); JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), f.getAbsolutePath()); JarFile jarFile = new JarFile("" + f.getAbsolutePath()); Enumeration e = jarFile.entries(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java index 8df9e550..ba1bd772 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java @@ -11,6 +11,8 @@ import javax.swing.JTextArea; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -73,25 +75,23 @@ public class ExceptionUI extends JFrame { this.setIconImages(Resources.iconList); setSize(new Dimension(600, 400)); - setTitle("Bytecode Viewer " + BytecodeViewer.VERSION - + " - Stack Trace - Send this to " + author); + setTitle("Bytecode Viewer " + VERSION + " - Stack Trace - Send this to " + author); getContentPane().setLayout(new CardLayout(0, 0)); JTextArea txtrBytecodeViewerIs = new JTextArea(); txtrBytecodeViewerIs.setDisabledTextColor(Color.BLACK); txtrBytecodeViewerIs.setWrapStyleWord(true); - getContentPane().add(new JScrollPane(txtrBytecodeViewerIs), - "name_140466576080695"); + getContentPane().add(new JScrollPane(txtrBytecodeViewerIs), "name_140466576080695"); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - txtrBytecodeViewerIs.setText("Bytecode Viewer Version: " + BytecodeViewer.VERSION + - ", Preview Copy: " + BytecodeViewer.PREVIEW_COPY + - ", Fat Jar: " + BytecodeViewer.FAT_JAR + + txtrBytecodeViewerIs.setText("Bytecode Viewer Version: " + VERSION + + ", Preview Copy: " + PREVIEW_COPY + + ", Fat Jar: " + FAT_JAR + ", OS: " + System.getProperty("os.name") + ", Java: " + System.getProperty("java.version") + - BytecodeViewer.nl + BytecodeViewer.nl + sw); + nl + nl + sw); this.setLocationRelativeTo(null); this.setVisible(true); } @@ -99,15 +99,13 @@ public class ExceptionUI extends JFrame { private void setup(String e, String author) { this.setIconImages(Resources.iconList); setSize(new Dimension(600, 400)); - setTitle("Bytecode Viewer " + BytecodeViewer.VERSION - + " - Stack Trace - Send this to " + author); + setTitle("Bytecode Viewer " + VERSION + " - Stack Trace - Send this to " + author); getContentPane().setLayout(new CardLayout(0, 0)); JTextArea txtrBytecodeViewerIs = new JTextArea(); txtrBytecodeViewerIs.setDisabledTextColor(Color.BLACK); txtrBytecodeViewerIs.setWrapStyleWord(true); - getContentPane().add(new JScrollPane(txtrBytecodeViewerIs), - "name_140466576080695"); + getContentPane().add(new JScrollPane(txtrBytecodeViewerIs), "name_140466576080695"); txtrBytecodeViewerIs.setText(e); System.err.println(e); this.setLocationRelativeTo(null); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/JavaCompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/JavaCompiler.java index c5a6c5ee..edca690e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/JavaCompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/JavaCompiler.java @@ -10,6 +10,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -38,22 +40,18 @@ public class JavaCompiler extends Compiler { @Override public byte[] compile(String contents, String name) { - String fileStart = - BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(12) + BytecodeViewer.fs; - String fileStart2 = - BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(12) + BytecodeViewer.fs; - File java = new File(fileStart + BytecodeViewer.fs + name + ".java"); - File clazz = new File(fileStart2 + BytecodeViewer.fs + name + ".class"); - File cp = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "cpath_" + MiscUtils.randomString(12) + - ".jar"); - File tempD = new File(fileStart + BytecodeViewer.fs + name.substring(0, - name.length() - name.split("/")[name.split("/").length - 1].length())); + String fileStart = tempDirectory + fs + "temp" + MiscUtils.randomString(12) + fs; + String fileStart2 = tempDirectory + fs + "temp" + MiscUtils.randomString(12) + fs; + File java = new File(fileStart + fs + name + ".java"); + File clazz = new File(fileStart2 + fs + name + ".class"); + File cp = new File(tempDirectory + fs + "cpath_" + MiscUtils.randomString(12) + ".jar"); + File tempD = new File(fileStart + fs + name.substring(0, name.length() - name.split("/")[name.split("/").length - 1].length())); + tempD.mkdirs(); new File(fileStart2).mkdirs(); if (BytecodeViewer.javac.equals("") || !new File(BytecodeViewer.javac).exists()) { - BytecodeViewer.showMessage("You need to set your Javac path, this requires the JDK to be downloaded." + BytecodeViewer.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(); } @@ -116,20 +114,20 @@ public class JavaCompiler extends Compiler { BufferedReader br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl).append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl).append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); System.out.println(log); if (!clazz.exists()) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/KrakatauAssembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/KrakatauAssembler.java index bf06e800..294ddffd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/KrakatauAssembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/KrakatauAssembler.java @@ -6,9 +6,12 @@ import java.io.InputStream; import java.io.InputStreamReader; import me.konloch.kontainer.io.DiskWriter; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -50,18 +53,15 @@ public class KrakatauAssembler extends Compiler { name = MiscUtils.randomString(20); File tempD = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempD.mkdir(); - File tempJ = new File(tempD.getAbsolutePath() + BytecodeViewer.fs + name + ".j"); + File tempJ = new File(tempD.getAbsolutePath() + fs + name + ".j"); DiskWriter.replaceFile(tempJ.getAbsolutePath(), contents, true); - final File tempDirectory = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); - final File tempJar = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(32) + - ".jar"); + final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); BytecodeViewer.sm.stopBlocking(); @@ -70,7 +70,7 @@ public class KrakatauAssembler extends Compiler { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "assemble.py", + krakatauWorkingDirectory + fs + "assemble.py", "-out", tempDirectory.getAbsolutePath(), tempJ.getAbsolutePath() @@ -85,25 +85,25 @@ public class KrakatauAssembler extends Compiler { BufferedReader br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl).append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl).append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); int exitValue = process.waitFor(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); System.out.println(log); byte[] b = - org.apache.commons.io.FileUtils.readFileToByteArray(new File(tempDirectory.getAbsolutePath() + BytecodeViewer.fs + origName + ".class")); + org.apache.commons.io.FileUtils.readFileToByteArray(new File(tempDirectory.getAbsolutePath() + fs + origName + ".class")); tempDirectory.delete(); tempJar.delete(); return b; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java index fc7f9705..4b857f5e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java @@ -9,6 +9,8 @@ import the.bytecode.club.bytecodeviewer.util.Enjarify; import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -37,16 +39,16 @@ public class SmaliAssembler extends Compiler { @Override public byte[] compile(String contents, String name) { - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp"; + String fileStart = tempDirectory + fs + "temp"; int fileNumber = MiscUtils.getClassNumber(fileStart, ".dex"); - final File tempSmaliFolder = new File(fileStart + fileNumber + "-smalifolder" + BytecodeViewer.fs); + final File tempSmaliFolder = new File(fileStart + fileNumber + "-smalifolder" + fs); tempSmaliFolder.mkdir(); - File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + BytecodeViewer.fs + fileNumber + ".smali"); + File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + fs + fileNumber + ".smali"); File tempDex = new File("./out.dex"); File tempJar = new File(fileStart + fileNumber + ".jar"); - File tempJarFolder = new File(fileStart + fileNumber + "-jar" + BytecodeViewer.fs); + File tempJarFolder = new File(fileStart + fileNumber + "-jar" + fs); try { DiskWriter.replaceFile(tempSmali.getAbsolutePath(), contents, false); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java index 468cc831..091706bb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java @@ -20,6 +20,8 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -84,7 +86,7 @@ public class CFRDecompiler extends Decompiler { @Override public String decompileClassNode(ClassNode cn, byte[] b) { - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs.toLowerCase(); + String fileStart = tempDirectory + fs.toLowerCase(); String exception = ""; //final File tempClass = new File(windowsFun(MiscUtils.getUniqueName(fileStart, ".class") + ".class")); @@ -129,7 +131,7 @@ public class CFRDecompiler extends Decompiler { e.printStackTrace(); exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } tempClass.delete(); @@ -138,7 +140,7 @@ public class CFRDecompiler extends Decompiler { if (file.exists()) return findFile(Objects.requireNonNull(file.listFiles())); - return "CFR error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + return "CFR error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + nl + nl + exception; } Random r = new Random(); @@ -166,15 +168,15 @@ public class CFRDecompiler extends Decompiler { e.printStackTrace(); String exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; return "CFR error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail" - + ".com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, " - + "if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + + ".com" + nl + nl + "Suggested Fix: Click refresh class, " + + "if it fails again try another decompiler." + nl + nl + exception; } return s; } } - return "CFR error!" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it " + return "CFR error!" + nl + nl + "Suggested Fix: Click refresh class, if it " + "fails again try another decompiler."; } @@ -296,7 +298,7 @@ public class CFRDecompiler extends Decompiler { public void decompileToZip(String sourceJar, String zipName) { File tempZip = new File(sourceJar); - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs; + String fileStart = tempDirectory + fs; String fuckery = fuckery(fileStart); org.benf.cfr.reader.Main.main(generateMainMethod(tempZip.getAbsolutePath(), fuckery)); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/FernFlowerDecompiler.java index b8a62ec8..ba2f5582 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/FernFlowerDecompiler.java @@ -12,6 +12,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -42,17 +44,16 @@ public class FernFlowerDecompiler extends Decompiler { public void decompileToZip(String sourceJar, String zipName) { File tempZip = new File(sourceJar); - File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs); + File f = new File(tempDirectory + fs + "temp" + fs); f.mkdir(); try { - org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/")); + org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), tempDirectory + "./temp/")); } catch (StackOverflowError | Exception ignored) { } - File tempZip2 = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs + tempZip.getName()); + File tempZip2 = new File(tempDirectory + fs + "temp" + fs + tempZip.getName()); if (tempZip2.exists()) tempZip2.renameTo(new File(zipName)); @@ -61,33 +62,29 @@ public class FernFlowerDecompiler extends Decompiler { @Override public String decompileClassNode(final ClassNode cn, byte[] b) { - String start = BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.getUniqueName("", ".class"); + String start = tempDirectory + fs + MiscUtils.getUniqueName("", ".class"); final File tempClass = new File(start + ".class"); String exception = ""; try { final FileOutputStream fos = new FileOutputStream(tempClass); - fos.write(b); - fos.close(); } catch (final IOException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - - exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } - if (!BytecodeViewer.FAT_JAR) { + if (!FAT_JAR) { try { ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("fernflower")}, generateMainMethod(tempClass.getAbsolutePath(), - new File(BytecodeViewer.tempDirectory).getAbsolutePath()) + new File(tempDirectory).getAbsolutePath()) )); BytecodeViewer.sm.stopBlocking(); Process p = pb.start(); @@ -100,15 +97,12 @@ public class FernFlowerDecompiler extends Decompiler { } } else { try { - org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), - new File(BytecodeViewer.tempDirectory).getAbsolutePath())); + org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath())); } catch (StackOverflowError | Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - - exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } } @@ -119,19 +113,21 @@ public class FernFlowerDecompiler extends Decompiler { String s; try { s = DiskReader.loadAsString(outputJava.getAbsolutePath()); - + outputJava.delete(); - + return s; } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception += nl + nl + sw; } } - return "FernFlower error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + return "FernFlower error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + + nl + nl + exception; } private String[] generateMainMethod(String className, String folder) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JADXDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JADXDecompiler.java index 14f2c5e3..fd4e59ee 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JADXDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JADXDecompiler.java @@ -14,6 +14,8 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -40,16 +42,14 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils; public class JADXDecompiler extends Decompiler { @Override public String decompileClassNode(ClassNode cn, byte[] b) { - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs; + String fileStart = tempDirectory + fs; String exception = ""; final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class"); try { final FileOutputStream fos = new FileOutputStream(tempClass); - fos.write(b); - fos.close(); } catch (final IOException e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); @@ -68,9 +68,7 @@ public class JADXDecompiler extends Decompiler { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - - exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } tempClass.delete(); @@ -78,7 +76,9 @@ public class JADXDecompiler extends Decompiler { if (fuckery.exists()) return findFile(Objects.requireNonNull(fuckery.listFiles())); - return "JADX error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + return "JADX error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + + nl + nl + exception; } Random r = new Random(); @@ -104,17 +104,16 @@ public class JADXDecompiler extends Decompiler { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - - String exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + String exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + return "JADX error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail" - + ".com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, " - + "if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + + ".com" + nl + nl + "Suggested Fix: Click refresh class, " + + "if it fails again try another decompiler." + nl + nl + exception; } return s; } } - return "CFR error!" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it " + return "CFR error!" + nl + nl + "Suggested Fix: Click refresh class, if it " + "fails again try another decompiler."; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java index c70b3a0a..184aad1f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java @@ -14,8 +14,11 @@ import me.konloch.kontainer.io.DiskReader; import org.jd.core.v1.ClassFileToJavaSourceDecompiler; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -47,17 +50,17 @@ public class JDGUIDecompiler extends Decompiler { public String decompileClassNode(ClassNode cn, byte[] b) { String exception; try { - final File tempDirectory = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); - final File tempClass = new File(tempDirectory.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".class"); - final File tempJava = new File(tempDirectory.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".java"); + + final File tempClass = new File(tempDirectory.getAbsolutePath() + fs + cn.name + ".class"); + final File tempJava = new File(tempDirectory.getAbsolutePath() + fs + cn.name + ".java"); if (cn.name.contains("/")) { String[] raw = cn.name.split("/"); - String path = tempDirectory.getAbsolutePath() + BytecodeViewer.fs; + String path = tempDirectory.getAbsolutePath() + fs; for (int i = 0; i < raw.length - 1; i++) { - path += raw[i] + BytecodeViewer.fs; + path += raw[i] + fs; File f = new File(path); f.mkdir(); } @@ -65,19 +68,15 @@ public class JDGUIDecompiler extends Decompiler { try { final FileOutputStream fos = new FileOutputStream(tempClass); - fos.write(b); - fos.close(); } catch (final IOException e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } - String pathToClass = tempClass.getAbsolutePath().replace('/', File.separatorChar).replace('\\', - File.separatorChar); + String pathToClass = tempClass.getAbsolutePath().replace('/', File.separatorChar).replace('\\', File.separatorChar); String directoryPath = ClassFileUtil.ExtractDirectoryPath(pathToClass); - String internalPath = ClassFileUtil.ExtractInternalPath(directoryPath, pathToClass); CommonPreferences preferences = new CommonPreferences() { @@ -112,9 +111,12 @@ public class JDGUIDecompiler extends Decompiler { e.printStackTrace(); exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } - return "JD-GUI error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + + return "JD-GUI error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + + nl + nl + exception; } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java index 37ce392a..e8f0a11d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java @@ -9,9 +9,11 @@ import java.io.StringWriter; import me.konloch.kontainer.io.DiskReader; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -69,15 +71,15 @@ public class KrakatauDecompiler extends Decompiler { return "Set your paths"; } - String s = "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + - "Please send this to konloch@gmail.com. " + BytecodeViewer.nl + BytecodeViewer.nl; + String s = "Bytecode Viewer Version: " + VERSION + nl + nl + + "Please send this to konloch@gmail.com. " + nl + nl; BytecodeViewer.sm.stopBlocking(); try { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "decompile.py", + krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3 "-nauto", "-path", @@ -94,34 +96,33 @@ public class KrakatauDecompiler extends Decompiler { InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); - StringBuilder log = new StringBuilder("Process:" + BytecodeViewer.nl + BytecodeViewer.nl); + StringBuilder log = new StringBuilder("Process:" + nl + nl); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl) - .append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl).append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); int exitValue = process.waitFor(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); s = log.toString(); //if the motherfucker failed this'll fail, aka wont set. - s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".java"); + s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + fs + cn.name + ".java"); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += BytecodeViewer.nl + "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { BytecodeViewer.sm.setBlocking(); } @@ -151,24 +152,22 @@ public class KrakatauDecompiler extends Decompiler { return "Set your paths"; } - String s = "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + - "Please send this to konloch@gmail.com. " + BytecodeViewer.nl + BytecodeViewer.nl; + String s = "Bytecode Viewer Version: " + VERSION + nl + nl + + "Please send this to konloch@gmail.com. " + nl + nl; - final File tempDirectory = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); - final File tempJar = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(32) + - ".jar"); + final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); + JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - + BytecodeViewer.sm.stopBlocking(); try { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "decompile.py", + krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3 "-nauto", "-path", @@ -185,36 +184,36 @@ public class KrakatauDecompiler extends Decompiler { InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); - StringBuilder log = new StringBuilder("Process:" + BytecodeViewer.nl + BytecodeViewer.nl); + StringBuilder log = new StringBuilder("Process:" + nl + nl); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl) - .append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl) + .append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); int exitValue = process.waitFor(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); s = log.toString(); //if the motherfucker failed this'll fail, aka wont set. - s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".java"); + s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + fs + cn.name + ".java"); tempDirectory.delete(); tempJar.delete(); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += BytecodeViewer.nl + "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { BytecodeViewer.sm.setBlocking(); } @@ -236,7 +235,7 @@ public class KrakatauDecompiler extends Decompiler { } String ran = MiscUtils.randomString(32); - final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + ran + fs); tempDirectory.mkdir(); @@ -248,7 +247,7 @@ public class KrakatauDecompiler extends Decompiler { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "decompile.py", + krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3 "-nauto", "-path", diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDisassembler.java index f7283fed..d5207d7e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDisassembler.java @@ -9,10 +9,13 @@ import java.io.StringWriter; import me.konloch.kontainer.io.DiskReader; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -50,15 +53,15 @@ public class KrakatauDisassembler extends Decompiler { return "Set your paths"; } - String s = "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + - "Please send this to konloch@gmail.com. " + BytecodeViewer.nl + BytecodeViewer.nl; + String s = "Bytecode Viewer Version: " + VERSION + nl + nl + + "Please send this to konloch@gmail.com. " + nl + nl; BytecodeViewer.sm.stopBlocking(); try { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "disassemble.py", + krakatauWorkingDirectory + fs + "disassemble.py", "-path", krakatauTempJar.getAbsolutePath(), "-out", @@ -73,34 +76,34 @@ public class KrakatauDisassembler extends Decompiler { InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); - StringBuilder log = new StringBuilder("Process:" + BytecodeViewer.nl + BytecodeViewer.nl); + StringBuilder log = new StringBuilder("Process:" + nl + nl); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl) - .append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl) + .append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); int exitValue = process.waitFor(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); s = log.toString(); //if the motherfucker failed this'll fail, aka wont set. - s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".j"); + s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + fs + cn.name + ".j"); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += BytecodeViewer.nl + "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { BytecodeViewer.sm.setBlocking(); } @@ -119,15 +122,12 @@ public class KrakatauDisassembler extends Decompiler { return "Set your paths"; } - String s = "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + - "Please send this to konloch@gmail.com. " + BytecodeViewer.nl + BytecodeViewer.nl; + String s = "Bytecode Viewer Version: " + VERSION + nl + nl + + "Please send this to konloch@gmail.com. " + nl + nl; - final File tempDirectory = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); - final File tempJar = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils.randomString(32) + - ".jar"); + final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); BytecodeViewer.sm.stopBlocking(); @@ -135,7 +135,7 @@ public class KrakatauDisassembler extends Decompiler { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "disassemble.py", + krakatauWorkingDirectory + fs + "disassemble.py", "-path", tempJar.getAbsolutePath(), "-out", @@ -150,34 +150,33 @@ public class KrakatauDisassembler extends Decompiler { InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); - StringBuilder log = new StringBuilder("Process:" + BytecodeViewer.nl + BytecodeViewer.nl); + StringBuilder log = new StringBuilder("Process:" + nl + nl); String line; while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Error:").append(BytecodeViewer.nl) - .append(BytecodeViewer.nl); + log.append(nl).append(nl).append("Error:").append(nl).append(nl); is = process.getErrorStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ((line = br.readLine()) != null) { - log.append(BytecodeViewer.nl).append(line); + log.append(nl).append(line); } br.close(); int exitValue = process.waitFor(); - log.append(BytecodeViewer.nl).append(BytecodeViewer.nl).append("Exit Value is ").append(exitValue); + log.append(nl).append(nl).append("Exit Value is ").append(exitValue); s = log.toString(); //if the motherfucker failed this'll fail, aka wont set. - s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + BytecodeViewer.fs + cn.name + ".j"); + s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + fs + cn.name + ".j"); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += BytecodeViewer.nl + "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { BytecodeViewer.sm.setBlocking(); } @@ -192,7 +191,7 @@ public class KrakatauDisassembler extends Decompiler { } String ran = MiscUtils.randomString(32); - final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs); + final File tempDirectory = new File(Constants.tempDirectory + fs + ran + fs); tempDirectory.mkdir(); final File tempJar = new File(sourceJar); @@ -202,7 +201,7 @@ public class KrakatauDisassembler extends Decompiler { ProcessBuilder pb = new ProcessBuilder( BytecodeViewer.python, "-O", //love you storyyeller <3 - BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.fs + "disassemble.py", + krakatauWorkingDirectory + fs + "disassemble.py", "-path", BytecodeViewer.rt + ";" + tempJar.getAbsolutePath(), "-out", diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/ProcyonDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/ProcyonDecompiler.java index 4e8563fe..d223c983 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/ProcyonDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/ProcyonDecompiler.java @@ -35,6 +35,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.util.EncodeUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -59,39 +61,24 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils; * @author Konloch * @author DeathMarine */ - public class ProcyonDecompiler extends Decompiler { public DecompilerSettings getDecompilerSettings() { DecompilerSettings settings = new DecompilerSettings(); - settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6 - .isSelected()); - settings.setExcludeNestedTypes(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11 - .isSelected()); - settings.setShowDebugLineNumbers(BytecodeViewer.viewer.chckbxmntmShowDebugLine - .isSelected()); - settings.setIncludeLineNumbersInBytecode(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3 - .isSelected()); - settings.setIncludeErrorDiagnostics(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4 - .isSelected()); - settings.setShowSyntheticMembers(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7 - .isSelected()); - settings.setSimplifyMemberReferences(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences - .isSelected()); - settings.setMergeVariables(BytecodeViewer.viewer.mnMergeVariables - .isSelected()); - settings.setForceExplicitTypeArguments(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8 - .isSelected()); - settings.setForceExplicitImports(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9 - .isSelected()); - settings.setFlattenSwitchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10 - .isSelected()); - settings.setRetainPointlessSwitches(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2 - .isSelected()); - settings.setRetainRedundantCasts(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5 - .isSelected()); - settings.setUnicodeOutputEnabled(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1 - .isSelected()); + settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.isSelected()); + settings.setExcludeNestedTypes(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.isSelected()); + settings.setShowDebugLineNumbers(BytecodeViewer.viewer.chckbxmntmShowDebugLine.isSelected()); + settings.setIncludeLineNumbersInBytecode(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.isSelected()); + settings.setIncludeErrorDiagnostics(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.isSelected()); + settings.setShowSyntheticMembers(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.isSelected()); + settings.setSimplifyMemberReferences(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.isSelected()); + settings.setMergeVariables(BytecodeViewer.viewer.mnMergeVariables.isSelected()); + settings.setForceExplicitTypeArguments(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.isSelected()); + settings.setForceExplicitImports(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.isSelected()); + settings.setFlattenSwitchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.isSelected()); + settings.setRetainPointlessSwitches(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.isSelected()); + settings.setRetainRedundantCasts(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.isSelected()); + settings.setUnicodeOutputEnabled(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.isSelected()); settings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); return settings; } @@ -100,8 +87,7 @@ public class ProcyonDecompiler extends Decompiler { public String decompileClassNode(ClassNode cn, byte[] b) { String exception; try { - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs - + "temp"; + String fileStart = tempDirectory + fs + "temp"; final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class"); @@ -119,8 +105,7 @@ public class ProcyonDecompiler extends Decompiler { LuytenTypeLoader typeLoader = new LuytenTypeLoader(); MetadataSystem metadataSystem = new MetadataSystem(typeLoader); - TypeReference type = metadataSystem.lookupType(tempClass - .getCanonicalPath()); + TypeReference type = metadataSystem.lookupType(tempClass.getCanonicalPath()); DecompilationOptions decompilationOptions = new DecompilationOptions(); decompilationOptions.setSettings(settings); @@ -130,6 +115,7 @@ public class ProcyonDecompiler extends Decompiler { if (type == null || ((resolvedType = type.resolve()) == null)) { throw new Exception("Unable to resolve type."); } + StringWriter stringwriter = new StringWriter(); settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions); @@ -139,10 +125,11 @@ public class ProcyonDecompiler extends Decompiler { e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception = - "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } - return "Procyon error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + return "Procyon error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + + nl + nl + exception; } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java index ffd1a255..4d7d4847 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java @@ -14,6 +14,8 @@ import the.bytecode.club.bytecodeviewer.util.Dex2Jar; import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -42,7 +44,7 @@ public class SmaliDisassembler extends Decompiler { public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b) { String exception = ""; - String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp"; + String fileStart = tempDirectory + fs + "temp"; String start = MiscUtils.getUniqueName(fileStart, ".class"); @@ -71,7 +73,7 @@ public class SmaliDisassembler extends Decompiler { e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } File rename = new File(tempDex.getName().replaceFirst("\\.dex", "-out")); @@ -83,7 +85,7 @@ public class SmaliDisassembler extends Decompiler { e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } File outputSmali = null; @@ -107,12 +109,12 @@ public class SmaliDisassembler extends Decompiler { e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw; + exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } - return "Smali Disassembler error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail" - + ".com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails " - + "again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception; + return "Smali Disassembler error! Send the stacktrace to Konloch at https://the.bytecode.club or konloch@gmail.com" + + nl + nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + + nl + nl + exception; } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java index 46055a40..efd50ff6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java @@ -11,6 +11,8 @@ import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -65,21 +67,21 @@ public class ClassNodeDecompiler extends Decompiler { } } sb.append(" {"); - sb.append(BytecodeViewer.nl); + sb.append(nl); sb.append(" "); sb.append(""); - sb.append(BytecodeViewer.nl); + sb.append(nl); if (cn.sourceDebug != null) { sb.append(" "); sb.append(""); - sb.append(BytecodeViewer.nl); + sb.append(nl); } if (cn.sourceFile != null) { sb.append(" "); sb.append(""); - sb.append(BytecodeViewer.nl); + sb.append(nl); } if (cn.signature != null) { @@ -88,15 +90,15 @@ public class ClassNodeDecompiler extends Decompiler { } for (FieldNode fn : cn.fields) { - sb.append(BytecodeViewer.nl); + sb.append(nl); sb.append(" "); FieldNodeDecompiler.decompile(sb, fn); } if (cn.fields.size() > 0) { - sb.append(BytecodeViewer.nl); + sb.append(nl); } for (MethodNode mn : cn.methods) { - sb.append(BytecodeViewer.nl); + sb.append(nl); MethodNodeDecompiler.decompile(sb, mn, cn); } @@ -108,10 +110,10 @@ public class ClassNodeDecompiler extends Decompiler { ClassNode cn1 = BytecodeViewer.getClassNode(innerClassName); if (cn1 != null) { sb.appendPrefix(" "); - sb.append(BytecodeViewer.nl + BytecodeViewer.nl); + sb.append(nl + nl); sb = decompile(sb, decompiledClasses, cn1); sb.trimPrefix(5); - sb.append(BytecodeViewer.nl); + sb.append(nl); } else { unableToDecompile.add(innerClassName); } @@ -124,11 +126,11 @@ public class ClassNodeDecompiler extends Decompiler { sb.append(s); sb.append(" "); } - sb.append(BytecodeViewer.nl); + sb.append(nl); } if (cn.attrs != null) { - sb.append(BytecodeViewer.nl); + sb.append(nl); for (Attribute attr : cn.attrs) { //TODO: finish attributes sb.append(attr.type + ": ");// + attr.content.toString()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java index f14ab3a1..5c89a62b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java @@ -12,6 +12,8 @@ import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.TryCatchBlockNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -98,7 +100,7 @@ public class MethodNodeDecompiler { sb.append(" {}"); sb.append(" //"); sb.append(m.desc); - sb.append(BytecodeViewer.nl); + sb.append(nl); } else { sb.append(" {"); @@ -113,7 +115,7 @@ public class MethodNodeDecompiler { sb.append(" //"); sb.append(m.desc); - sb.append(BytecodeViewer.nl); + sb.append(nl); if (m.signature != null) { sb.append(" "); @@ -152,14 +154,14 @@ public class MethodNodeDecompiler { sb.append(o.type); else sb.append("Type is null."); - sb.append(BytecodeViewer.nl); + sb.append(nl); } for (String insn : insnPrinter.createPrint()) { sb.append(" "); sb.append(insn); - sb.append(BytecodeViewer.nl); + sb.append(nl); } - sb.append(" }" + BytecodeViewer.nl); + sb.append(" }" + nl); } return sb; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java index 07bd7755..fb97a1e7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java @@ -10,6 +10,9 @@ import javax.swing.JTextArea; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; +import static the.bytecode.club.bytecodeviewer.BytecodeViewer.*; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -44,7 +47,7 @@ public class AboutWindow extends JFrame { setTitle("Bytecode Viewer - About - https://bytecodeviewer.com | https://the.bytecode.club"); getContentPane().setLayout(new CardLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); - getContentPane().add(scrollPane, "name_322439757638784"); + getContentPane().add(scrollPane, "name_845520934713596"); textArea.setWrapStyleWord(true); textArea.setEnabled(false); textArea.setDisabledTextColor(Color.BLACK); @@ -57,39 +60,39 @@ public class AboutWindow extends JFrame { public void setVisible(boolean b) { super.setVisible(b); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue())); - textArea.setText("Bytecode Viewer " + BytecodeViewer.VERSION + " is an open source program developed and " + textArea.setText("Bytecode Viewer " + VERSION + " is an open source program developed and " + "maintained by Konloch (konloch@gmail.com) 100% free and open sourced licensed under GPL v3 " + "CopyLeft\r\n\r\n" + - "Settings:" + BytecodeViewer.nl + - " Preview Copy: " + BytecodeViewer.PREVIEW_COPY + BytecodeViewer.nl + - " Fat Jar: " + BytecodeViewer.FAT_JAR + BytecodeViewer.nl + - " Java: " + BytecodeViewer.java + BytecodeViewer.nl + - " Javac: " + BytecodeViewer.javac + BytecodeViewer.nl + - " BCV Dir: " + BytecodeViewer.getBCVDirectory() + BytecodeViewer.nl + - " Python 2.7 (or PyPy): " + BytecodeViewer.python + BytecodeViewer.nl + - " Python 3.X (or PyPy): " + BytecodeViewer.python3 + BytecodeViewer.nl + - " RT.jar:" + BytecodeViewer.rt + BytecodeViewer.nl + - " Optional Lib: " + BytecodeViewer.library + BytecodeViewer.nl + - " BCV Krakatau: v" + BytecodeViewer.krakatauVersion + BytecodeViewer.nl + - " Krakatau Dir: " + BytecodeViewer.krakatauWorkingDirectory + BytecodeViewer.nl + - " BCV Enjarify: v" + BytecodeViewer.enjarifyVersion + BytecodeViewer.nl + - " Enjarify Dir: " + BytecodeViewer.enjarifyWorkingDirectory + BytecodeViewer.nl + BytecodeViewer.nl + - "Command Line Input:" + BytecodeViewer.nl + - " -help Displays the help menu" + BytecodeViewer.nl + - " -list Displays the available decompilers" + BytecodeViewer.nl + - " -decompiler Selects the decompiler, procyon by default" + BytecodeViewer.nl + + "Settings:" + nl + + " Preview Copy: " + PREVIEW_COPY + nl + + " Fat Jar: " + FAT_JAR + nl + + " Java: " + java + nl + + " Javac: " + javac + nl + + " BCV Dir: " + getBCVDirectory() + nl + + " Python 2.7 (or PyPy): " + python + nl + + " Python 3.X (or PyPy): " + python3 + nl + + " RT.jar:" + rt + nl + + " Optional Lib: " + library + nl + + " BCV Krakatau: v" + krakatauVersion + nl + + " Krakatau Dir: " + krakatauWorkingDirectory + nl + + " BCV Enjarify: v" + enjarifyVersion + nl + + " Enjarify Dir: " + enjarifyWorkingDirectory + nl + nl + + "Command Line Input:" + nl + + " -help Displays the help menu" + nl + + " -list Displays the available decompilers" + nl + + " -decompiler Selects the decompiler, procyon by default" + nl + " -i Selects the input file (Jar, Class, APK, ZIP, DEX all work " - + "automatically)" + BytecodeViewer.nl + - " -o Selects the output file (Java or Java-Bytecode)" + BytecodeViewer.nl + + + "automatically)" + nl + + " -o Selects the output file (Java or Java-Bytecode)" + nl + " -t Must either be the fully qualified classname or \"all\" to decompile" - + " all as zip" + BytecodeViewer.nl + - " -nowait Doesn't wait for the user to read the CLI messages" + BytecodeViewer.nl + BytecodeViewer.nl + - "Keybinds:" + BytecodeViewer.nl + - " CTRL + O: Open/add new jar/class/apk" + BytecodeViewer.nl + - " CTLR + N: Reset the workspace" + BytecodeViewer.nl + - " CTRL + W: Closes the currently opened tab" + BytecodeViewer.nl + - " CTRL + T: Compile" + BytecodeViewer.nl + - " CTRL + S: Save classes as zip" + BytecodeViewer.nl + + + " all as zip" + nl + + " -nowait Doesn't wait for the user to read the CLI messages" + nl + nl + + "Keybinds:" + nl + + " CTRL + O: Open/add new jar/class/apk" + nl + + " CTLR + N: Reset the workspace" + nl + + " CTRL + W: Closes the currently opened tab" + nl + + " CTRL + T: Compile" + nl + + " CTRL + S: Save classes as zip" + nl + " CTRL + R: Run (EZ-Inject) - dynamically load the classes and invoke a main class" + "\r\n\r\nCode from various projects has been used, including but not limited to:\r\n J-RET by " + "WaterWolf\r\n JHexPane by Sam Koivu\r\n RSynaxPane by Robert Futrell\r\n Commons IO by " diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index 9af23202..04300dc8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -57,6 +57,7 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; import the.bytecode.club.bytecodeviewer.util.MiscUtils; +import static the.bytecode.club.bytecodeviewer.Constants.*; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -617,7 +618,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { ArrayList reopen = new ArrayList<>(); for (FileContainer container : BytecodeViewer.files) { - File newFile = new File(container.file.getParent() + BytecodeViewer.fs + container.name); + File newFile = new File(container.file.getParent() + fs + container.name); if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) && (container.file.getAbsolutePath().endsWith(".apk") || container.file.getAbsolutePath().endsWith(".dex"))) //APKs & dex get renamed { @@ -769,8 +770,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { Thread t16 = new Thread(() -> { BytecodeViewer.viewer.setIcon(true); - final String input = - BytecodeViewer.tempDirectory + BytecodeViewer.fs + BytecodeViewer.getRandomizedName() + ".jar"; + final String input = tempDirectory + fs + BytecodeViewer.getRandomizedName() + ".jar"; JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input); Thread t15 = new Thread(() -> { @@ -880,8 +880,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { Thread t14 = new Thread(() -> { BytecodeViewer.viewer.setIcon(true); - final String input = - BytecodeViewer.tempDirectory + BytecodeViewer.fs + BytecodeViewer.getRandomizedName() + ".jar"; + final String input = tempDirectory + fs + BytecodeViewer.getRandomizedName() + ".jar"; JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input); Thread t13 = new Thread(() -> { @@ -952,8 +951,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { final File javaSucks = file; - final String path = MiscUtils.append(file, ".zip"); // cheap hax cause - // string is final + final String path = MiscUtils.append(file, ".zip"); // cheap hax cause string is final JOptionPane pane = new JOptionPane( "What decompiler will you use?"); @@ -971,8 +969,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { BytecodeViewer.viewer.setIcon(true); - File tempZip = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar"); + File tempZip = new File(tempDirectory + fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar"); if (tempZip.exists()) tempZip.delete(); @@ -2001,11 +1998,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { mntmShowMainMethods.addActionListener(e -> PluginManager.runPlugin(new ShowMainMethods())); setSize(new Dimension(800, 400)); - if (BytecodeViewer.PREVIEW_COPY) - setTitle("Bytecode Viewer " + BytecodeViewer.VERSION + " Preview - https://bytecodeviewer.com | " + if (PREVIEW_COPY) + setTitle("Bytecode Viewer " + VERSION + " Preview - https://bytecodeviewer.com | " + "https://the.bytecode.club - @Konloch"); else - setTitle("Bytecode Viewer " + BytecodeViewer.VERSION + " - https://bytecodeviewer.com | https://the" + setTitle("Bytecode Viewer " + VERSION + " - https://bytecodeviewer.com | https://the" + ".bytecode.club - @Konloch"); getContentPane().setLayout( diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java index 41ff5be5..aa5388b8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java @@ -21,6 +21,8 @@ import javax.swing.text.JTextComponent; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -139,7 +141,7 @@ public class SystemErrConsole extends JFrame { String start = split[0] + "'" + split[1] + "', "; s = s.substring(start.length()); } - replace.append(s).append(BytecodeViewer.nl); + replace.append(s).append(nl); } setText(replace.toString()); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java index d51d7037..fcd8278b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java @@ -22,6 +22,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileContainer; +import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -111,7 +113,7 @@ public class WorkPane extends VisibleComponent implements ActionListener { @Override public void mousePressed(MouseEvent e) { if (e.getButton() == 3) { - if (BytecodeViewer.BLOCK_TAB_MENU) + if (BLOCK_TAB_MENU) return; Rectangle bounds = new Rectangle(1, 1, e.getX(), e.getY()); @@ -143,7 +145,7 @@ public class WorkPane extends VisibleComponent implements ActionListener { pop_up.add(closetab); - if (!BytecodeViewer.BLOCK_TAB_MENU) + if (!BLOCK_TAB_MENU) tabs.setComponentPopupMenu(pop_up); getContentPane().setLayout(new BorderLayout()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java index dc1fefd5..fe04efe0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java @@ -16,6 +16,8 @@ import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; import the.bytecode.club.bytecodeviewer.gui.GraphicalReflectionKit; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -273,8 +275,7 @@ public class EZInjection extends Plugin { the.bytecode.club.bytecodeviewer.api.BytecodeViewer .getClassNodeLoader().addClass(cn); - print("Invoking " + invokeMethodInformation + ":" - + BytecodeViewer.nl + BytecodeViewer.nl); + print("Invoking " + invokeMethodInformation + ":" + nl + nl); for (ClassNode classNode : classNodeList) { for (Object o : classNode.methods.toArray()) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/MaliciousCodeScanner.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/MaliciousCodeScanner.java index 781c1451..25d690a9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/MaliciousCodeScanner.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/MaliciousCodeScanner.java @@ -14,6 +14,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -80,7 +82,7 @@ public class MaliciousCodeScanner extends Plugin { || (LIP && s .matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) sb.append("Found LDC \"").append(s).append("\" at field ").append(classNode.name).append(".") - .append(f.name).append("(").append(f.desc).append(")").append(BytecodeViewer.nl); + .append(f.name).append("(").append(f.desc).append(")").append(nl); } if (v instanceof String[]) { for (int i = 0; i < ((String[]) v).length; i++) { @@ -96,7 +98,7 @@ public class MaliciousCodeScanner extends Plugin { .matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) sb.append("Found LDC \"").append(s).append("\" at field ").append(classNode.name) .append(".").append(f.name).append("(").append(f.desc).append(")") - .append(BytecodeViewer.nl); + .append(nl); } } } @@ -117,7 +119,7 @@ public class MaliciousCodeScanner extends Plugin { || (OIO && min.owner.startsWith("java/io"))) { sb.append("Found Method call to ").append(min.owner).append(".").append(min.name) .append("(").append(min.desc).append(") at ").append(classNode.name).append(".") - .append(m.name).append("(").append(m.desc).append(")").append(BytecodeViewer.nl); + .append(m.name).append("(").append(m.desc).append(")").append(nl); } } if (a instanceof LdcInsnNode) { @@ -134,7 +136,7 @@ public class MaliciousCodeScanner extends Plugin { .matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) { sb.append("Found LDC \"").append(s).append("\" at method ").append(classNode.name) .append(".").append(m.name).append("(").append(m.desc).append(")") - .append(BytecodeViewer.nl); + .append(nl); } } } @@ -152,7 +154,7 @@ public class MaliciousCodeScanner extends Plugin { .equals("setSecurityManager"))) { sb.append("Found Security Manager set to null at method ").append(classNode.name) .append(".").append(m.name).append("(").append(m.desc).append(")") - .append(BytecodeViewer.nl); + .append(nl); prevInsn_aconst_null = false; } } else { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java index 0c8a6fc9..0ce0eab1 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java @@ -11,6 +11,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -50,7 +52,7 @@ public class ShowAllStrings extends Plugin { if (!s.isEmpty()) sb.append(classNode.name).append(".").append(f.name).append(f.desc).append(" -> \"") .append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")) - .append("\"").append(BytecodeViewer.nl); + .append("\"").append(nl); } if (v instanceof String[]) { for (int i = 0; i < ((String[]) v).length; i++) { @@ -58,7 +60,7 @@ public class ShowAllStrings extends Plugin { if (!s.isEmpty()) sb.append(classNode.name).append(".").append(f.name).append(f.desc).append("[").append(i) .append("] -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")) - .append("\"").append(BytecodeViewer.nl); + .append("\"").append(nl); } } } @@ -74,7 +76,7 @@ public class ShowAllStrings extends Plugin { if (!s.isEmpty()) sb.append(classNode.name).append(".").append(m.name).append(m.desc).append(" -> \"") .append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")) - .append("\"").append(BytecodeViewer.nl); + .append("\"").append(nl); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java index 275ba8ad..a45b0d6f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ZStringArrayDecrypter.java @@ -11,6 +11,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -44,8 +46,8 @@ public class ZStringArrayDecrypter extends Plugin { @Override public void execute(ArrayList classNodeList) { JOptionPane pane = new JOptionPane( - "WARNING: This will load the classes into the JVM and execute the initialize function" + BytecodeViewer.nl + - "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE." + "WARNING: This will load the classes into the JVM and execute the initialize function" + + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE." ); Object[] options = new String[]{"Continue", "Cancel"}; pane.setOptions(options); @@ -66,12 +68,12 @@ public class ZStringArrayDecrypter extends Plugin { Field[] fields = debug.getDeclaredFields(); for (Field field : fields) { if (field.getName().equals("z")) { - out.append(debug.getName()).append(":").append(BytecodeViewer.nl); + out.append(debug.getName()).append(":").append(nl); field.setAccessible(true); if (field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) { String[] fieldVal = (String[]) field.get(null); for (int i = 0; i < fieldVal.length; i++) { - out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(BytecodeViewer.nl); + out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(nl); } } } @@ -84,7 +86,8 @@ public class ZStringArrayDecrypter extends Plugin { } if (needsWarning) { - BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them" + BytecodeViewer.nl + "makes sure you include ALL the libraries it requires."); + BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them" + + nl + "makes sure you include ALL the libraries it requires."); } gui.setText(out.toString()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java index f421ba94..080ec7a8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java @@ -4,6 +4,8 @@ import java.io.File; import org.apache.commons.io.FileUtils; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -29,16 +31,15 @@ public class APKTool { public static synchronized void decodeResources(File input, File output, FileContainer container) { try { - File dir = - new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(32) + BytecodeViewer.fs + "Decoded Resources"); + File dir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs + "Decoded Resources"); dir.mkdirs(); - File tempAPKPath = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(12)); + File tempAPKPath = new File(tempDirectory + fs + MiscUtils.randomString(12)); tempAPKPath.mkdirs(); brut.apktool.Main.main(new String[]{"r", "--frame-path", tempAPKPath.getAbsolutePath(), "d", input.getAbsolutePath(), "-o", dir.getAbsolutePath(), "-f"}); - File zip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(12) + ".zip"); + File zip = new File(tempDirectory + fs + MiscUtils.randomString(12) + ".zip"); ZipUtils.zipFolderAPKTool(dir.getAbsolutePath(), zip.getAbsolutePath()); if (zip.exists()) @@ -52,16 +53,16 @@ public class APKTool { } public static synchronized void buildAPK(File input, File output, FileContainer container) { - String temp = BytecodeViewer.tempDirectory + BytecodeViewer.fs; - File tempDir = new File(temp + BytecodeViewer.fs + BytecodeViewer.getRandomizedName() + BytecodeViewer.fs); + String temp = tempDirectory + fs; + File tempDir = new File(temp + fs + BytecodeViewer.getRandomizedName() + fs); tempDir.mkdirs(); - File tempAPKPath = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(12)); + File tempAPKPath = new File(tempDirectory + fs + MiscUtils.randomString(12)); tempAPKPath.mkdirs(); try { - File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + BytecodeViewer.fs + "smali"); + File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + fs + "smali"); FileUtils.deleteDirectory(smaliFolder); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/BootCheck.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/BootCheck.java new file mode 100644 index 00000000..651bd2b6 --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/BootCheck.java @@ -0,0 +1,100 @@ +package the.bytecode.club.bytecodeviewer.util; + +import the.bytecode.club.bootloader.Boot; +import the.bytecode.club.bootloader.ILoader; +import the.bytecode.club.bootloader.resource.EmptyExternalResource; +import the.bytecode.club.bootloader.resource.ExternalResource; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.CommandLineInput; + +import javax.swing.*; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static the.bytecode.club.bytecodeviewer.Constants.nl; + +/** + * @author Konloch + * @since 6/21/2021 + */ +public class BootCheck implements Runnable +{ + boolean finished = false; + + @Override + @SuppressWarnings({"rawtypes", "unchecked"}) + public void run() { + long start = System.currentTimeMillis(); + + while (!finished) { + if (System.currentTimeMillis() - start >= 7000) { //7 second failsafe + if (!Boot.completedboot && !Boot.downloading) { + File libsDir = Boot.libsDir(); + File[] listFiles = libsDir.listFiles(); + if (listFiles == null || listFiles.length <= 0) { + BytecodeViewer.showMessage( + "Github is loading extremely slow, BCV needs to download libraries from github in" + + " order" + nl + + "to work, please try adjusting your network settings or manually " + + "downloading these libraries" + nl + + "if this error persists."); + finished = true; + return; + } + + Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Unable to connect to github, " + + "force booting..."); + System.out.println("Unable to connect to github, force booting..."); + List libsFileList = new ArrayList<>(); + for (File f : listFiles) { + libsFileList.add(f.getAbsolutePath()); + } + + ILoader loader = Boot.findLoader(); + + for (String s : libsFileList) { + if (s.endsWith(".jar")) { + File f = new File(s); + if (f.exists()) { + Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Force Loading Library" + + " " + f.getName()); + System.out.println("Force loading library " + f.getName()); + + try { + ExternalResource res = new EmptyExternalResource<>(f.toURI().toURL()); + loader.bind(res); + System.out.println("Successfully loaded " + f.getName()); + } catch (Exception e) { + e.printStackTrace(); + f.delete(); + JOptionPane.showMessageDialog(null, "Error, Library " + f.getName() + " is " + + "corrupt, please restart to redownload it.", + "Error", JOptionPane.ERROR_MESSAGE); + } + } + } + } + + Boot.checkEnjarify(); + Boot.checkKrakatau(); + + Boot.globalstop = false; + Boot.hide(); + + if (CommandLineInput.parseCommandLine(BytecodeViewer.args) == CommandLineInput.OPEN_FILE) + BytecodeViewer.BOOT(false); + else { + BytecodeViewer.BOOT(true); + CommandLineInput.executeCommandLine(BytecodeViewer.args); + } + } + finished = true; + } + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } + } + } +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java index f586ba1d..d16cb111 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java @@ -3,6 +3,8 @@ package the.bytecode.club.bytecodeviewer.util; import java.io.File; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import static the.bytecode.club.bytecodeviewer.Constants.enjarifyWorkingDirectory; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -59,7 +61,7 @@ public class Enjarify { "-f" ); - pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory)); + pb.directory(new File(enjarifyWorkingDirectory)); Process process = pb.start(); BytecodeViewer.createdProcesses.add(process); process.waitFor(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/JarUtils.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/JarUtils.java index 661dc16b..ffb33a59 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/JarUtils.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/JarUtils.java @@ -22,6 +22,8 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import static the.bytecode.club.bytecodeviewer.Constants.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -331,7 +333,7 @@ public class JarUtils { ClassWriter cw = new ClassWriter(0); cn.accept(cw); - String name = dir + BytecodeViewer.fs + cn.name + ".class"; + String name = dir + fs + cn.name + ".class"; File f = new File(name); f.mkdirs(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java new file mode 100644 index 00000000..df838533 --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java @@ -0,0 +1,220 @@ +package the.bytecode.club.bytecodeviewer.util; + +import org.apache.commons.io.FileUtils; +import org.objectweb.asm.tree.ClassNode; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.api.ExceptionUI; +import the.bytecode.club.bytecodeviewer.gui.FileNavigationPane; +import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Objects; + +import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; +import static the.bytecode.club.bytecodeviewer.Constants.fs; + +/*************************************************************************** + * 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 . * + ***************************************************************************/ + +/** + * @author Konloch + */ +public class OpenFile implements Runnable +{ + private boolean update = true; + private final File[] files; + + public OpenFile(File[] files) {this.files = files;} + + @Override + public void run() + { + try { + for (final File f : files) { + final String fn = f.getName(); + if (!f.exists()) { + update = false; + BytecodeViewer.showMessage("The file " + f.getAbsolutePath() + " could not be found."); + } else { + if (f.isDirectory()) { + FileContainer container = new FileContainer(f); + HashMap files1 = new HashMap<>(); + boolean finished = false; + ArrayList totalFiles = new ArrayList<>(); + totalFiles.add(f); + String dir = f.getAbsolutePath();//f.getAbsolutePath().substring(0, f.getAbsolutePath + // ().length()-f.getName().length()); + + while (!finished) { + boolean added = false; + for (int i = 0; i < totalFiles.size(); i++) { + File child = totalFiles.get(i); + if (child.listFiles() != null) + for (File rocket : Objects.requireNonNull(child.listFiles())) + if (!totalFiles.contains(rocket)) { + totalFiles.add(rocket); + added = true; + } + } + + if (!added) { + for (File child : totalFiles) + if (child.isFile()) { + String fileName = child.getAbsolutePath().substring(dir.length() + 1 + ).replaceAll("\\\\", "\\/"); + + + files1.put(fileName, + Files.readAllBytes(Paths.get(child.getAbsolutePath()))); + } + finished = true; + } + } + container.files = files1; + BytecodeViewer.files.add(container); + } else { + if (fn.endsWith(".jar") || fn.endsWith(".zip") || fn.endsWith(".war")) { + try { + JarUtils.put(f); + } catch (IOException z) { + try { + JarUtils.put2(f); + } catch (final Exception e) { + new ExceptionUI(e); + update = false; + } + } catch (final Exception e) { + new ExceptionUI(e); + update = false; + } + + } else if (fn.endsWith(".class")) { + try { + byte[] bytes = JarUtils.getBytes(new FileInputStream(f)); + String cafebabe = String.format("%02X", bytes[0]) + String.format("%02X", + bytes[1]) + String.format("%02X", bytes[2]) + String.format("%02X", + bytes[3]); + if (cafebabe.equalsIgnoreCase("cafebabe")) { + final ClassNode cn = JarUtils.getNode(bytes); + + FileContainer container = new FileContainer(f); + container.classes.add(cn); + BytecodeViewer.files.add(container); + } else { + BytecodeViewer.showMessage(fn + ": Header does not start with CAFEBABE, ignoring."); + update = false; + } + } catch (final Exception e) { + new ExceptionUI(e); + update = false; + } + } else if (fn.endsWith(".apk")) { + try { + BytecodeViewer.viewer.setIcon(true); + + File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); + + FileUtils.copyFile(f, tempCopy); + + FileContainer container = new FileContainer(tempCopy, f.getName()); + + if (BytecodeViewer.viewer.decodeAPKResources.isSelected()) { + File decodedResources = + new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); + APKTool.decodeResources(tempCopy, decodedResources, container); + container.files = JarUtils.loadResources(decodedResources); + } + + Objects.requireNonNull(container.files).putAll(JarUtils.loadResources(tempCopy)); //copy and rename + // to prevent unicode filenames + + String name = BytecodeViewer.getRandomizedName() + ".jar"; + File output = new File(tempDirectory + fs + name); + + if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.dex2Jar(tempCopy, output); + else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.apk2Jar(tempCopy, output); + + container.classes = JarUtils.loadClasses(output); + + BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.files.add(container); + } catch (final Exception e) { + new ExceptionUI(e); + } + return; + } else if (fn.endsWith(".dex")) { + try { + BytecodeViewer.viewer.setIcon(true); + + File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + + ".dex"); + + FileUtils.copyFile(f, tempCopy); //copy and rename to prevent unicode filenames + + FileContainer container = new FileContainer(tempCopy, f.getName()); + + String name = BytecodeViewer.getRandomizedName() + ".jar"; + File output = new File(tempDirectory + fs + name); + + if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.dex2Jar(tempCopy, output); + else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.apk2Jar(tempCopy, output); + + container.classes = JarUtils.loadClasses(output); + + BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.files.add(container); + } catch (final Exception e) { + new ExceptionUI(e); + } + return; + } else { + HashMap files1 = new HashMap<>(); + byte[] bytes = JarUtils.getBytes(new FileInputStream(f)); + files1.put(f.getName(), bytes); + + + FileContainer container = new FileContainer(f); + container.files = files1; + BytecodeViewer.files.add(container); + } + } + } + } + } catch (final Exception e) { + new ExceptionUI(e); + } finally { + BytecodeViewer.viewer.setIcon(false); + + if (update) + try { + Objects.requireNonNull(MainViewerGUI.getComponent(FileNavigationPane.class)).updateTree(); + } catch (NullPointerException ignored) { + } + } + } +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/SecurityMan.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java similarity index 98% rename from src/main/java/the/bytecode/club/bytecodeviewer/SecurityMan.java rename to src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java index 18c2d8a9..22098594 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/SecurityMan.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java @@ -1,4 +1,6 @@ -package the.bytecode.club.bytecodeviewer; +package the.bytecode.club.bytecodeviewer.util; + +import the.bytecode.club.bytecodeviewer.BytecodeViewer; import java.io.FileDescriptor; import java.net.InetAddress; @@ -103,7 +105,6 @@ public class SecurityMan extends SecurityManager { public void checkAccess(ThreadGroup g) { } - @Override public void checkAwtEventQueueAccess() { } @@ -134,7 +135,6 @@ public class SecurityMan extends SecurityManager { public void checkLink(String lib) { } - @Override public void checkMemberAccess(Class clazz, int which) { } @@ -146,7 +146,6 @@ public class SecurityMan extends SecurityManager { public void checkMulticast(InetAddress maddr, byte ttl) { } - @Override public void checkPackageAccess(String pkg) { } @@ -186,7 +185,6 @@ public class SecurityMan extends SecurityManager { public void checkSetFactory() { } - @Override public void checkSystemClipboardAccess() { } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java new file mode 100644 index 00000000..0da6fd90 --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java @@ -0,0 +1,221 @@ +package the.bytecode.club.bytecodeviewer.util; + +import me.konloch.kontainer.io.HTTPRequest; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.api.ExceptionUI; + +import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import java.awt.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; + +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 . * + ***************************************************************************/ + + +/** + * @author Konloch + */ +public class VersionChecker implements Runnable +{ + @Override + public void run() + { + try { + HTTPRequest r = new HTTPRequest(new URL("https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/VERSION")); + final String version = r.readSingle(); + final String localVersion = VERSION + 0; + try { + int simplemaths = Integer.parseInt(version.replace(".", "")); + int simplemaths2 = Integer.parseInt(localVersion.replace(".", "")); + System.out.println("DEBUG: " + simplemaths + " vs " + simplemaths2); + if (simplemaths2 > simplemaths) + return; //developer version + } catch (Exception ignored) { + + } + + if (!VERSION.equals(version)) { + JOptionPane pane = new JOptionPane( + "Your version: " + VERSION + ", latest version: " + + version + nl + "What would you like to do?"); + Object[] options = new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"}; + pane.setOptions(options); + JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Outdated Version"); + dialog.setVisible(true); + Object obj = pane.getValue(); + int result = -1; + for (int k = 0; k < options.length; k++) + if (options[k].equals(obj)) + result = k; + + if (result == 0) { + if (Desktop.isDesktopSupported()) { + Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases")); + } else { + BytecodeViewer.showMessage("Cannot open the page, please manually type it." + nl + "https://github.com/Konloch/bytecode-viewer/releases"); + } + } + if (result == 1) { + JFileChooser fc = new JFileChooser(); + try { + fc.setCurrentDirectory(new File(".").getAbsoluteFile()); //set the current working directory + } catch (Exception e) { + new ExceptionUI(e); + } + fc.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + return f.isDirectory() || MiscUtils.extension(f.getAbsolutePath()).equals("zip"); + } + + @Override + public String getDescription() { + return "Zip Archives"; + } + }); + fc.setFileHidingEnabled(false); + fc.setAcceptAllFileFilterUsed(false); + int returnVal = fc.showSaveDialog(BytecodeViewer.viewer); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + if (!file.getAbsolutePath().endsWith(".zip")) + file = new File(file.getAbsolutePath() + ".zip"); + + if (file.exists()) { + pane = new JOptionPane("The file " + file + " exists, would you like to overwrite it?"); + options = new String[]{"Yes", "No"}; + pane.setOptions(options); + dialog = pane.createDialog(BytecodeViewer.viewer, + "Bytecode Viewer - Overwrite File"); + dialog.setVisible(true); + obj = pane.getValue(); + result = -1; + for (int k = 0; k < options.length; k++) + if (options[k].equals(obj)) + result = k; + + if (result != 0) + return; + + file.delete(); + } + + final File finalFile = file; + Thread downloadThread = new Thread(() -> { + try { + InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip").openConnection().getInputStream(); + FileOutputStream fos = new FileOutputStream(finalFile); + try { + System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip"); + byte[] buffer = new byte[8192]; + int len; + int downloaded = 0; + boolean flag = false; + BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished " + + "you will be alerted with another message box." + nl + nl + + "Expect this to take several minutes."); + while ((len = is.read(buffer)) > 0) { + fos.write(buffer, 0, len); + fos.flush(); + downloaded += 8192; + int mbs = downloaded / 1048576; + if (mbs % 5 == 0 && mbs != 0) { + if (!flag) + System.out.println("Downloaded " + mbs + "MBs so far"); + flag = true; + } else + flag = false; + } + } finally { + try { + if (is != null) { + is.close(); + } + } finally { + fos.flush(); + fos.close(); + } + } + System.out.println("Download finished!"); + BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + try { + InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar" + ).openConnection().getInputStream(); + FileOutputStream fos = new FileOutputStream(finalFile); + try { + System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar"); + byte[] buffer = new byte[8192]; + int len; + int downloaded = 0; + boolean flag = false; + BytecodeViewer.showMessage("Downloading the jar in the background, when it's " + + "finished you will be alerted with another message box." + nl + nl + "Expect this to take several minutes."); + while ((len = is.read(buffer)) > 0) { + fos.write(buffer, 0, len); + fos.flush(); + downloaded += 8192; + int mbs = downloaded / 1048576; + if (mbs % 5 == 0 && mbs != 0) { + if (!flag) + System.out.println("Downloaded " + mbs + "MBs so far"); + flag = true; + } else + flag = false; + } + } finally { + try { + if (is != null) { + is.close(); + } + } finally { + fos.flush(); + fos.close(); + } + } + System.out.println("Download finished!"); + BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath()); + } catch (FileNotFoundException ex) { + BytecodeViewer.showMessage("Unable to download, the zip file has not been uploaded yet, " + + "please try again in about 10 minutes."); + } catch (Exception ex) { + new ExceptionUI(ex); + } + + } catch (Exception e) { + new ExceptionUI(e); + } + + }); + downloadThread.start(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +}