diff --git a/BytecodeViewer 2.9.7-preview.jar b/BytecodeViewer 2.9.7-preview.jar index 9fd7f0dd..22e1ef76 100644 Binary files a/BytecodeViewer 2.9.7-preview.jar and b/BytecodeViewer 2.9.7-preview.jar differ diff --git a/src/krakatau.zip b/src/krakatau.zip deleted file mode 100644 index 652f292e..00000000 Binary files a/src/krakatau.zip and /dev/null differ diff --git a/src/org/objectweb/asm/commons/util/JarArchive.java b/src/org/objectweb/asm/commons/util/JarArchive.java index 8d423786..d555a9b0 100644 --- a/src/org/objectweb/asm/commons/util/JarArchive.java +++ b/src/org/objectweb/asm/commons/util/JarArchive.java @@ -32,8 +32,9 @@ public class JarArchive { public Map build() { if (!nodes.isEmpty()) return nodes; + JarFile jar = null; try { - JarFile jar = new JarFile(file); + jar = new JarFile(file); manifest = jar.getManifest(); Enumeration entries = jar.entries(); while (entries.hasMoreElements()) { @@ -48,6 +49,12 @@ public class JarArchive { } } catch (IOException e) { throw new RuntimeException("Error building classes (" + file.getName() + "): ", e.getCause()); + } finally { + try { + if(jar != null) + jar.close(); + } catch (IOException e) { + } } return nodes; } diff --git a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index f7540459..6d21a165 100644 --- a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -43,12 +43,10 @@ import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer; import the.bytecode.club.bytecodeviewer.plugin.PluginManager; /** - * A lightweight Java Reverse Engineering suite, developed by Konloch - - * http://konloch.me + * A lightweight Java Reverse Engineering suite, developed by Konloch - http://konloch.me * - * 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. + * 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 * @@ -91,13 +89,17 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager; * refresh appears under panes that are non refreshable * make ez-injection plugin console show all sys.out calls * edit then save issues? - * Search open doesnt append .class to tab name + * Search open doesn't append .class to tab name * * -----2.9.7-----: * 07/02/2015 - Added ajustable font size. * 07/05/2015 - Started working on the new Boot Screen. * 07/06/2015 - Moved the font size to be under the view menu. * 07/06/2015 - Fixed a bug with plugins not being able to grab the currently viewed class. + * 07/07/2015 - Started adding enjarify as an optional APK converter instead of Dex2Jar. + * 07/07/2015 - Finished the new Boot Screen + * 07/09/2015 - Fixed a process leak with krakatau decompiler. + * 07/09/2015 - Finished adding enjarify. * * @author Konloch * @@ -107,14 +109,15 @@ public class BytecodeViewer { /*per version*/ public static String version = "2.9.7"; - public static String krakatauVersion = "2"; + public static boolean previewCopy = true; /*the rest*/ 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 String python = ""; + public static String python3 = ""; public static String rt = ""; public static String library = ""; - public static SecurityMan sm = new SecurityMan(); + public static SecurityMan sm = new SecurityMan(); //might be insecure due to assholes targeting BCV, however that's highly unlikely. public static HashMap loadedClasses = new HashMap(); public static HashMap loadedResources = new HashMap(); private static int maxRecentFiles = 25; @@ -126,13 +129,17 @@ public class BytecodeViewer { 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 + fs + "Krakatau-master"; + public static String krakatauWorkingDirectory = ""; + public static String krakatauVersion = ""; + public static String enjarifyWorkingDirectory = ""; + public static String enjarifyVersion = ""; private static ArrayList recentFiles = DiskReader.loadArrayList(filesName, false); private static ArrayList recentPlugins = DiskReader.loadArrayList(pluginsName, false); public static boolean runningObfuscation = false; private static long start = System.currentTimeMillis(); public static String lastDirectory = ""; public static ArrayList krakatau = new ArrayList(); + public static ArrayList enjarify = new ArrayList(); public static Refactorer refactorer = new Refactorer(); public static boolean pingback = false; public static boolean deleteForiegnLibraries = true; @@ -303,7 +310,7 @@ public class BytecodeViewer { try { new HTTPRequest(new URL("https://bytecodeviewer.com/add.php")).read(); } catch(Exception e) { - //ignore + pingback = false; } } }; @@ -356,6 +363,9 @@ public class BytecodeViewer { System.setSecurityManager(sm); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + if(previewCopy) + showMessage("WARNING: This is a preview/dev copy, you WON'T be alerted when 2.9.7 is actually out if you use this."+nl+ + "Make sure to watch the repo: https://github.com/Konloch/bytecode-viewer for 2.9.7's release"); new BootScreen().DO_FIRST_BOOT(args); } catch (Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); @@ -363,7 +373,6 @@ public class BytecodeViewer { } public static void BOOT(String[] args) { - checkKrakatau(); System.out.println("https://the.bytecode.club - Created by @Konloch - Bytecode Viewer " + version); cleanup(); Runtime.getRuntime().addShutdownHook(new Thread() { @@ -371,6 +380,8 @@ public class BytecodeViewer { public void run() { for(Process krakatau : krakatau) krakatau.destroy(); + for(Process enjarify : enjarify) + enjarify.destroy(); Settings.saveGUI(); cleanup(); } @@ -558,33 +569,6 @@ public class BytecodeViewer { return true; } - - /** - * Drops the latest krakatau safely - */ - public static void checkKrakatau() { - File krakatauDirectory = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion); - if(!krakatauDirectory.exists()) { - try { - File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip"); - while(temp.exists()) - temp.delete(); - InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("krakatau.zip"); - FileOutputStream baos = new FileOutputStream(temp); - int r = 0; - byte[] buffer = new byte[8192]; - while((r=is.read(buffer))>=0) { - baos.write(buffer, 0, r); - } - baos.close(); - ZipUtils.unzipFilesToPath(temp.getAbsolutePath(), krakatauDirectory.getAbsolutePath()); - temp.delete(); - } catch(Exception e) { - showMessage("ERROR: There was an issue unzipping Krakatau decompiler, please contact @Konloch with your stacktrace."); - new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); - } - } - } private static boolean update = true; @@ -653,7 +637,12 @@ public class BytecodeViewer { String name = getRandomizedName()+".jar"; File output = new File(tempDirectory + fs + name); - Dex2Jar.dex2Jar(f, output); + + if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.dex2Jar(f, output); + else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.apk2Jar(f, output); + BytecodeViewer.viewer.setIcon(false); openFiles(new File[]{output}, false); } catch (final Exception e) { @@ -664,7 +653,12 @@ public class BytecodeViewer { try { String name = getRandomizedName()+".jar"; File output = new File(tempDirectory + fs + name); - Dex2Jar.dex2Jar(f, output); + + if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.dex2Jar(f, output); + else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.apk2Jar(f, output); + BytecodeViewer.viewer.setIcon(false); openFiles(new File[]{output}, false); } catch (final Exception e) { diff --git a/src/the/bytecode/club/bytecodeviewer/Enjarify.java b/src/the/bytecode/club/bytecodeviewer/Enjarify.java new file mode 100644 index 00000000..472a5d1c --- /dev/null +++ b/src/the/bytecode/club/bytecodeviewer/Enjarify.java @@ -0,0 +1,128 @@ +package the.bytecode.club.bytecodeviewer; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * A simple wrapper for Enjarify. + * + * @author Konloch + * + */ + +public class Enjarify { + + /** + * Converts a .apk or .dex to .jar + * @param input the input .apk or .dex file + * @param output the output .jar file + */ + public static synchronized void apk2Jar(File input, File output) { + if(BytecodeViewer.python3.equals("")) { + BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path."); + BytecodeViewer.viewer.pythonC3(); + } + + BytecodeViewer.sm.blocking = false; + try { + ProcessBuilder pb = new ProcessBuilder( + BytecodeViewer.python3, + "-O", + "-m", + "enjarify.main", + input.getAbsolutePath(), + "-o", + output.getAbsolutePath() + ); + + pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory)); + + Process process = pb.start(); + BytecodeViewer.enjarify.add(process); + + //Read out dir output + InputStream is = process.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line; + while ((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + is = process.getErrorStream(); + isr = new InputStreamReader(is); + br = new BufferedReader(isr); + while ((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + int exitValue = process.waitFor(); + System.out.println("Exit Value is " + exitValue); + + } catch(Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + } + + BytecodeViewer.sm.blocking = true; + } + + /** + * Converts a .jar to .dex + * @param input the input .jar file + * @param output the output .dex file + */ + public static synchronized void saveAsAPK(File input, File output) { + if(BytecodeViewer.python3.equals("")) { + BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path."); + BytecodeViewer.viewer.pythonC3(); + } + + BytecodeViewer.sm.blocking = false; + try { + ProcessBuilder pb = new ProcessBuilder( + BytecodeViewer.python3, + "-O", + "-m", + "enjarify.main", + input.getAbsolutePath(), + "-o", + output.getAbsolutePath() + ); + pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory)); + + + Process process = pb.start(); + BytecodeViewer.enjarify.add(process); + + //Read out dir output + InputStream is = process.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line; + while ((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + is = process.getErrorStream(); + isr = new InputStreamReader(is); + br = new BufferedReader(isr); + while ((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + int exitValue = process.waitFor(); + System.out.println("Exit Value is " + exitValue); + + } catch(Exception e) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + } + + BytecodeViewer.sm.blocking = true; + } +} diff --git a/src/the/bytecode/club/bytecodeviewer/Settings.java b/src/the/bytecode/club/bytecodeviewer/Settings.java index 570c344c..cfc593a1 100644 --- a/src/the/bytecode/club/bytecodeviewer/Settings.java +++ b/src/the/bytecode/club/bytecodeviewer/Settings.java @@ -194,6 +194,7 @@ public class Settings { DiskWriter.writeNewLine(BytecodeViewer.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); } catch(Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } @@ -387,6 +388,7 @@ public class Settings { 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); } catch(Exception e) { //ignore because errors are expected, first start up and outdated settings. //e.printStackTrace(); diff --git a/src/the/bytecode/club/bytecodeviewer/api/ASMUtil_OLD.java b/src/the/bytecode/club/bytecodeviewer/api/ASMUtil_OLD.java index 3f28d479..a3f3d1e4 100644 --- a/src/the/bytecode/club/bytecodeviewer/api/ASMUtil_OLD.java +++ b/src/the/bytecode/club/bytecodeviewer/api/ASMUtil_OLD.java @@ -93,7 +93,6 @@ public final class ASMUtil_OLD { } } - @SuppressWarnings("unchecked") public static void renameClassNode(final String oldName, final String newName) { for (ClassNode c : BytecodeViewer.getLoadedClasses()) { diff --git a/src/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java b/src/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java index f584d221..2f6b4428 100644 --- a/src/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java +++ b/src/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java @@ -5,6 +5,7 @@ import java.io.File; import me.konloch.kontainer.io.DiskWriter; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Dex2Jar; +import the.bytecode.club.bytecodeviewer.Enjarify; import the.bytecode.club.bytecodeviewer.MiscUtils; import the.bytecode.club.bytecodeviewer.ZipUtils; @@ -43,7 +44,10 @@ public class SmaliAssembler extends Compiler { } - Dex2Jar.dex2Jar(tempDex, tempJar); + if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.dex2Jar(tempDex, tempJar); + else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.apk2Jar(tempDex, tempJar); try { ZipUtils.unzipFilesToPath(tempJar.getAbsolutePath(), tempJarFolder.getAbsolutePath()); diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java index 866755a6..1a1a70ee 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java @@ -1,20 +1,15 @@ package the.bytecode.club.bytecodeviewer.decompilers; -import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import jd.cli.loader.DirectoryLoader; -import jd.cli.loader.JarLoader; import jd.cli.preferences.CommonPreferences; import jd.cli.util.ClassFileUtil; -import jd.core.loader.Loader; import jd.core.process.DecompilerImpl; import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; @@ -23,9 +18,7 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; -import the.bytecode.club.bytecodeviewer.JarUtils; import the.bytecode.club.bytecodeviewer.MiscUtils; -import the.bytecode.club.bytecodeviewer.ZipUtils; import jd.cli.printer.text.PlainTextPrinter; /** diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java index e000ea8a..9ffd2f3a 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java @@ -138,6 +138,7 @@ public class KrakatauDecompiler extends Decompiler { ); Process process = pb.start(); + BytecodeViewer.krakatau.add(process); //Read out dir output InputStream is = process.getInputStream(); diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java index aca9890a..76cd7653 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java @@ -10,6 +10,7 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Dex2Jar; +import the.bytecode.club.bytecodeviewer.Enjarify; import the.bytecode.club.bytecodeviewer.MiscUtils; import the.bytecode.club.bytecodeviewer.ZipUtils; @@ -44,7 +45,12 @@ public class SmaliDisassembler extends Decompiler { } ZipUtils.zipFile(tempClass, tempZip); - Dex2Jar.saveAsDex(tempZip, tempDex); + + if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.saveAsDex(tempZip, tempDex); + else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.saveAsAPK(tempZip, tempDex); + try { org.jf.baksmali.main.main(new String[]{"-o", tempSmali.getAbsolutePath(), "-x", tempDex.getAbsolutePath()}); } catch (Exception e) { diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java index 41813809..4119c8f5 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java @@ -26,7 +26,6 @@ public class ClassNodeDecompiler extends Decompiler { new ArrayList(), cn).toString(); } - @SuppressWarnings("unchecked") protected static PrefixedStringBuilder decompile( PrefixedStringBuilder sb, ArrayList decompiledClasses, ClassNode cn) { diff --git a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java index f19c1f6f..f8ace560 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java @@ -45,11 +45,14 @@ public class AboutWindow extends JFrame { "100% free and open sourced licensed under GPL v3 CopyLeft\r\n\r\n"+ "Settings:"+BytecodeViewer.nl+ "BCV Dir: " + BytecodeViewer.getBCVDirectory()+BytecodeViewer.nl+ - "Python: " + BytecodeViewer.python+BytecodeViewer.nl+ + "Python 2.7 (or PyPy): " + BytecodeViewer.python+BytecodeViewer.nl+ + "Python 3.0 (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+BytecodeViewer.nl+ + "Krakatau Dir: " + BytecodeViewer.krakatauWorkingDirectory+BytecodeViewer.nl+ + "BCV Enjarify: v" + BytecodeViewer.enjarifyVersion+BytecodeViewer.nl+ + "Enjarify Dir: " + BytecodeViewer.enjarifyWorkingDirectory+BytecodeViewer.nl+BytecodeViewer.nl+ "Keybinds:"+BytecodeViewer.nl+ "CTRL + O: Open/add new jar/class/apk"+BytecodeViewer.nl+ "CTLR + N: Reset the workspace"+BytecodeViewer.nl+ diff --git a/src/the/bytecode/club/bytecodeviewer/gui/BootScreen.java b/src/the/bytecode/club/bytecodeviewer/gui/BootScreen.java index bad331c5..8b49f1d9 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/BootScreen.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/BootScreen.java @@ -30,9 +30,12 @@ import java.util.jar.JarFile; import javax.swing.text.html.HTMLEditorKit; +import org.apache.commons.io.FileUtils; + import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Settings; +import the.bytecode.club.bytecodeviewer.ZipUtils; import me.konloch.kontainer.io.HTTPRequest; /** @@ -142,7 +145,7 @@ public class BootScreen extends JFrame { libsFileList.add(f.getAbsolutePath()); } - progressBar.setMaximum(urlList.size()); + progressBar.setMaximum(urlList.size()*2); for(String s : urlList) { String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length(), s.length()); @@ -202,9 +205,8 @@ public class BootScreen extends JFrame { boolean delete = true; for(String urlS : urlList) { String fileName = urlS.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length(), urlS.length()); - if(fileName.equals(f.getName())) { + if(fileName.equals(f.getName())) delete = false; - } } if(delete) { f.delete(); @@ -246,8 +248,91 @@ public class BootScreen extends JFrame { BytecodeViewer.showMessage("Error, Library " + f.getName() + " is corrupt, please restart to redownload it."); } } + completedCheck++; + progressBar.setValue(completedCheck); } } + + + + setTitle("Bytecode Viewer Boot Screen - Checking Krakatau..."); + File krakatauZip = null; + for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) { + if(f.getName().toLowerCase().startsWith("krakatau-")) { + BytecodeViewer.krakatauVersion = f.getName().split("-")[1].split("\\.")[0]; + krakatauZip = f; + } + } + + for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) { + if(f.getName().toLowerCase().startsWith("krakatau_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.krakatauVersion)) { + setTitle("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "..."); + System.out.println("Removing oudated " + f.getName()); + try { + FileUtils.deleteDirectory(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + BytecodeViewer.krakatauWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion + BytecodeViewer.fs + "Krakatau-master"; + File krakatauDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion); + if(!krakatauDirectory.exists()) { + try { + setTitle("Bytecode Viewer Boot Screen - Updating to "+krakatauDirectory.getName()+"..."); + ZipUtils.unzipFilesToPath(krakatauZip.getAbsolutePath(), krakatauDirectory.getAbsolutePath()); + System.out.println("Updated to krakatau v" + BytecodeViewer.krakatauVersion); + } catch(Exception e) { + BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly corrupt). Restart BCV."+BytecodeViewer.nl+ + "If the error persists contact @Konloch."); + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + krakatauZip.delete(); + } + } + + completedCheck++; + progressBar.setValue(completedCheck); + + + setTitle("Bytecode Viewer Boot Screen - Checking Enjarify..."); + File enjarifyZip = null; + for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) { + if(f.getName().toLowerCase().startsWith("enjarify-")) { + BytecodeViewer.enjarifyVersion = f.getName().split("-")[1].split("\\.")[0]; + enjarifyZip = f; + } + } + + for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) { + if(f.getName().toLowerCase().startsWith("enjarify_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.enjarifyVersion)) { + setTitle("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "..."); + System.out.println("Removing oudated " + f.getName()); + try { + FileUtils.deleteDirectory(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + BytecodeViewer.enjarifyWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion + BytecodeViewer.fs + "enjarify-master"; + File enjarifyDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion); + if(!enjarifyDirectory.exists()) { + try { + setTitle("Bytecode Viewer Boot Screen - Updating to "+enjarifyDirectory.getName()+"..."); + ZipUtils.unzipFilesToPath(enjarifyZip.getAbsolutePath(), enjarifyDirectory.getAbsolutePath()); + System.out.println("Updated to enjarify v" + BytecodeViewer.enjarifyVersion); + } catch(Exception e) { + BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart BCV."+BytecodeViewer.nl+ + "If the error persists contact @Konloch."); + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); + enjarifyZip.delete(); + } + } + completedCheck++; + progressBar.setValue(completedCheck); + setTitle("Bytecode Viewer Boot Screen - Booting!"); } catch(Exception e) { diff --git a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index d8870d7a..7d18c016 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -34,6 +34,7 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Dex2Jar; +import the.bytecode.club.bytecodeviewer.Enjarify; import the.bytecode.club.bytecodeviewer.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.JarUtils; import the.bytecode.club.bytecodeviewer.MiscUtils; @@ -49,10 +50,9 @@ import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ShowAllStrings; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ShowMainMethods; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ZKMStringDecrypter; import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ZStringArrayDecrypter; + import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeListener; -import javax.swing.event.ChangeEvent; /** * The main file for the GUI.n @@ -61,7 +61,7 @@ import javax.swing.event.ChangeEvent; * */ public class MainViewerGUI extends JFrame implements FileChangeNotifier { - + public void pythonC() { JFileChooser fc = new JFileChooser(); fc.setFileFilter(new PythonCFileFilter()); @@ -77,6 +77,21 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { } } + public void pythonC3() { + JFileChooser fc = new JFileChooser(); + fc.setFileFilter(new PythonC3FileFilter()); + fc.setFileHidingEnabled(false); + fc.setAcceptAllFileFilterUsed(false); + int returnVal = fc.showOpenDialog(BytecodeViewer.viewer); + + if (returnVal == JFileChooser.APPROVE_OPTION) + try { + BytecodeViewer.python3 = fc.getSelectedFile().getAbsolutePath(); + } catch (Exception e1) { + new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); + } + } + public void library() { JFileChooser fc = new JFileChooser(); fc.setFileFilter(new LibraryFileFilter()); @@ -784,7 +799,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { Thread t = new Thread() { @Override public void run() { - Dex2Jar.saveAsDex(new File(input), file2); + if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) + Dex2Jar.saveAsDex(new File(input), file2); + else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) + Enjarify.saveAsAPK(new File(input), file2); + BytecodeViewer.viewer.setIcon(false); } }; @@ -1973,6 +1992,18 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { } } + public class PythonC3FileFilter extends FileFilter { + @Override + public boolean accept(File f) { + return true; + } + + @Override + public String getDescription() { + return "Python (Or PyPy for speed) 3.x Executable"; + } + } + public class RTCFileFilter extends FileFilter { @Override public boolean accept(File f) { diff --git a/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameClasses.java b/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameClasses.java index 0691a8e2..0ca7f488 100644 --- a/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameClasses.java +++ b/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameClasses.java @@ -2,11 +2,9 @@ package the.bytecode.club.bytecodeviewer.obfuscators.rename; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; -import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD; import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData; diff --git a/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameMethods.java b/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameMethods.java index 52a31816..3cc29c72 100644 --- a/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameMethods.java +++ b/src/the/bytecode/club/bytecodeviewer/obfuscators/rename/RenameMethods.java @@ -5,7 +5,6 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; -import the.bytecode.club.bytecodeviewer.api.ASMUtil_OLD; import the.bytecode.club.bytecodeviewer.obfuscators.JavaObfuscator; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MethodMappingData; diff --git a/src/the/bytecode/club/bytecodeviewer/plugin/preinstalled/CodeSequenceDiagram.java b/src/the/bytecode/club/bytecodeviewer/plugin/preinstalled/CodeSequenceDiagram.java index 6f66c2da..cae128f9 100644 --- a/src/the/bytecode/club/bytecodeviewer/plugin/preinstalled/CodeSequenceDiagram.java +++ b/src/the/bytecode/club/bytecodeviewer/plugin/preinstalled/CodeSequenceDiagram.java @@ -30,7 +30,6 @@ import the.bytecode.club.bytecodeviewer.gui.ClassViewer; public class CodeSequenceDiagram extends Plugin { - @SuppressWarnings("unchecked") @Override public void execute(ArrayList classNodeList) { if(BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer)) { diff --git a/src/the/bytecode/club/bytecodeviewer/searching/FieldCallSearch.java b/src/the/bytecode/club/bytecodeviewer/searching/FieldCallSearch.java index 83daf219..e56f611a 100644 --- a/src/the/bytecode/club/bytecodeviewer/searching/FieldCallSearch.java +++ b/src/the/bytecode/club/bytecodeviewer/searching/FieldCallSearch.java @@ -49,7 +49,6 @@ public class FieldCallSearch implements SearchTypeDetails { @Override public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) { - @SuppressWarnings("unchecked") final Iterator methods = node.methods.iterator(); String owner = mOwner.getText(); if (owner.isEmpty()) { @@ -67,7 +66,6 @@ public class FieldCallSearch implements SearchTypeDetails { final MethodNode method = methods.next(); final InsnList insnlist = method.instructions; - @SuppressWarnings("unchecked") final ListIterator instructions = insnlist .iterator(); while (instructions.hasNext()) { diff --git a/src/the/bytecode/club/bytecodeviewer/searching/LDCSearch.java b/src/the/bytecode/club/bytecodeviewer/searching/LDCSearch.java index dcd3529b..fe850f59 100644 --- a/src/the/bytecode/club/bytecodeviewer/searching/LDCSearch.java +++ b/src/the/bytecode/club/bytecodeviewer/searching/LDCSearch.java @@ -40,7 +40,6 @@ public class LDCSearch implements SearchTypeDetails { return myPanel; } - @SuppressWarnings("unchecked") @Override public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) { diff --git a/src/the/bytecode/club/bytecodeviewer/searching/MethodCallSearch.java b/src/the/bytecode/club/bytecodeviewer/searching/MethodCallSearch.java index 27f5edc8..8954ca31 100644 --- a/src/the/bytecode/club/bytecodeviewer/searching/MethodCallSearch.java +++ b/src/the/bytecode/club/bytecodeviewer/searching/MethodCallSearch.java @@ -46,7 +46,6 @@ public class MethodCallSearch implements SearchTypeDetails { return myPanel; } - @SuppressWarnings("unchecked") @Override public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) { diff --git a/src/the/bytecode/club/bytecodeviewer/searching/RegexInsnFinder.java b/src/the/bytecode/club/bytecodeviewer/searching/RegexInsnFinder.java index 7fc95580..56371494 100644 --- a/src/the/bytecode/club/bytecodeviewer/searching/RegexInsnFinder.java +++ b/src/the/bytecode/club/bytecodeviewer/searching/RegexInsnFinder.java @@ -195,8 +195,7 @@ public class RegexInsnFinder { public RegexInsnFinder(final ClassNode clazz, final MethodNode method) { setMethod(clazz, method); } - - @SuppressWarnings("unchecked") + private AbstractInsnNode[] cleanInsn(final InsnList insnList) { final List il = new ArrayList(); diff --git a/src/the/bytecode/club/bytecodeviewer/searching/RegexSearch.java b/src/the/bytecode/club/bytecodeviewer/searching/RegexSearch.java index edc66ce8..5181377d 100644 --- a/src/the/bytecode/club/bytecodeviewer/searching/RegexSearch.java +++ b/src/the/bytecode/club/bytecodeviewer/searching/RegexSearch.java @@ -37,7 +37,6 @@ public class RegexSearch implements SearchTypeDetails { return myPanel; } - @SuppressWarnings("unchecked") @Override public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) {