diff --git a/BytecodeViewer 2.9.8-preview-2.jar b/BytecodeViewer 2.9.8-preview-3.jar similarity index 91% rename from BytecodeViewer 2.9.8-preview-2.jar rename to BytecodeViewer 2.9.8-preview-3.jar index 0dc3045c..cfeb30b3 100644 Binary files a/BytecodeViewer 2.9.8-preview-2.jar and b/BytecodeViewer 2.9.8-preview-3.jar differ diff --git a/src/resources/android.png b/src/resources/android.png new file mode 100644 index 00000000..6c242f0a Binary files /dev/null and b/src/resources/android.png differ diff --git a/src/resources/bat.png b/src/resources/bat.png new file mode 100644 index 00000000..c28dd638 Binary files /dev/null and b/src/resources/bat.png differ diff --git a/src/resources/c#.png b/src/resources/c#.png new file mode 100644 index 00000000..ffb8fc93 Binary files /dev/null and b/src/resources/c#.png differ diff --git a/src/resources/c++.png b/src/resources/c++.png new file mode 100644 index 00000000..a87cf847 Binary files /dev/null and b/src/resources/c++.png differ diff --git a/src/resources/config.png b/src/resources/config.png new file mode 100644 index 00000000..106f5aa3 Binary files /dev/null and b/src/resources/config.png differ diff --git a/src/resources/decoded.png b/src/resources/decoded.png new file mode 100644 index 00000000..44ccbf81 Binary files /dev/null and b/src/resources/decoded.png differ diff --git a/src/resources/file.png b/src/resources/file.png new file mode 100644 index 00000000..8b8b1ca0 Binary files /dev/null and b/src/resources/file.png differ diff --git a/src/resources/folder.png b/src/resources/folder.png new file mode 100644 index 00000000..784e8fa4 Binary files /dev/null and b/src/resources/folder.png differ diff --git a/src/resources/image.png b/src/resources/image.png new file mode 100644 index 00000000..4a158fef Binary files /dev/null and b/src/resources/image.png differ diff --git a/src/resources/jar.png b/src/resources/jar.png new file mode 100644 index 00000000..b1d0b57d Binary files /dev/null and b/src/resources/jar.png differ diff --git a/src/resources/java.png b/src/resources/java.png new file mode 100644 index 00000000..0a7d6f4a Binary files /dev/null and b/src/resources/java.png differ diff --git a/src/resources/package.png b/src/resources/package.png new file mode 100644 index 00000000..0afea5b8 Binary files /dev/null and b/src/resources/package.png differ diff --git a/src/resources/sh.png b/src/resources/sh.png new file mode 100644 index 00000000..b3d8ce01 Binary files /dev/null and b/src/resources/sh.png differ diff --git a/src/resources/text.png b/src/resources/text.png new file mode 100644 index 00000000..b93e7760 Binary files /dev/null and b/src/resources/text.png differ diff --git a/src/resources/zip.png b/src/resources/zip.png new file mode 100644 index 00000000..fd4bbccd Binary files /dev/null and b/src/resources/zip.png differ diff --git a/src/the/bytecode/club/bootloader/Boot.java b/src/the/bytecode/club/bootloader/Boot.java index d49db048..8bc70a79 100644 --- a/src/the/bytecode/club/bootloader/Boot.java +++ b/src/the/bytecode/club/bootloader/Boot.java @@ -26,6 +26,7 @@ import the.bytecode.club.bytecodeviewer.api.ExceptionUI; */ public class Boot { + /*flags*/ public static boolean globalstop = false; public static boolean completedboot = false; public static boolean downloading = false; diff --git a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index a476fdef..04246862 100644 --- a/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -98,12 +98,17 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager; * 07/19/2015 - Fixed enjarify. * 07/20/2015 - Bibl sexified the boot loading time. * 07/20/2015 - Decode APK Resources is selected by default. - * 07/20/2015 - Made the security manager slightly safer, can still be targeted but not as obvious now. + * 07/20/2015 - Made the security manager slightly safer, it can still be targeted but not as obviously now. * 07/20/2015 - Added CLI to the boot page. - * 07/21/2015 - Added support for offline mode incase you cannot connect to github for some reason. (kicks in after 7 seconds) - * 07/21/2015 - Added fatjar option back, incase anyone wants a 100% portable version. + * 07/21/2015 - Added support for offline mode in case you cannot connect to github for some reason. (kicks in after 7 seconds) + * 07/21/2015 - Added fatjar option back, in case anyone wants a 100% portable version. * 07/21/2015 - Made it so it now shows the decompiler it's using - http://i.imgur.com/yMEzXwv.png. * 07/21/2015 - Rewrote the file system, it now shows the path of the jar it's got loaded. + * 07/21/2015 - Now it shows if the decompiler is in editable mode or not. + * 07/21/2015 - Fixed Enjarify bug from new security manager. + * 07/22/2015 - Fixed a typo (Thanks affffsdsd) + * 07/22/2015 - Finally added icons to the File Navigator, credits to http://famfamfam.com/lab/icons/silk/ for the icons. + * 07/22/2015 - JD-GUI is now the default decompiler for GUI. * * @author Konloch * @@ -214,7 +219,7 @@ public class BytecodeViewer { { Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases")); } else { - showMessage("Cannot open the page, please manually type it."); + showMessage("Cannot open the page, please manually type it."+nl+"https://github.com/Konloch/bytecode-viewer/releases"); } } if(result == 1) { @@ -303,7 +308,7 @@ public class BytecodeViewer { System.out.println("Download finished!"); showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath()); } catch(FileNotFoundException e) { - showMessage("Unable to download, the zip file has not been uploaded yet, please try again later in an hour."); + showMessage("Unable to download, the zip file has not been uploaded yet, please try again in about 10 minutes."); } catch(Exception e) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } @@ -468,7 +473,7 @@ public class BytecodeViewer { /** * Main startup - * @param args files you want to open + * @param args files you want to open or CLI */ public static void main(String[] args) { BytecodeViewer.args = args; @@ -756,11 +761,8 @@ public class BytecodeViewer { if(cafebabe.toLowerCase().equals("cafebabe")) { final ClassNode cn = JarUtils.getNode(bytes); - FileContainer container = new FileContainer(); - - container.name = fn; + FileContainer container = new FileContainer(f); container.classes.add(cn); - BytecodeViewer.files.add(container); } else { showMessage(fn+": Header does not start with CAFEBABE, ignoring."); @@ -773,8 +775,7 @@ public class BytecodeViewer { } else if(fn.endsWith(".apk")) { try { BytecodeViewer.viewer.setIcon(true); - FileContainer container = new FileContainer(); - container.name = fn; + FileContainer container = new FileContainer(f); if(viewer.decodeAPKResources.isSelected()) { File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); @@ -803,8 +804,7 @@ public class BytecodeViewer { } else if(fn.endsWith(".dex")) { try { BytecodeViewer.viewer.setIcon(true); - FileContainer container = new FileContainer(); - container.name = fn; + FileContainer container = new FileContainer(f); String name = getRandomizedName()+".jar"; File output = new File(tempDirectory + fs + name); @@ -828,11 +828,8 @@ public class BytecodeViewer { files.put(f.getName(), bytes); - FileContainer container = new FileContainer(); - - container.name = fn; + FileContainer container = new FileContainer(f); container.files = files; - BytecodeViewer.files.add(container); } } diff --git a/src/the/bytecode/club/bytecodeviewer/CommandLineInput.java b/src/the/bytecode/club/bytecodeviewer/CommandLineInput.java index d6c756c5..27127053 100644 --- a/src/the/bytecode/club/bytecodeviewer/CommandLineInput.java +++ b/src/the/bytecode/club/bytecodeviewer/CommandLineInput.java @@ -176,16 +176,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.procyon.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -203,16 +194,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.cfr.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -230,16 +212,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.fernflower.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -257,16 +230,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.krakatau.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -285,16 +249,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.krakatauDA.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -313,16 +268,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.jdgui.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -341,16 +287,7 @@ public class CommandLineInput { } else { try { ClassNode cn = BytecodeViewer.getClassNode(target); - final ClassWriter cw = new ClassWriter(0); - try { - cn.accept(cw); - } catch(Exception e) { - e.printStackTrace(); - try { - Thread.sleep(200); - cn.accept(cw); - } catch (InterruptedException e1) { } - } + final ClassWriter cw = accept(cn); String contents = Decompiler.smali.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(output.getAbsolutePath(), contents, false); } catch (Exception e) { @@ -367,4 +304,18 @@ public class CommandLineInput { } } + public static ClassWriter accept(ClassNode cn) { + ClassWriter cw = new ClassWriter(0); + try { + cn.accept(cw); + } catch(Exception e) { + e.printStackTrace(); + try { + Thread.sleep(200); + cn.accept(cw); + } catch (InterruptedException e1) { } + } + return cw; + } + } diff --git a/src/the/bytecode/club/bytecodeviewer/FileContainer.java b/src/the/bytecode/club/bytecodeviewer/FileContainer.java index e6ea55cb..eea00c12 100644 --- a/src/the/bytecode/club/bytecodeviewer/FileContainer.java +++ b/src/the/bytecode/club/bytecodeviewer/FileContainer.java @@ -1,5 +1,6 @@ package the.bytecode.club.bytecodeviewer; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -14,6 +15,12 @@ import org.objectweb.asm.tree.ClassNode; public class FileContainer { + public FileContainer(File f) { + this.file = f; + this.name = f.getName(); + } + + public File file; public String name; public HashMap files = new HashMap(); diff --git a/src/the/bytecode/club/bytecodeviewer/JarUtils.java b/src/the/bytecode/club/bytecodeviewer/JarUtils.java index 8326a315..b265d3f2 100644 --- a/src/the/bytecode/club/bytecodeviewer/JarUtils.java +++ b/src/the/bytecode/club/bytecodeviewer/JarUtils.java @@ -34,8 +34,7 @@ public class JarUtils { * @throws IOException */ public static void put(final File jarFile) throws IOException { - FileContainer container = new FileContainer(); - container.name = jarFile.getName(); + FileContainer container = new FileContainer(jarFile); HashMap files = new HashMap(); ZipInputStream jis = new ZipInputStream(new FileInputStream(jarFile)); diff --git a/src/the/bytecode/club/bytecodeviewer/Resources.java b/src/the/bytecode/club/bytecodeviewer/Resources.java index 75e61b02..95e4d897 100644 --- a/src/the/bytecode/club/bytecodeviewer/Resources.java +++ b/src/the/bytecode/club/bytecodeviewer/Resources.java @@ -25,7 +25,22 @@ public class Resources { public static ImageIcon prevIcon; public static ImageIcon busy; public static ImageIcon busyB64; - + + public static ImageIcon bat; + public static ImageIcon sh; + public static ImageIcon csharp; + public static ImageIcon cplusplus; + public static ImageIcon config; + public static ImageIcon jar; + public static ImageIcon zip; + public static ImageIcon packages; + public static ImageIcon folder; + public static ImageIcon android; + public static ImageIcon file; + public static ImageIcon textFile; + public static ImageIcon classFile; + public static ImageIcon imageFile; + public static ImageIcon decoded; static { @@ -35,6 +50,21 @@ public class Resources { busy = new ImageIcon(Resources.class.getClass().getResource("/resources/1.gif")); busyB64 = new ImageIcon(b642IMG("R0lGODlhEAALAPQAAP///wAAANra2tDQ0Orq6gcHBwAAAC8vL4KCgmFhYbq6uiMjI0tLS4qKimVlZb6+vicnJwUFBU9PT+bm5tjY2PT09Dk5Odzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH5BAkLAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7")); + bat = new ImageIcon(Resources.class.getClass().getResource("/resources/bat.png")); + sh = new ImageIcon(Resources.class.getClass().getResource("/resources/sh.png")); + csharp = new ImageIcon(Resources.class.getClass().getResource("/resources/c#.png")); + cplusplus = new ImageIcon(Resources.class.getClass().getResource("/resources/c++.png")); + config = new ImageIcon(Resources.class.getClass().getResource("/resources/config.png")); + jar = new ImageIcon(Resources.class.getClass().getResource("/resources/jar.png")); + zip= new ImageIcon(Resources.class.getClass().getResource("/resources/zip.png")); + packages = new ImageIcon(Resources.class.getClass().getResource("/resources/package.png")); + folder = new ImageIcon(Resources.class.getClass().getResource("/resources/folder.png")); + android = new ImageIcon(Resources.class.getClass().getResource("/resources/android.png")); + file = new ImageIcon(Resources.class.getClass().getResource("/resources/file.png")); + textFile = new ImageIcon(Resources.class.getClass().getResource("/resources/text.png")); + classFile = new ImageIcon(Resources.class.getClass().getResource("/resources/java.png")); + imageFile = new ImageIcon(Resources.class.getClass().getResource("/resources/image.png")); + decoded = new ImageIcon(Resources.class.getClass().getResource("/resources/decoded.png")); iconList = new ArrayList(); int size = 16; diff --git a/src/the/bytecode/club/bytecodeviewer/SecurityMan.java b/src/the/bytecode/club/bytecodeviewer/SecurityMan.java index ad1ab5b4..90c48b11 100644 --- a/src/the/bytecode/club/bytecodeviewer/SecurityMan.java +++ b/src/the/bytecode/club/bytecodeviewer/SecurityMan.java @@ -22,6 +22,7 @@ public class SecurityMan extends SecurityManager { if( executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.KrakatauDecompiler") || executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.KrakatauDisassambler") || executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.KrakatauAssembler") || + executedClass.equals("the.bytecode.club.bytecodeviewer.Enjarify") || executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer")) { blocking = false; @@ -48,11 +49,11 @@ public class SecurityMan extends SecurityManager { if(allow && !blocking) { System.out.println("Allowing exec:" + cmd); - } else throw new SecurityException("BCV is awesome."); + } else throw new SecurityException("BCV is awesome, blocking " + cmd); } @Override public void checkListen(int port) { - throw new SecurityException("BCV is awesome."); + throw new SecurityException("BCV is awesome, blocking port "+port+" from listening"); } @Override public void checkPermission(Permission perm) { //expand eventually diff --git a/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java b/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java index 1b6380a8..e4bfff72 100644 --- a/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java +++ b/src/the/bytecode/club/bytecodeviewer/decompilers/JDGUIDecompiler.java @@ -20,7 +20,7 @@ import the.bytecode.club.bytecodeviewer.MiscUtils; import jd.cli.printer.text.PlainTextPrinter; /** - * JDCore Decompiler Wrapper + * JD-Core Decompiler Wrapper * * @author Konloch * @author JD-Core developers diff --git a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java index 79c423cf..24bba9f2 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java @@ -625,7 +625,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -652,7 +652,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -680,7 +680,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("FernFlower Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("FernFlower Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -709,7 +709,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -746,7 +746,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -774,7 +774,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -806,7 +806,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Krakatau Disassembler")); + scrollPane.setColumnHeaderView(new JLabel("Krakatau Disassembler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -834,7 +834,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler - Editable: " + panelArea.isEditable())); panel1.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -879,7 +879,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -907,7 +907,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -935,7 +935,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -962,7 +962,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -998,7 +998,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1026,7 +1026,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1084,7 +1084,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler - Editable: " + panelArea.isEditable())); panel2.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1130,7 +1130,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Procyon Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1158,7 +1158,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1186,7 +1186,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("CFR Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1213,7 +1213,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Bytecode Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1249,7 +1249,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Smali Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1277,7 +1277,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("Krakatau Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); java3 = panelArea; panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); @@ -1335,7 +1335,7 @@ public class ClassViewer extends Viewer { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); - scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler")); + scrollPane.setColumnHeaderView(new JLabel("JD-GUI Decompiler - Editable: " + panelArea.isEditable())); panel3.add(scrollPane); java3 = panelArea; panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int)BytecodeViewer.viewer.fontSpinner.getValue())); diff --git a/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java b/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java index 987673f1..cf191b1b 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/FileNavigationPane.java @@ -4,6 +4,7 @@ import java.awt.BorderLayout; import java.awt.font.FontRenderContext; import java.awt.geom.*; import java.awt.Color; +import java.awt.Component; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; @@ -16,6 +17,7 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; @@ -31,6 +33,7 @@ import javax.swing.JTree; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; @@ -63,6 +66,10 @@ public class FileNavigationPane extends VisibleComponent implements super("ClassNavigation"); setTitle("Files"); + + tree.setRootVisible(false); + tree.setShowsRootHandles(true); + this.fcn = fcn; open.addActionListener(new ActionListener() { @@ -291,6 +298,8 @@ public class FileNavigationPane extends VisibleComponent implements for (FileContainer container : BytecodeViewer.files) { MyTreeNode root = new MyTreeNode(container.name); treeRoot.add(root); + ImageRenderer renderer = new ImageRenderer(); + tree.setCellRenderer(renderer); if(!container.classes.isEmpty()) { for(ClassNode c : container.classes) { @@ -508,5 +517,103 @@ public class FileNavigationPane extends VisibleComponent implements tree.repaint(); tree.updateUI(); } + + /** + * + * @author http://stackoverflow.com/questions/14968005 + * @author Konloch + * + */ + public class ImageRenderer extends DefaultTreeCellRenderer { + + public Component getTreeCellRendererComponent( + JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) + { //called every time there is a pane update, I.E. whenever you expand a folder + + Component ret = super.getTreeCellRendererComponent(tree, value, + selected, expanded, leaf, row, hasFocus); + + if(value != null && value instanceof the.bytecode.club.bytecodeviewer.gui.FileNavigationPane.MyTreeNode) { + the.bytecode.club.bytecodeviewer.gui.FileNavigationPane.MyTreeNode node = (the.bytecode.club.bytecodeviewer.gui.FileNavigationPane.MyTreeNode) value; + String name = node.toString().toLowerCase(); + + if(name.endsWith(".jar")) { + setIcon(Resources.jar); + } else if(name.endsWith(".zip")) { + setIcon(Resources.zip); + } else if(name.endsWith(".bat")) { + setIcon(Resources.bat); + } else if(name.endsWith(".sh")) { + setIcon(Resources.sh); + } else if(name.endsWith(".cs")) { + setIcon(Resources.csharp); + } else if(name.endsWith(".c") ||name.endsWith(".cpp") ||name.endsWith(".h")) { + setIcon(Resources.cplusplus); + } else if(name.endsWith(".apk") || name.endsWith(".dex")) { + setIcon(Resources.android); + } else if(name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".bmp") || name.endsWith(".gif")) { + setIcon(Resources.imageFile); + } else if(name.endsWith(".class")) { + setIcon(Resources.classFile); + } else if(name.endsWith(".txt") || name.endsWith(".md")) { + setIcon(Resources.textFile); + } else if(name.equals("decoded resources")) { + setIcon(Resources.decoded); + } else if(name.endsWith(".properties") || name.endsWith(".xml") || name.endsWith(".mf") || name.endsWith(".config") || name.endsWith(".cfg")) { + setIcon(Resources.config); + } else if(node.getChildCount() <= 0) { //random file + setIcon(Resources.file); + } else { //folder + ArrayList nodes = new ArrayList(); + ArrayList totalNodes = new ArrayList(); + + nodes.add(node); + totalNodes.add(node); + + boolean isJava = false; + boolean finished = false; + + while(!finished) { //may cause a clusterfuck with huge files + if(nodes.isEmpty()) + finished = true; + else { + TreeNode treeNode = nodes.get(0); + nodes.remove(treeNode); + int children = treeNode.getChildCount(); + if(children >= 1) + for(int i = 0; i < children; i++) { + TreeNode child = treeNode.getChildAt(i); + + if(!totalNodes.contains(child)) { + nodes.add(child); + totalNodes.add(child); + } + + if(child.toString().endsWith(".class")) + isJava = true; + } + + if(isJava) + nodes.clear(); + } + } + + if(isJava) + setIcon(Resources.packages); + else { + setIcon(Resources.folder); + } + } + } + + return ret; + } + } } diff --git a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index b2e96045..9473484f 100644 --- a/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -540,7 +540,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final ButtonGroup panelGroup1 = new ButtonGroup(); public final ButtonGroup panelGroup2 = new ButtonGroup(); public final ButtonGroup panelGroup3 = new ButtonGroup(); - private final JMenuItem mntmSetOpitonalLibrary = new JMenuItem("Set Optionial Library Folder"); + private final JMenuItem mntmSetOpitonalLibrary = new JMenuItem("Set Optional Library Folder"); private final JMenuItem mntmPingback = new JMenuItem("Pingback"); private final JMenu mnJdgui = new JMenu("JD-GUI"); public final JRadioButtonMenuItem panel3JDGUI = new JRadioButtonMenuItem("Java"); @@ -1936,7 +1936,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { apkConversionGroup.add(apkConversionDex); apkConversionGroup.add(apkConversionEnjarify); - apkConversionGroup.setSelected(apkConversionDex.getModel(), true);//my one true love + apkConversionGroup.setSelected(apkConversionDex.getModel(), true); panelGroup1.add(panel1None); @@ -1980,7 +1980,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { mnFontSize.add(fontSpinner); - panelGroup1.setSelected(panel1Proc.getModel(), true);//my one true love + panelGroup1.setSelected(panel1JDGUI.getModel(), true); panelGroup2.setSelected(panel2Bytecode.getModel(), true); panelGroup3.setSelected(panel3None.getModel(), true);