Code Cleanup
This commit is contained in:
parent
47d8222f2e
commit
85197c9739
16 changed files with 340 additions and 271 deletions
|
@ -24,7 +24,7 @@ import the.bytecode.club.bootloader.Boot;
|
||||||
import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader;
|
import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader;
|
||||||
import the.bytecode.club.bytecodeviewer.compilers.Compilers;
|
import the.bytecode.club.bytecodeviewer.compilers.Compilers;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.ClassViewer;
|
import the.bytecode.club.bytecodeviewer.gui.ClassViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.ResourceListPane;
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceListPane;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions;
|
import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.SearchBoxPane;
|
import the.bytecode.club.bytecodeviewer.gui.SearchBoxPane;
|
||||||
|
@ -104,6 +104,7 @@ public class BytecodeViewer
|
||||||
public static Refactorer refactorer = new Refactorer();
|
public static Refactorer refactorer = new Refactorer();
|
||||||
public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc
|
public static List<FileContainer> files = new ArrayList<>(); //all of BCV's loaded files/classes/etc
|
||||||
public static List<Process> createdProcesses = new ArrayList<>();
|
public static List<Process> createdProcesses = new ArrayList<>();
|
||||||
|
public static final boolean EXPERIMENTAL_DRAG_TABS = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version checker thread
|
* The version checker thread
|
||||||
|
|
|
@ -32,6 +32,7 @@ import the.bytecode.club.bytecodeviewer.gui.extras.AboutWindow;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions;
|
import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.plugins.MaliciousCodeScannerOptions;
|
import the.bytecode.club.bytecodeviewer.gui.plugins.MaliciousCodeScannerOptions;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.plugins.ReplaceStringsOptions;
|
import the.bytecode.club.bytecodeviewer.gui.plugins.ReplaceStringsOptions;
|
||||||
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceListPane;
|
||||||
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses;
|
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses;
|
||||||
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameFields;
|
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameFields;
|
||||||
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods;
|
import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods;
|
||||||
|
|
|
@ -47,7 +47,6 @@ import static the.bytecode.club.bytecodeviewer.gui.TabbedPane.BLANK;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @author DreamSworK
|
* @author DreamSworK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class PaneUpdaterThread extends Thread {
|
public abstract class PaneUpdaterThread extends Thread {
|
||||||
public ClassViewer viewer;
|
public ClassViewer viewer;
|
||||||
public RSyntaxTextArea panelArea;
|
public RSyntaxTextArea panelArea;
|
||||||
|
@ -62,8 +61,8 @@ public abstract class PaneUpdaterThread extends Thread {
|
||||||
public void run() {
|
public void run() {
|
||||||
doShit();
|
doShit();
|
||||||
synchronizePane();
|
synchronizePane();
|
||||||
attachCtrlMouseWheelZoom(scrollPane, panelArea); //freezes the UI for some reason, probably cause BCV is
|
attachCtrlMouseWheelZoom(scrollPane, panelArea); //freezes the UI for some reason
|
||||||
// doing dumb shit with the swing thread
|
//probably cause BCV is doing dumb shit with the swing thread
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCtrlMouseWheelZoom(RTextScrollPane scrollPane, RSyntaxTextArea panelArea) {
|
public void attachCtrlMouseWheelZoom(RTextScrollPane scrollPane, RSyntaxTextArea panelArea) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceListPane;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.FieldCallSearch;
|
import the.bytecode.club.bytecodeviewer.searching.FieldCallSearch;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearch;
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearch;
|
||||||
|
|
|
@ -14,14 +14,7 @@ import java.awt.event.InputEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.*;
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.plaf.basic.BasicButtonUI;
|
import javax.swing.plaf.basic.BasicButtonUI;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
|
||||||
|
@ -55,6 +48,8 @@ public class TabbedPane extends JPanel {
|
||||||
public static final Color BLANK = new Color(0, 0, 0, 0);
|
public static final Color BLANK = new Color(0, 0, 0, 0);
|
||||||
private final JTabbedPane pane;
|
private final JTabbedPane pane;
|
||||||
public final JLabel label;
|
public final JLabel label;
|
||||||
|
private DelayTabbedPaneThread probablyABadIdea;
|
||||||
|
private long startedDragging = 0;
|
||||||
private static long zero = System.currentTimeMillis();
|
private static long zero = System.currentTimeMillis();
|
||||||
public String tabName;
|
public String tabName;
|
||||||
public String fileContainerName;
|
public String fileContainerName;
|
||||||
|
@ -159,48 +154,40 @@ public class TabbedPane extends JPanel {
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*this.addMouseListener(new MouseListener() {
|
|
||||||
|
if(BytecodeViewer.EXPERIMENTAL_DRAG_TABS)
|
||||||
|
{
|
||||||
|
/*label.addMouseListener(new MouseListener() {
|
||||||
@Override public void mouseClicked(MouseEvent e) {}
|
@Override public void mouseClicked(MouseEvent e) {}
|
||||||
@Override public void mouseEntered(MouseEvent arg0) {
|
@Override public void mouseEntered(MouseEvent arg0) {
|
||||||
}
|
}
|
||||||
@Override public void mouseExited(MouseEvent arg0) {
|
@Override public void mouseExited(MouseEvent arg0) {
|
||||||
}
|
}
|
||||||
@Override public void mousePressed(MouseEvent e) {
|
@Override public void mousePressed(MouseEvent e) {
|
||||||
if(e.getButton() == 1)
|
onMousePressed(e);
|
||||||
{
|
|
||||||
startedDragging = System.currentTimeMillis();
|
|
||||||
dragging = true;
|
|
||||||
if (probablyABadIdea != null)
|
|
||||||
{
|
|
||||||
probablyABadIdea.stopped = true;
|
|
||||||
}
|
|
||||||
probablyABadIdea = new DelayTabbedPaneThread(THIS);
|
|
||||||
probablyABadIdea.start();
|
|
||||||
repaint();
|
|
||||||
System.out.println(e.getX()+", "+e.getY());
|
|
||||||
Rectangle bounds = new Rectangle(1, 1, e.getX(), e.getY());
|
|
||||||
for(int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
|
|
||||||
{
|
|
||||||
Component c = BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i);
|
|
||||||
if(c != null && bounds.intersects(c.getBounds()))
|
|
||||||
{
|
|
||||||
BytecodeViewer.viewer.workPane.tabs.setSelectedIndex(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stopDragging(e.getX(), e.getY());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override public void mouseReleased(MouseEvent e) {
|
@Override public void mouseReleased(MouseEvent e) {
|
||||||
stopDragging(e.getX(), e.getY());
|
stopDragging(e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
|
this.addMouseListener(new MouseListener() {
|
||||||
|
@Override public void mouseClicked(MouseEvent e) {}
|
||||||
|
@Override public void mouseEntered(MouseEvent arg0) {
|
||||||
|
}
|
||||||
|
@Override public void mouseExited(MouseEvent arg0) {
|
||||||
|
}
|
||||||
|
@Override public void mousePressed(MouseEvent e) {
|
||||||
|
onMousePressed(e);
|
||||||
|
}
|
||||||
|
@Override public void mouseReleased(MouseEvent e) {
|
||||||
|
stopDragging(e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopDragging(int mouseX, int mouseY) {
|
private void stopDragging(int mouseX, int mouseY) {
|
||||||
long startedDragging = 0;
|
|
||||||
if (System.currentTimeMillis() - startedDragging >= 210) {
|
if (System.currentTimeMillis() - startedDragging >= 210) {
|
||||||
Rectangle bounds = new Rectangle(1, 1, mouseX, mouseY);
|
Rectangle bounds = new Rectangle(1, 1, mouseX, mouseY);
|
||||||
System.out.println("debug-5: " + mouseX + ", " + mouseY);
|
System.out.println("debug-5: " + mouseX + ", " + mouseY);
|
||||||
|
@ -228,8 +215,43 @@ public class TabbedPane extends JPanel {
|
||||||
BytecodeViewer.viewer.workPane.tabs.setTabComponentAt(index, this);
|
BytecodeViewer.viewer.workPane.tabs.setTabComponentAt(index, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SwingUtilities.invokeLater(() ->
|
||||||
|
{
|
||||||
label.setBackground(BLANK);
|
label.setBackground(BLANK);
|
||||||
label.updateUI();
|
label.updateUI();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMousePressed(MouseEvent e)
|
||||||
|
{
|
||||||
|
BytecodeViewer.viewer.workPane.tabs.dispatchEvent(e);
|
||||||
|
|
||||||
|
if(e.getButton() == 1)
|
||||||
|
{
|
||||||
|
startedDragging = System.currentTimeMillis();
|
||||||
|
//dragging = true;
|
||||||
|
if (probablyABadIdea != null)
|
||||||
|
{
|
||||||
|
probablyABadIdea.stopped = true;
|
||||||
|
}
|
||||||
|
probablyABadIdea = new DelayTabbedPaneThread(TabbedPane.this);
|
||||||
|
probablyABadIdea.start();
|
||||||
|
repaint();
|
||||||
|
System.out.println(e.getX()+", "+e.getY());
|
||||||
|
Rectangle bounds = new Rectangle(1, 1, e.getX(), e.getY());
|
||||||
|
for(int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
|
||||||
|
{
|
||||||
|
Component c = BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i);
|
||||||
|
if(c != null && bounds.intersects(c.getBounds()))
|
||||||
|
{
|
||||||
|
BytecodeViewer.viewer.workPane.tabs.setSelectedIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stopDragging(e.getX(), e.getY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TabButton extends JButton implements ActionListener {
|
private class TabButton extends JButton implements ActionListener {
|
||||||
|
|
|
@ -37,10 +37,12 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AboutWindow extends JFrame {
|
public class AboutWindow extends JFrame
|
||||||
|
{
|
||||||
JTextArea textArea = new JTextArea();
|
JTextArea textArea = new JTextArea();
|
||||||
|
|
||||||
public AboutWindow() {
|
public AboutWindow()
|
||||||
|
{
|
||||||
this.setIconImages(Resources.iconList);
|
this.setIconImages(Resources.iconList);
|
||||||
setSize(Toolkit.getDefaultToolkit().getScreenSize());
|
setSize(Toolkit.getDefaultToolkit().getScreenSize());
|
||||||
setType(Type.UTILITY);
|
setType(Type.UTILITY);
|
||||||
|
@ -57,12 +59,13 @@ public class AboutWindow extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean b) {
|
public void setVisible(boolean b)
|
||||||
|
{
|
||||||
super.setVisible(b);
|
super.setVisible(b);
|
||||||
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||||
textArea.setText("Bytecode Viewer " + VERSION + " is an open source program developed and "
|
textArea.setText("Bytecode Viewer " + VERSION + " is an open source program developed and " +
|
||||||
+ "maintained by Konloch (konloch@gmail.com) 100% free and open sourced licensed under GPL v3 "
|
"maintained by Konloch (konloch@gmail.com) 100% free and open sourced licensed under GPL v3 " +
|
||||||
+ "CopyLeft\r\n\r\n" +
|
"CopyLeft" + nl + nl +
|
||||||
"Settings:" + nl +
|
"Settings:" + nl +
|
||||||
" Preview Copy: " + PREVIEW_COPY + nl +
|
" Preview Copy: " + PREVIEW_COPY + nl +
|
||||||
" Fat Jar: " + FAT_JAR + nl +
|
" Fat Jar: " + FAT_JAR + nl +
|
||||||
|
@ -81,11 +84,11 @@ public class AboutWindow extends JFrame {
|
||||||
" -help Displays the help menu" + nl +
|
" -help Displays the help menu" + nl +
|
||||||
" -list Displays the available decompilers" + nl +
|
" -list Displays the available decompilers" + nl +
|
||||||
" -decompiler <decompiler> Selects the decompiler, procyon by default" + nl +
|
" -decompiler <decompiler> Selects the decompiler, procyon by default" + nl +
|
||||||
" -i <input file> Selects the input file (Jar, Class, APK, ZIP, DEX all work "
|
" -i <input file> Selects the input file (Jar, Class, APK, ZIP, DEX all work " +
|
||||||
+ "automatically)" + nl +
|
"automatically)" + nl +
|
||||||
" -o <output file> Selects the output file (Java or Java-Bytecode)" + nl +
|
" -o <output file> Selects the output file (Java or Java-Bytecode)" + nl +
|
||||||
" -t <target classname> Must either be the fully qualified classname or \"all\" to decompile"
|
" -t <target classname> Must either be the fully qualified classname or \"all\" to decompile" +
|
||||||
+ " all as zip" + nl +
|
" all as zip" + nl +
|
||||||
" -nowait Doesn't wait for the user to read the CLI messages" + nl + nl +
|
" -nowait Doesn't wait for the user to read the CLI messages" + nl + nl +
|
||||||
"Keybinds:" + nl +
|
"Keybinds:" + nl +
|
||||||
" CTRL + O: Open/add new jar/class/apk" + nl +
|
" CTRL + O: Open/add new jar/class/apk" + nl +
|
||||||
|
@ -94,13 +97,13 @@ public class AboutWindow extends JFrame {
|
||||||
" CTRL + T: Compile" + nl +
|
" CTRL + T: Compile" + nl +
|
||||||
" CTRL + S: Save classes as zip" + nl +
|
" CTRL + S: Save classes as zip" + nl +
|
||||||
" CTRL + R: Run (EZ-Inject) - dynamically load the classes and invoke a main class" +
|
" CTRL + R: Run (EZ-Inject) - dynamically load the classes and invoke a main class" +
|
||||||
"\r\n\r\nCode from various projects has been used, including but not limited to:\r\n J-RET by "
|
"\r\n\r\nCode from various projects has been used, including but not limited to:\r\n J-RET by " +
|
||||||
+ "WaterWolf\r\n JHexPane by Sam Koivu\r\n RSynaxPane by Robert Futrell\r\n Commons IO by "
|
"WaterWolf\r\n JHexPane by Sam Koivu\r\n RSynaxPane by Robert Futrell\r\n Commons IO by " +
|
||||||
+ "Apache\r\n ASM by OW2\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee "
|
"Apache\r\n ASM by OW2\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee " +
|
||||||
+ "Benfield\r\n CFIDE by Bibl\r\n Smali by JesusFreke\r\n Dex2Jar by pxb1..?\r\n Krakatau by "
|
"Benfield\r\n CFIDE by Bibl\r\n Smali by JesusFreke\r\n Dex2Jar by pxb1..?\r\n Krakatau by " +
|
||||||
+ "Storyyeller\r\n JD-GUI + JD-Core by The Java-Decompiler Team\r\n Enjarify by "
|
"Storyyeller\r\n JD-GUI + JD-Core by The Java-Decompiler Team\r\n Enjarify by " +
|
||||||
+ "Storyyeller\r\n\r\nIf you're interested in Java Reverse Engineering, join The Bytecode Club - "
|
"Storyyeller\r\n\r\nIf you're interested in Java Reverse Engineering, join The Bytecode Club - " +
|
||||||
+ "https://the.bytecode.club");
|
"https://the.bytecode.club");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,10 @@ import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExportJar extends JFrame {
|
public class ExportJar extends JFrame
|
||||||
public ExportJar(final String jarPath) {
|
{
|
||||||
|
public ExportJar(final String jarPath)
|
||||||
|
{
|
||||||
setSize(new Dimension(250, 277));
|
setSize(new Dimension(250, 277));
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Save As Jar..");
|
setTitle("Save As Jar..");
|
||||||
|
@ -44,14 +46,12 @@ public class ExportJar extends JFrame {
|
||||||
btnNewButton.setMaximumSize(new Dimension(999, 23));
|
btnNewButton.setMaximumSize(new Dimension(999, 23));
|
||||||
btnNewButton.setMinimumSize(new Dimension(999, 23));
|
btnNewButton.setMinimumSize(new Dimension(999, 23));
|
||||||
btnNewButton.setSize(new Dimension(999, 0));
|
btnNewButton.setSize(new Dimension(999, 0));
|
||||||
getContentPane().setLayout(
|
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
||||||
new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
getContentPane().add(scrollPane);
|
getContentPane().add(scrollPane);
|
||||||
|
|
||||||
JLabel lblMetainfmanifestmf = new JLabel("META-INF/MANIFEST.MF:");
|
scrollPane.setColumnHeaderView(new JLabel("META-INF/MANIFEST.MF:"));
|
||||||
scrollPane.setColumnHeaderView(lblMetainfmanifestmf);
|
|
||||||
|
|
||||||
final JTextArea mani = new JTextArea();
|
final JTextArea mani = new JTextArea();
|
||||||
mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: ");
|
mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: ");
|
||||||
|
@ -61,8 +61,7 @@ public class ExportJar extends JFrame {
|
||||||
btnNewButton.addActionListener(arg0 -> {
|
btnNewButton.addActionListener(arg0 -> {
|
||||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath,
|
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath, mani.getText());
|
||||||
mani.getText());
|
|
||||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package the.bytecode.club.bytecodeviewer.gui.extras;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Konloch
|
||||||
|
* @since 6/21/2021
|
||||||
|
*/
|
||||||
|
public class JTextAreaOutputStream extends OutputStream
|
||||||
|
{
|
||||||
|
private final StringBuilder sb = new StringBuilder();
|
||||||
|
private final JTextArea textArea;
|
||||||
|
|
||||||
|
public JTextAreaOutputStream(JTextArea textArea)
|
||||||
|
{
|
||||||
|
this.textArea = textArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
textArea.append(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException
|
||||||
|
{
|
||||||
|
sb.append((char) b);
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,8 +45,7 @@ public class RunOptions extends JFrame {
|
||||||
setTitle("Run Options");
|
setTitle("Run Options");
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
|
|
||||||
final JCheckBox accessModifiers = new JCheckBox(
|
final JCheckBox accessModifiers = new JCheckBox("Set All Access Modifiers Public");
|
||||||
"Set All Access Modifiers Public");
|
|
||||||
accessModifiers.setBounds(6, 7, 232, 23);
|
accessModifiers.setBounds(6, 7, 232, 23);
|
||||||
getContentPane().add(accessModifiers);
|
getContentPane().add(accessModifiers);
|
||||||
|
|
||||||
|
@ -74,8 +73,7 @@ public class RunOptions extends JFrame {
|
||||||
for (Object o : classNode.methods.toArray()) {
|
for (Object o : classNode.methods.toArray()) {
|
||||||
MethodNode m = (MethodNode) o;
|
MethodNode m = (MethodNode) o;
|
||||||
|
|
||||||
if (m.name.equals("main")
|
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V")) {
|
||||||
&& m.desc.equals("([Ljava/lang/String;)V")) {
|
|
||||||
if (!b) {
|
if (!b) {
|
||||||
b = true;
|
b = true;
|
||||||
txtThebytecodeclubexamplemainlstring
|
txtThebytecodeclubexamplemainlstring
|
||||||
|
@ -86,8 +84,7 @@ public class RunOptions extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!b)
|
if (!b)
|
||||||
txtThebytecodeclubexamplemainlstring
|
txtThebytecodeclubexamplemainlstring.setText("the/bytecode/club/Example.main");
|
||||||
.setText("the/bytecode/club/Example.main");
|
|
||||||
|
|
||||||
txtThebytecodeclubexamplemainlstring.setBounds(6, 233, 232, 20);
|
txtThebytecodeclubexamplemainlstring.setBounds(6, 233, 232, 20);
|
||||||
getContentPane().add(txtThebytecodeclubexamplemainlstring);
|
getContentPane().add(txtThebytecodeclubexamplemainlstring);
|
||||||
|
@ -109,13 +106,11 @@ public class RunOptions extends JFrame {
|
||||||
textField_1.setBounds(6, 172, 232, 20);
|
textField_1.setBounds(6, 172, 232, 20);
|
||||||
getContentPane().add(textField_1);
|
getContentPane().add(textField_1);
|
||||||
|
|
||||||
final JCheckBox forceProxy = new JCheckBox(
|
final JCheckBox forceProxy = new JCheckBox("Force Proxy (socks5, host:port):");
|
||||||
"Force Proxy (socks5, host:port):");
|
|
||||||
forceProxy.setBounds(6, 142, 232, 23);
|
forceProxy.setBounds(6, 142, 232, 23);
|
||||||
getContentPane().add(forceProxy);
|
getContentPane().add(forceProxy);
|
||||||
|
|
||||||
final JCheckBox launchReflectionKit = new JCheckBox(
|
final JCheckBox launchReflectionKit = new JCheckBox("Launch Reflection Kit On Successful Invoke");
|
||||||
"Launch Reflection Kit On Successful Invoke");
|
|
||||||
launchReflectionKit.setEnabled(false);
|
launchReflectionKit.setEnabled(false);
|
||||||
launchReflectionKit.setBounds(6, 260, 232, 23);
|
launchReflectionKit.setBounds(6, 260, 232, 23);
|
||||||
getContentPane().add(launchReflectionKit);
|
getContentPane().add(launchReflectionKit);
|
||||||
|
@ -125,8 +120,7 @@ public class RunOptions extends JFrame {
|
||||||
console.setSelected(true);
|
console.setSelected(true);
|
||||||
getContentPane().add(console);
|
getContentPane().add(console);
|
||||||
|
|
||||||
final JCheckBox chckbxPrintToTerminal = new JCheckBox(
|
final JCheckBox chckbxPrintToTerminal = new JCheckBox("Print To Command Line");
|
||||||
"Print To Command Line");
|
|
||||||
chckbxPrintToTerminal.setSelected(true);
|
chckbxPrintToTerminal.setSelected(true);
|
||||||
chckbxPrintToTerminal.setBounds(6, 315, 232, 23);
|
chckbxPrintToTerminal.setBounds(6, 315, 232, 23);
|
||||||
getContentPane().add(chckbxPrintToTerminal);
|
getContentPane().add(chckbxPrintToTerminal);
|
||||||
|
|
|
@ -5,8 +5,6 @@ import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
@ -47,16 +45,18 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SystemErrConsole extends JFrame {
|
public class SystemErrConsole extends JFrame
|
||||||
|
{
|
||||||
JTextArea textArea = new JTextArea();
|
private final JTextArea textArea = new JTextArea();
|
||||||
JPanel panel = new JPanel(new BorderLayout());
|
private final JPanel panel = new JPanel(new BorderLayout());
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
private final JScrollPane scrollPane = new JScrollPane();
|
||||||
public JCheckBox check = new JCheckBox("Exact");
|
private final JCheckBox check = new JCheckBox("Exact");
|
||||||
final JTextField field = new JTextField();
|
private final JTextField field = new JTextField();
|
||||||
private final PrintStream originalOut;
|
private final PrintStream originalOut;
|
||||||
|
private final JTextAreaOutputStream s;
|
||||||
|
|
||||||
public SystemErrConsole(String title) {
|
public SystemErrConsole(String title)
|
||||||
|
{
|
||||||
this.setIconImages(Resources.iconList);
|
this.setIconImages(Resources.iconList);
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
setSize(new Dimension(542, 316));
|
setSize(new Dimension(542, 316));
|
||||||
|
@ -64,7 +64,8 @@ public class SystemErrConsole extends JFrame {
|
||||||
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
scrollPane.setViewportView(textArea);
|
scrollPane.setViewportView(textArea);
|
||||||
textArea.addKeyListener(new KeyListener() {
|
textArea.addKeyListener(new KeyListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
|
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
|
||||||
|
@ -113,14 +114,12 @@ public class SystemErrConsole extends JFrame {
|
||||||
});
|
});
|
||||||
scrollPane.setColumnHeaderView(panel);
|
scrollPane.setColumnHeaderView(panel);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
s = new CustomOutputStream(textArea);
|
s = new JTextAreaOutputStream(textArea);
|
||||||
PrintStream printStream = new PrintStream(s);
|
PrintStream printStream = new PrintStream(s);
|
||||||
originalOut = System.err;
|
originalOut = System.err;
|
||||||
System.setErr(printStream);
|
System.setErr(printStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomOutputStream s;
|
|
||||||
|
|
||||||
public void finished() {
|
public void finished() {
|
||||||
if (originalOut != null)
|
if (originalOut != null)
|
||||||
System.setErr(originalOut);
|
System.setErr(originalOut);
|
||||||
|
@ -295,23 +294,5 @@ public class SystemErrConsole extends JFrame {
|
||||||
textArea.setCaretPosition(0);
|
textArea.setCaretPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomOutputStream extends OutputStream {
|
|
||||||
private final StringBuilder sb = new StringBuilder();
|
|
||||||
private final JTextArea textArea;
|
|
||||||
|
|
||||||
public CustomOutputStream(JTextArea textArea) {
|
|
||||||
this.textArea = textArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
textArea.append(sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(int b) throws IOException {
|
|
||||||
sb.append((char) b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6556940545421437508L;
|
private static final long serialVersionUID = -6556940545421437508L;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,10 @@ import the.bytecode.club.bytecodeviewer.Resources;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GraphicalReflectionKit extends JFrame {
|
public class GraphicalReflectionKit extends JFrame
|
||||||
public GraphicalReflectionKit() {
|
{
|
||||||
|
public GraphicalReflectionKit()
|
||||||
|
{
|
||||||
this.setIconImages(Resources.iconList);
|
this.setIconImages(Resources.iconList);
|
||||||
setSize(new Dimension(382, 356));
|
setSize(new Dimension(382, 356));
|
||||||
setTitle("Graphical Reflection Kit");
|
setTitle("Graphical Reflection Kit");
|
||||||
|
|
|
@ -35,7 +35,8 @@ import the.bytecode.club.bytecodeviewer.plugin.preinstalled.MaliciousCodeScanner
|
||||||
* @author Adrianherrera
|
* @author Adrianherrera
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MaliciousCodeScannerOptions extends JFrame {
|
public class MaliciousCodeScannerOptions extends JFrame
|
||||||
|
{
|
||||||
public static void open()
|
public static void open()
|
||||||
{
|
{
|
||||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||||
|
@ -44,15 +45,16 @@ public class MaliciousCodeScannerOptions extends JFrame {
|
||||||
}
|
}
|
||||||
new MaliciousCodeScannerOptions().setVisible(true);
|
new MaliciousCodeScannerOptions().setVisible(true);
|
||||||
}
|
}
|
||||||
public MaliciousCodeScannerOptions() {
|
|
||||||
|
public MaliciousCodeScannerOptions()
|
||||||
|
{
|
||||||
this.setIconImages(Resources.iconList);
|
this.setIconImages(Resources.iconList);
|
||||||
setSize(new Dimension(250, 323));
|
setSize(new Dimension(250, 323));
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Malicious Code Scanner Options");
|
setTitle("Malicious Code Scanner Options");
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
|
|
||||||
final JCheckBox chckbxJavalangreflection = new JCheckBox(
|
final JCheckBox chckbxJavalangreflection = new JCheckBox("java/lang/reflection");
|
||||||
"java/lang/reflection");
|
|
||||||
chckbxJavalangreflection.setSelected(true);
|
chckbxJavalangreflection.setSelected(true);
|
||||||
chckbxJavalangreflection.setBounds(6, 7, 232, 23);
|
chckbxJavalangreflection.setBounds(6, 7, 232, 23);
|
||||||
getContentPane().add(chckbxJavalangreflection);
|
getContentPane().add(chckbxJavalangreflection);
|
||||||
|
@ -66,38 +68,32 @@ public class MaliciousCodeScannerOptions extends JFrame {
|
||||||
chckbxJavaio.setBounds(6, 104, 232, 23);
|
chckbxJavaio.setBounds(6, 104, 232, 23);
|
||||||
getContentPane().add(chckbxJavaio);
|
getContentPane().add(chckbxJavaio);
|
||||||
|
|
||||||
final JCheckBox chckbxJavalangruntime = new JCheckBox(
|
final JCheckBox chckbxJavalangruntime = new JCheckBox("java/lang/Runtime");
|
||||||
"java/lang/Runtime");
|
|
||||||
chckbxJavalangruntime.setSelected(true);
|
chckbxJavalangruntime.setSelected(true);
|
||||||
chckbxJavalangruntime.setBounds(6, 33, 232, 23);
|
chckbxJavalangruntime.setBounds(6, 33, 232, 23);
|
||||||
getContentPane().add(chckbxJavalangruntime);
|
getContentPane().add(chckbxJavalangruntime);
|
||||||
|
|
||||||
final JCheckBox chckbxLdcContainswww = new JCheckBox(
|
final JCheckBox chckbxLdcContainswww = new JCheckBox("LDC contains 'www.'");
|
||||||
"LDC contains 'www.'");
|
|
||||||
chckbxLdcContainswww.setSelected(true);
|
chckbxLdcContainswww.setSelected(true);
|
||||||
chckbxLdcContainswww.setBounds(6, 130, 232, 23);
|
chckbxLdcContainswww.setBounds(6, 130, 232, 23);
|
||||||
getContentPane().add(chckbxLdcContainswww);
|
getContentPane().add(chckbxLdcContainswww);
|
||||||
|
|
||||||
final JCheckBox chckbxLdcContainshttp = new JCheckBox(
|
final JCheckBox chckbxLdcContainshttp = new JCheckBox("LDC contains 'http://'");
|
||||||
"LDC contains 'http://'");
|
|
||||||
chckbxLdcContainshttp.setSelected(true);
|
chckbxLdcContainshttp.setSelected(true);
|
||||||
chckbxLdcContainshttp.setBounds(6, 156, 232, 23);
|
chckbxLdcContainshttp.setBounds(6, 156, 232, 23);
|
||||||
getContentPane().add(chckbxLdcContainshttp);
|
getContentPane().add(chckbxLdcContainshttp);
|
||||||
|
|
||||||
final JCheckBox chckbxLdcContainshttps = new JCheckBox(
|
final JCheckBox chckbxLdcContainshttps = new JCheckBox("LDC contains 'https://'");
|
||||||
"LDC contains 'https://'");
|
|
||||||
chckbxLdcContainshttps.setSelected(true);
|
chckbxLdcContainshttps.setSelected(true);
|
||||||
chckbxLdcContainshttps.setBounds(6, 182, 232, 23);
|
chckbxLdcContainshttps.setBounds(6, 182, 232, 23);
|
||||||
getContentPane().add(chckbxLdcContainshttps);
|
getContentPane().add(chckbxLdcContainshttps);
|
||||||
|
|
||||||
final JCheckBox chckbxLdcMatchesIp = new JCheckBox(
|
final JCheckBox chckbxLdcMatchesIp = new JCheckBox("LDC matches IP regex");
|
||||||
"LDC matches IP regex");
|
|
||||||
chckbxLdcMatchesIp.setSelected(true);
|
chckbxLdcMatchesIp.setSelected(true);
|
||||||
chckbxLdcMatchesIp.setBounds(6, 208, 232, 23);
|
chckbxLdcMatchesIp.setBounds(6, 208, 232, 23);
|
||||||
getContentPane().add(chckbxLdcMatchesIp);
|
getContentPane().add(chckbxLdcMatchesIp);
|
||||||
|
|
||||||
final JCheckBox chckbxNullSecMan = new JCheckBox(
|
final JCheckBox chckbxNullSecMan = new JCheckBox("SecurityManager set to null");
|
||||||
"SecurityManager set to null");
|
|
||||||
chckbxNullSecMan.setSelected(true);
|
chckbxNullSecMan.setSelected(true);
|
||||||
chckbxNullSecMan.setBounds(6, 234, 232, 23);
|
chckbxNullSecMan.setBounds(6, 234, 232, 23);
|
||||||
getContentPane().add(chckbxNullSecMan);
|
getContentPane().add(chckbxNullSecMan);
|
||||||
|
|
|
@ -36,17 +36,19 @@ import the.bytecode.club.bytecodeviewer.plugin.preinstalled.ReplaceStrings;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ReplaceStringsOptions extends JFrame {
|
public class ReplaceStringsOptions extends JFrame
|
||||||
|
{
|
||||||
public static void open()
|
public static void open()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
|
||||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new ReplaceStringsOptions().setVisible(true);
|
new ReplaceStringsOptions().setVisible(true);
|
||||||
}
|
}
|
||||||
public ReplaceStringsOptions() {
|
|
||||||
|
public ReplaceStringsOptions()
|
||||||
|
{
|
||||||
this.setIconImages(Resources.iconList);
|
this.setIconImages(Resources.iconList);
|
||||||
setSize(new Dimension(250, 176));
|
setSize(new Dimension(250, 176));
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
@ -61,49 +63,48 @@ public class ReplaceStringsOptions extends JFrame {
|
||||||
lblNewLabel.setBounds(6, 40, 67, 14);
|
lblNewLabel.setBounds(6, 40, 67, 14);
|
||||||
getContentPane().add(lblNewLabel);
|
getContentPane().add(lblNewLabel);
|
||||||
|
|
||||||
textField = new JTextField();
|
originalLDC = new JTextField();
|
||||||
textField.setBounds(80, 37, 158, 20);
|
originalLDC.setBounds(80, 37, 158, 20);
|
||||||
getContentPane().add(textField);
|
getContentPane().add(originalLDC);
|
||||||
textField.setColumns(10);
|
originalLDC.setColumns(10);
|
||||||
|
|
||||||
JLabel lblNewLabel_1 = new JLabel("New LDC:");
|
JLabel lblNewLabel_1 = new JLabel("New LDC:");
|
||||||
lblNewLabel_1.setBounds(6, 65, 77, 14);
|
lblNewLabel_1.setBounds(6, 65, 77, 14);
|
||||||
getContentPane().add(lblNewLabel_1);
|
getContentPane().add(lblNewLabel_1);
|
||||||
|
|
||||||
textField_1 = new JTextField();
|
newLDC = new JTextField();
|
||||||
textField_1.setColumns(10);
|
newLDC.setColumns(10);
|
||||||
textField_1.setBounds(80, 62, 158, 20);
|
newLDC.setBounds(80, 62, 158, 20);
|
||||||
getContentPane().add(textField_1);
|
getContentPane().add(newLDC);
|
||||||
|
|
||||||
JLabel lblNewLabel_2 = new JLabel("Class:");
|
JLabel lblNewLabel_2 = new JLabel("Class:");
|
||||||
lblNewLabel_2.setBounds(6, 90, 46, 14);
|
lblNewLabel_2.setBounds(6, 90, 46, 14);
|
||||||
getContentPane().add(lblNewLabel_2);
|
getContentPane().add(lblNewLabel_2);
|
||||||
|
|
||||||
textField_2 = new JTextField();
|
classToReplaceIn = new JTextField();
|
||||||
textField_2.setToolTipText("* will search all classes");
|
classToReplaceIn.setToolTipText("* will search all classes");
|
||||||
textField_2.setText("*");
|
classToReplaceIn.setText("*");
|
||||||
textField_2.setBounds(80, 87, 158, 20);
|
classToReplaceIn.setBounds(80, 87, 158, 20);
|
||||||
getContentPane().add(textField_2);
|
getContentPane().add(classToReplaceIn);
|
||||||
textField_2.setColumns(10);
|
classToReplaceIn.setColumns(10);
|
||||||
|
|
||||||
final JCheckBox chckbxNewCheckBox = new JCheckBox(
|
final JCheckBox chckbxNewCheckBox = new JCheckBox("Replace All Contains");
|
||||||
"Replace All Contains");
|
chckbxNewCheckBox.setToolTipText("If it's unticked, it will check if the string equals, if its ticked it will check if"
|
||||||
chckbxNewCheckBox
|
|
||||||
.setToolTipText("If it's unticked, it will check if the string equals, if its ticked it will check if"
|
|
||||||
+ " it contains, then replace the original LDC part of the string.");
|
+ " it contains, then replace the original LDC part of the string.");
|
||||||
chckbxNewCheckBox.setBounds(6, 7, 232, 23);
|
chckbxNewCheckBox.setBounds(6, 7, 232, 23);
|
||||||
getContentPane().add(chckbxNewCheckBox);
|
getContentPane().add(chckbxNewCheckBox);
|
||||||
btnNewButton.addActionListener(arg0 -> {
|
btnNewButton.addActionListener(arg0 -> {
|
||||||
PluginManager.runPlugin(new ReplaceStrings(textField.getText(),
|
PluginManager.runPlugin(new ReplaceStrings(originalLDC.getText(),
|
||||||
textField_1.getText(), textField_2.getText(),
|
newLDC.getText(), classToReplaceIn.getText(),
|
||||||
chckbxNewCheckBox.isSelected()));
|
chckbxNewCheckBox.isSelected()));
|
||||||
dispose();
|
dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = -2662514582647810868L;
|
private static final long serialVersionUID = -2662514582647810868L;
|
||||||
private final JTextField textField;
|
private final JTextField originalLDC;
|
||||||
private final JTextField textField_1;
|
private final JTextField newLDC;
|
||||||
private final JTextField textField_2;
|
private final JTextField classToReplaceIn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
|
||||||
|
|
||||||
|
import the.bytecode.club.bytecodeviewer.Resources;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author http://stackoverflow.com/questions/14968005
|
||||||
|
* @author Konloch
|
||||||
|
*/
|
||||||
|
public class ImageRenderer extends DefaultTreeCellRenderer
|
||||||
|
{
|
||||||
|
//called every time there is a pane update, I.E. whenever you expand a folder
|
||||||
|
@Override
|
||||||
|
public Component getTreeCellRendererComponent(
|
||||||
|
JTree tree, Object value,
|
||||||
|
boolean sel, boolean expanded, boolean leaf,
|
||||||
|
int row, boolean hasFocus)
|
||||||
|
{
|
||||||
|
|
||||||
|
Component ret = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
|
||||||
|
|
||||||
|
if (value instanceof ResourceListPane.MyTreeNode)
|
||||||
|
{
|
||||||
|
ResourceListPane.MyTreeNode node = (ResourceListPane.MyTreeNode) value;
|
||||||
|
String name = node.toString().toLowerCase();
|
||||||
|
|
||||||
|
if (name.endsWith(".jar") || name.endsWith(".war"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.jarIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".zip"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.zipIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".bat"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.batIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".sh"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.shIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".cs"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.csharpIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".c") || name.endsWith(".cpp") || name.endsWith(".h"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.cplusplusIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".apk") || name.endsWith(".dex"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.androidIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg")
|
||||||
|
|| name.endsWith(".bmp") || name.endsWith(".gif"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.imageIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".class"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.classIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".java"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.javaIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".txt") || name.endsWith(".md"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.textIcon);
|
||||||
|
}
|
||||||
|
else if (name.equals("decoded resources"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.decodedIcon);
|
||||||
|
}
|
||||||
|
else if (name.endsWith(".properties") || name.endsWith(".xml") || name.endsWith(".jsp")
|
||||||
|
|| name.endsWith(".mf") || name.endsWith(".config") || name.endsWith(".cfg"))
|
||||||
|
{
|
||||||
|
setIcon(Resources.configIcon);
|
||||||
|
}
|
||||||
|
else if (node.getChildCount() <= 0)
|
||||||
|
{ //random file
|
||||||
|
setIcon(Resources.fileIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //folder
|
||||||
|
ArrayList<TreeNode> nodes = new ArrayList<>();
|
||||||
|
ArrayList<TreeNode> 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.packagesIcon);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon(Resources.folderIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui;
|
package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
|
||||||
|
|
||||||
//TODO fix for Java 9+
|
//TODO fix for Java 9+
|
||||||
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
|
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
@ -19,7 +18,6 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.font.FontRenderContext;
|
import java.awt.font.FontRenderContext;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -33,13 +31,12 @@ import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
|
||||||
import javax.swing.tree.MutableTreeNode;
|
import javax.swing.tree.MutableTreeNode;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.Resources;
|
import the.bytecode.club.bytecodeviewer.gui.VisibleComponent;
|
||||||
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||||
import the.bytecode.club.bytecodeviewer.util.FileDrop;
|
import the.bytecode.club.bytecodeviewer.util.FileDrop;
|
||||||
import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
|
import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
|
||||||
|
@ -641,104 +638,4 @@ public class ResourceListPane extends VisibleComponent implements FileDrop.Liste
|
||||||
BytecodeViewer.getFileContents(nameBuffer.toString()));
|
BytecodeViewer.getFileContents(nameBuffer.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @author http://stackoverflow.com/questions/14968005
|
|
||||||
* @author Konloch
|
|
||||||
*/
|
|
||||||
public static class ImageRenderer extends DefaultTreeCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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 instanceof MyTreeNode) {
|
|
||||||
ResourceListPane.MyTreeNode node =
|
|
||||||
(ResourceListPane.MyTreeNode) value;
|
|
||||||
String name = node.toString().toLowerCase();
|
|
||||||
|
|
||||||
if (name.endsWith(".jar") || name.endsWith(".war")) {
|
|
||||||
setIcon(Resources.jarIcon);
|
|
||||||
} else if (name.endsWith(".zip")) {
|
|
||||||
setIcon(Resources.zipIcon);
|
|
||||||
} else if (name.endsWith(".bat")) {
|
|
||||||
setIcon(Resources.batIcon);
|
|
||||||
} else if (name.endsWith(".sh")) {
|
|
||||||
setIcon(Resources.shIcon);
|
|
||||||
} else if (name.endsWith(".cs")) {
|
|
||||||
setIcon(Resources.csharpIcon);
|
|
||||||
} else if (name.endsWith(".c") || name.endsWith(".cpp") || name.endsWith(".h")) {
|
|
||||||
setIcon(Resources.cplusplusIcon);
|
|
||||||
} else if (name.endsWith(".apk") || name.endsWith(".dex")) {
|
|
||||||
setIcon(Resources.androidIcon);
|
|
||||||
} else if (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(
|
|
||||||
".bmp") || name.endsWith(".gif")) {
|
|
||||||
setIcon(Resources.imageIcon);
|
|
||||||
} else if (name.endsWith(".class")) {
|
|
||||||
setIcon(Resources.classIcon);
|
|
||||||
} else if (name.endsWith(".java")) {
|
|
||||||
setIcon(Resources.javaIcon);
|
|
||||||
} else if (name.endsWith(".txt") || name.endsWith(".md")) {
|
|
||||||
setIcon(Resources.textIcon);
|
|
||||||
} else if (name.equals("decoded resources")) {
|
|
||||||
setIcon(Resources.decodedIcon);
|
|
||||||
} else if (name.endsWith(".properties") || name.endsWith(".xml") || name.endsWith(".jsp") || name.endsWith(".mf") || name.endsWith(".config") || name.endsWith(".cfg")) {
|
|
||||||
setIcon(Resources.configIcon);
|
|
||||||
} else if (node.getChildCount() <= 0) { //random file
|
|
||||||
setIcon(Resources.fileIcon);
|
|
||||||
} else { //folder
|
|
||||||
ArrayList<TreeNode> nodes = new ArrayList<>();
|
|
||||||
ArrayList<TreeNode> 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.packagesIcon);
|
|
||||||
else {
|
|
||||||
setIcon(Resources.folderIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import org.apache.commons.io.FileUtils;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.ResourceListPane;
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.ResourceListPane;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
Loading…
Reference in a new issue