This commit is contained in:
Konloch 2015-07-22 17:36:28 -06:00
parent f7d0233df2
commit 908ba230fe
27 changed files with 212 additions and 119 deletions

BIN
src/resources/android.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
src/resources/bat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

BIN
src/resources/c#.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

BIN
src/resources/c++.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

BIN
src/resources/config.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

BIN
src/resources/decoded.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

BIN
src/resources/file.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

BIN
src/resources/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

BIN
src/resources/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

BIN
src/resources/jar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

BIN
src/resources/java.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

BIN
src/resources/package.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

BIN
src/resources/sh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

BIN
src/resources/text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

BIN
src/resources/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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<String, byte[]> files = new HashMap<String, byte[]>();

View file

@ -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<String, byte[]> files = new HashMap<String, byte[]>();
ZipInputStream jis = new ZipInputStream(new FileInputStream(jarFile));

View file

@ -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<BufferedImage>();
int size = 16;

View file

@ -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

View file

@ -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

View file

@ -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()));

View file

@ -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<TreeNode> nodes = new ArrayList<TreeNode>();
ArrayList<TreeNode> totalNodes = new ArrayList<TreeNode>();
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;
}
}
}

View file

@ -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);