2.3.0 Release
12/16/2014 - Started updating the class viewer. 12/18/2014 - Finished a basic concept of the new class viewer. 12/18/2014 - Fixed an error with importing some jars. 12/18/2014 - Fixed the about window. 12/18/2014 - Finished the final concept for the new class viewer. 12/18/2014 - Threaded save Java files as zip, it now runs in a background thread. 12/18/2014 - Save Java files as zip now prompts you to select a decompiler. 12/18/2014 - Removed the cursor waiting for save Java files as zip. 12/18/2014 - Wrapped the save Java files as zip around an exception handler, it will now safely show the exception if any is thrown. 12/18/2014 - Fixed not escaping the Java strings by default for the Bytecode decompiler. - http://i.imgur.com/YrRnZA7.png 12/18/2014 - Used Eclipse's code formatting tool and formatted the code 12/19/2014 - Priav03 fixed the quick class searcher.
This commit is contained in:
parent
a8220ecb61
commit
4e6647be19
67 changed files with 6467 additions and 5406 deletions
Binary file not shown.
22
README.txt
22
README.txt
|
@ -15,6 +15,15 @@ Code from various projects has been used, including but not limited to:
|
|||
CFR by Lee Benfield
|
||||
CFIDE by Bibl
|
||||
|
||||
Contributors:
|
||||
Konloch
|
||||
Bibl
|
||||
Fluke
|
||||
Righteous
|
||||
sahitya-pavurala
|
||||
priav03
|
||||
If I missed you, please feel free to contact me @Konloch or konloch@gmail.com
|
||||
|
||||
Video: http://the.bytecode.club/bytecodeviewer-video/
|
||||
Source Code: https://github.com/konloch/bytecode-viewer
|
||||
Bin/Archive: https://github.com/konloch/bytecode-viewer/releases
|
||||
|
@ -182,3 +191,16 @@ Changelog:
|
|||
12/13/2014 - Search results are now clickable.
|
||||
--- 2.2.1 ---:
|
||||
12/13/2014 - Fixed an issue with the Bytecode Decompiler. - Thanks bibl
|
||||
--- 2.3.0 ---:
|
||||
12/16/2014 - Started updating the class viewer.
|
||||
12/18/2014 - Finished a basic concept of the new class viewer.
|
||||
12/18/2014 - Fixed an error with importing some jars.
|
||||
12/18/2014 - Fixed the about window.
|
||||
12/18/2014 - Finished the final concept for the new class viewer.
|
||||
12/18/2014 - Threaded save Java files as zip, it now runs in a background thread.
|
||||
12/18/2014 - Save Java files as zip now prompts you to select a decompiler.
|
||||
12/18/2014 - Removed the cursor waiting for save Java files as zip.
|
||||
12/18/2014 - Wrapped the save Java files as zip around an exception handler, it will now safely show the exception if any is thrown.
|
||||
12/18/2014 - Fixed not escaping the Java strings by default for the Bytecode decompiler. - http://i.imgur.com/YrRnZA7.png
|
||||
12/18/2014 - Used Eclipse's code formatting tool and formatted the code
|
||||
12/19/2014 - Priav03 fixed the quick class searcher.
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.2.1
|
||||
2.3.0
|
|
@ -5,13 +5,10 @@ import java.awt.*;
|
|||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: laullon
|
||||
* Date: 08-abr-2003
|
||||
* Time: 13:21:09
|
||||
* Created by IntelliJ IDEA. User: laullon Date: 08-abr-2003 Time: 13:21:09
|
||||
*/
|
||||
public class JHexEditor extends JPanel implements FocusListener,AdjustmentListener,MouseWheelListener
|
||||
{
|
||||
public class JHexEditor extends JPanel implements FocusListener,
|
||||
AdjustmentListener, MouseWheelListener {
|
||||
private static final long serialVersionUID = 2289328616534802372L;
|
||||
byte[] buff;
|
||||
public int cursor;
|
||||
|
@ -23,8 +20,7 @@ public class JHexEditor extends JPanel implements FocusListener,AdjustmentListen
|
|||
private int inicio = 0;
|
||||
private int lineas = 10;
|
||||
|
||||
public JHexEditor(byte[] buff)
|
||||
{
|
||||
public JHexEditor(byte[] buff) {
|
||||
super();
|
||||
this.buff = buff;
|
||||
|
||||
|
@ -62,159 +58,136 @@ public class JHexEditor extends JPanel implements FocusListener,AdjustmentListen
|
|||
this.add(panel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
public void paint(Graphics g) {
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
Rectangle rec = this.getBounds();
|
||||
lineas = (rec.height / fn.getHeight()) - 1;
|
||||
int n = (buff.length / 16) - 1;
|
||||
if(lineas>n) { lineas=n; inicio=0; }
|
||||
if (lineas > n) {
|
||||
lineas = n;
|
||||
inicio = 0;
|
||||
}
|
||||
|
||||
sb.setValues(getInicio(), +getLineas(), 0, buff.length / 16);
|
||||
sb.setValueIsAdjusting(true);
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
protected void actualizaCursor()
|
||||
{
|
||||
protected void actualizaCursor() {
|
||||
int n = (cursor / 16);
|
||||
|
||||
System.out.print("- "+inicio+"<"+n+"<"+(lineas+inicio)+"("+lineas+")");
|
||||
System.out.print("- " + inicio + "<" + n + "<" + (lineas + inicio)
|
||||
+ "(" + lineas + ")");
|
||||
|
||||
if(n<inicio) inicio=n;
|
||||
else if(n>=inicio+lineas) inicio=n-(lineas-1);
|
||||
if (n < inicio)
|
||||
inicio = n;
|
||||
else if (n >= inicio + lineas)
|
||||
inicio = n - (lineas - 1);
|
||||
|
||||
System.out.println(" - "+inicio+"<"+n+"<"+(lineas+inicio)+"("+lineas+")");
|
||||
System.out.println(" - " + inicio + "<" + n + "<" + (lineas + inicio)
|
||||
+ "(" + lineas + ")");
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected int getInicio()
|
||||
{
|
||||
protected int getInicio() {
|
||||
return inicio;
|
||||
}
|
||||
|
||||
protected int getLineas()
|
||||
{
|
||||
protected int getLineas() {
|
||||
return lineas;
|
||||
}
|
||||
|
||||
protected void fondo(Graphics g,int x,int y,int s)
|
||||
{
|
||||
protected void fondo(Graphics g, int x, int y, int s) {
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
g.fillRect(((fn.stringWidth(" ")+1)*x)+border,(fn.getHeight()*y)+border,((fn.stringWidth(" ")+1)*s),fn.getHeight()+1);
|
||||
g.fillRect(((fn.stringWidth(" ") + 1) * x) + border,
|
||||
(fn.getHeight() * y) + border, ((fn.stringWidth(" ") + 1) * s),
|
||||
fn.getHeight() + 1);
|
||||
}
|
||||
|
||||
protected void cuadro(Graphics g,int x,int y,int s)
|
||||
{
|
||||
protected void cuadro(Graphics g, int x, int y, int s) {
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
g.drawRect(((fn.stringWidth(" ")+1)*x)+border,(fn.getHeight()*y)+border,((fn.stringWidth(" ")+1)*s),fn.getHeight()+1);
|
||||
g.drawRect(((fn.stringWidth(" ") + 1) * x) + border,
|
||||
(fn.getHeight() * y) + border, ((fn.stringWidth(" ") + 1) * s),
|
||||
fn.getHeight() + 1);
|
||||
}
|
||||
|
||||
protected void printString(Graphics g,String s,int x,int y)
|
||||
{
|
||||
protected void printString(Graphics g, String s, int x, int y) {
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
g.drawString(s,((fn.stringWidth(" ")+1)*x)+border,((fn.getHeight()*(y+1))-fn.getMaxDescent())+border);
|
||||
g.drawString(s, ((fn.stringWidth(" ") + 1) * x) + border,
|
||||
((fn.getHeight() * (y + 1)) - fn.getMaxDescent()) + border);
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e)
|
||||
{
|
||||
public void focusGained(FocusEvent e) {
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e)
|
||||
{
|
||||
public void focusLost(FocusEvent e) {
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e)
|
||||
{
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
inicio = e.getValue();
|
||||
if(inicio<0) inicio=0;
|
||||
if (inicio < 0)
|
||||
inicio = 0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e)
|
||||
{
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
inicio += (e.getUnitsToScroll());
|
||||
if((inicio+lineas)>=buff.length/16) inicio=(buff.length/16)-lineas;
|
||||
if(inicio<0) inicio=0;
|
||||
if ((inicio + lineas) >= buff.length / 16)
|
||||
inicio = (buff.length / 16) - lineas;
|
||||
if (inicio < 0)
|
||||
inicio = 0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
/*switch(e.getKeyCode())
|
||||
{
|
||||
case 33: // rep
|
||||
if(cursor>=(16*lineas)) cursor-=(16*lineas);
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 34: // fin
|
||||
if(cursor<(buff.length-(16*lineas))) cursor+=(16*lineas);
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 35: // fin
|
||||
cursor=buff.length-1;
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 36: // ini
|
||||
cursor=0;
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 37: // <--
|
||||
if(cursor!=0) cursor--;
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 38: // <--
|
||||
if(cursor>15) cursor-=16;
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 39: // -->
|
||||
if(cursor!=(buff.length-1)) cursor++;
|
||||
actualizaCursor();
|
||||
break;
|
||||
case 40: // -->
|
||||
if(cursor<(buff.length-16)) cursor+=16;
|
||||
actualizaCursor();
|
||||
break;
|
||||
}*/
|
||||
public void keyPressed(KeyEvent e) {
|
||||
/*
|
||||
* switch(e.getKeyCode()) { case 33: // rep if(cursor>=(16*lineas))
|
||||
* cursor-=(16*lineas); actualizaCursor(); break; case 34: // fin
|
||||
* if(cursor<(buff.length-(16*lineas))) cursor+=(16*lineas);
|
||||
* actualizaCursor(); break; case 35: // fin cursor=buff.length-1;
|
||||
* actualizaCursor(); break; case 36: // ini cursor=0;
|
||||
* actualizaCursor(); break; case 37: // <-- if(cursor!=0) cursor--;
|
||||
* actualizaCursor(); break; case 38: // <-- if(cursor>15) cursor-=16;
|
||||
* actualizaCursor(); break; case 39: // --> if(cursor!=(buff.length-1))
|
||||
* cursor++; actualizaCursor(); break; case 40: // -->
|
||||
* if(cursor<(buff.length-16)) cursor+=16; actualizaCursor(); break; }
|
||||
*/
|
||||
}
|
||||
|
||||
private class Columnas extends JPanel
|
||||
{
|
||||
private class Columnas extends JPanel {
|
||||
private static final long serialVersionUID = -1734199617526339842L;
|
||||
|
||||
public Columnas()
|
||||
{
|
||||
public Columnas() {
|
||||
this.setLayout(new BorderLayout(1, 1));
|
||||
}
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension d = new Dimension();
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
int h = fn.getHeight();
|
||||
int nl = 1;
|
||||
d.setSize(((fn.stringWidth(" ")+1)*+((16*3)-1))+(border*2)+1,h*nl+(border*2)+1);
|
||||
d.setSize(((fn.stringWidth(" ") + 1) * +((16 * 3) - 1))
|
||||
+ (border * 2) + 1, h * nl + (border * 2) + 1);
|
||||
return d;
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
public void paint(Graphics g) {
|
||||
Dimension d = getMinimumSize();
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
g.setColor(Color.black);
|
||||
g.setFont(font);
|
||||
|
||||
for(int n=0;n<16;n++)
|
||||
{
|
||||
if(n==(cursor%16)) cuadro(g,n*3,0,2);
|
||||
for (int n = 0; n < 16; n++) {
|
||||
if (n == (cursor % 16))
|
||||
cuadro(g, n * 3, 0, 2);
|
||||
String s = "00" + Integer.toHexString(n);
|
||||
s = s.substring(s.length() - 2);
|
||||
printString(g, s, n * 3, 0);
|
||||
|
@ -222,51 +195,46 @@ public class JHexEditor extends JPanel implements FocusListener,AdjustmentListen
|
|||
}
|
||||
}
|
||||
|
||||
private class Caja extends JPanel
|
||||
{
|
||||
private class Caja extends JPanel {
|
||||
private static final long serialVersionUID = -6124062720565016834L;
|
||||
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension d = new Dimension();
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
int h = fn.getHeight();
|
||||
d.setSize((fn.stringWidth(" ")+1)+(border*2)+1,h+(border*2)+1);
|
||||
d.setSize((fn.stringWidth(" ") + 1) + (border * 2) + 1, h
|
||||
+ (border * 2) + 1);
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class Filas extends JPanel
|
||||
{
|
||||
private class Filas extends JPanel {
|
||||
private static final long serialVersionUID = 8797347523486018051L;
|
||||
|
||||
public Filas()
|
||||
{
|
||||
public Filas() {
|
||||
this.setLayout(new BorderLayout(1, 1));
|
||||
}
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension d = new Dimension();
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
int h = fn.getHeight();
|
||||
int nl = getLineas();
|
||||
d.setSize((fn.stringWidth(" ")+1)*(8)+(border*2)+1,h*nl+(border*2)+1);
|
||||
d.setSize((fn.stringWidth(" ") + 1) * (8) + (border * 2) + 1, h
|
||||
* nl + (border * 2) + 1);
|
||||
return d;
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
public void paint(Graphics g) {
|
||||
Dimension d = getMinimumSize();
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
|
@ -276,9 +244,9 @@ public class JHexEditor extends JPanel implements FocusListener,AdjustmentListen
|
|||
int ini = getInicio();
|
||||
int fin = ini + getLineas();
|
||||
int y = 0;
|
||||
for(int n=ini;n<fin;n++)
|
||||
{
|
||||
if(n==(cursor/16)) cuadro(g,0,y,8);
|
||||
for (int n = ini; n < fin; n++) {
|
||||
if (n == (cursor / 16))
|
||||
cuadro(g, 0, y, 8);
|
||||
String s = "0000000000000" + Integer.toHexString(n);
|
||||
s = s.substring(s.length() - 8);
|
||||
printString(g, s, 0, y++);
|
||||
|
|
|
@ -5,44 +5,38 @@ import java.awt.*;
|
|||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: laullon
|
||||
* Date: 09-abr-2003
|
||||
* Time: 12:47:18
|
||||
* Created by IntelliJ IDEA. User: laullon Date: 09-abr-2003 Time: 12:47:18
|
||||
*/
|
||||
public class JHexEditorASCII extends JComponent implements MouseListener,KeyListener
|
||||
{
|
||||
public class JHexEditorASCII extends JComponent implements MouseListener,
|
||||
KeyListener {
|
||||
private static final long serialVersionUID = 5505374841731053461L;
|
||||
private JHexEditor he;
|
||||
|
||||
public JHexEditorASCII(JHexEditor he)
|
||||
{
|
||||
public JHexEditorASCII(JHexEditor he) {
|
||||
this.he = he;
|
||||
addMouseListener(this);
|
||||
addKeyListener(this);
|
||||
addFocusListener(he);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
public Dimension getPreferredSize() {
|
||||
debug("getPreferredSize()");
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize()
|
||||
{
|
||||
public Dimension getMinimumSize() {
|
||||
debug("getMinimumSize()");
|
||||
|
||||
Dimension d = new Dimension();
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
int h = fn.getHeight();
|
||||
int nl = he.getLineas();
|
||||
d.setSize((fn.stringWidth(" ")+1)*(16)+(he.border*2)+1,h*nl+(he.border*2)+1);
|
||||
d.setSize((fn.stringWidth(" ") + 1) * (16) + (he.border * 2) + 1, h
|
||||
* nl + (he.border * 2) + 1);
|
||||
return d;
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
public void paint(Graphics g) {
|
||||
debug("paint(" + g + ")");
|
||||
debug("cursor=" + he.cursor + " buff.length=" + he.buff.length);
|
||||
Dimension d = getMinimumSize();
|
||||
|
@ -55,27 +49,31 @@ public class JHexEditorASCII extends JComponent implements MouseListener,KeyList
|
|||
// datos ascii
|
||||
int ini = he.getInicio() * 16;
|
||||
int fin = ini + (he.getLineas() * 16);
|
||||
if(fin>he.buff.length) fin=he.buff.length;
|
||||
if (fin > he.buff.length)
|
||||
fin = he.buff.length;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for(int n=ini;n<fin;n++)
|
||||
{
|
||||
if(n==he.cursor)
|
||||
{
|
||||
for (int n = ini; n < fin; n++) {
|
||||
if (n == he.cursor) {
|
||||
g.setColor(Color.blue);
|
||||
if(hasFocus()) he.fondo(g,x,y,1); else he.cuadro(g,x,y,1);
|
||||
if(hasFocus()) g.setColor(Color.white); else g.setColor(Color.black);
|
||||
} else
|
||||
{
|
||||
if (hasFocus())
|
||||
he.fondo(g, x, y, 1);
|
||||
else
|
||||
he.cuadro(g, x, y, 1);
|
||||
if (hasFocus())
|
||||
g.setColor(Color.white);
|
||||
else
|
||||
g.setColor(Color.black);
|
||||
} else {
|
||||
g.setColor(Color.black);
|
||||
}
|
||||
|
||||
String s = "" + new Character((char) he.buff[n]);
|
||||
if((he.buff[n]<20)||(he.buff[n]>126)) s=""+(char)16;
|
||||
if ((he.buff[n] < 20) || (he.buff[n] > 126))
|
||||
s = "" + (char) 16;
|
||||
he.printString(g, s, (x++), y);
|
||||
if(x==16)
|
||||
{
|
||||
if (x == 16) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
|
@ -83,14 +81,13 @@ public class JHexEditorASCII extends JComponent implements MouseListener,KeyList
|
|||
|
||||
}
|
||||
|
||||
private void debug(String s)
|
||||
{
|
||||
if(he.DEBUG) System.out.println("JHexEditorASCII ==> "+s);
|
||||
private void debug(String s) {
|
||||
if (he.DEBUG)
|
||||
System.out.println("JHexEditorASCII ==> " + s);
|
||||
}
|
||||
|
||||
// calcular la posicion del raton
|
||||
public int calcularPosicionRaton(int x,int y)
|
||||
{
|
||||
public int calcularPosicionRaton(int x, int y) {
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
x = x / (fn.stringWidth(" ") + 1);
|
||||
y = y / fn.getHeight();
|
||||
|
@ -99,54 +96,46 @@ public class JHexEditorASCII extends JComponent implements MouseListener,KeyList
|
|||
}
|
||||
|
||||
// mouselistener
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
debug("mouseClicked(" + e + ")");
|
||||
he.cursor = calcularPosicionRaton(e.getX(), e.getY());
|
||||
this.requestFocus();
|
||||
he.repaint();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
// KeyListener
|
||||
public void keyTyped(KeyEvent e)
|
||||
{
|
||||
/*debug("keyTyped("+e+")");
|
||||
|
||||
he.buff[he.cursor]=(byte)e.getKeyChar();
|
||||
|
||||
if(he.cursor!=(he.buff.length-1)) he.cursor++;
|
||||
he.repaint();*/
|
||||
public void keyTyped(KeyEvent e) {
|
||||
/*
|
||||
* debug("keyTyped("+e+")");
|
||||
*
|
||||
* he.buff[he.cursor]=(byte)e.getKeyChar();
|
||||
*
|
||||
* if(he.cursor!=(he.buff.length-1)) he.cursor++; he.repaint();
|
||||
*/
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
public void keyPressed(KeyEvent e) {
|
||||
debug("keyPressed(" + e + ")");
|
||||
he.keyPressed(e);
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e)
|
||||
{
|
||||
public void keyReleased(KeyEvent e) {
|
||||
debug("keyReleased(" + e + ")");
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable()
|
||||
{
|
||||
public boolean isFocusTraversable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,51 +5,41 @@ import java.awt.*;
|
|||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: laullon
|
||||
* Date: 09-abr-2003
|
||||
* Time: 12:47:32
|
||||
* Created by IntelliJ IDEA. User: laullon Date: 09-abr-2003 Time: 12:47:32
|
||||
*/
|
||||
public class JHexEditorHEX extends JComponent implements MouseListener,KeyListener
|
||||
{
|
||||
public class JHexEditorHEX extends JComponent implements MouseListener,
|
||||
KeyListener {
|
||||
private static final long serialVersionUID = 1481995655372014571L;
|
||||
private JHexEditor he;
|
||||
private int cursor = 0;
|
||||
|
||||
public JHexEditorHEX(JHexEditor he)
|
||||
{
|
||||
public JHexEditorHEX(JHexEditor he) {
|
||||
this.he = he;
|
||||
addMouseListener(this);
|
||||
addKeyListener(this);
|
||||
addFocusListener(he);
|
||||
}
|
||||
|
||||
/*public Dimension getPreferredSize()
|
||||
{
|
||||
debug("getPreferredSize()");
|
||||
return getMinimumSize();
|
||||
}*/
|
||||
/*
|
||||
* public Dimension getPreferredSize() { debug("getPreferredSize()"); return
|
||||
* getMinimumSize(); }
|
||||
*/
|
||||
|
||||
public Dimension getMaximumSize()
|
||||
{
|
||||
public Dimension getMaximumSize() {
|
||||
debug("getMaximumSize()");
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
/*public Dimension getMinimumSize()
|
||||
{
|
||||
debug("getMinimumSize()");
|
||||
/*
|
||||
* public Dimension getMinimumSize() { debug("getMinimumSize()");
|
||||
*
|
||||
* Dimension d=new Dimension(); FontMetrics fn=getFontMetrics(he.font); int
|
||||
* h=fn.getHeight(); int nl=he.getLineas();
|
||||
* d.setSize(((fn.stringWidth(" ")+1
|
||||
* )*+((16*3)-1))+(he.border*2)+1,h*nl+(he.border*2)+1); return d; }
|
||||
*/
|
||||
|
||||
Dimension d=new Dimension();
|
||||
FontMetrics fn=getFontMetrics(he.font);
|
||||
int h=fn.getHeight();
|
||||
int nl=he.getLineas();
|
||||
d.setSize(((fn.stringWidth(" ")+1)*+((16*3)-1))+(he.border*2)+1,h*nl+(he.border*2)+1);
|
||||
return d;
|
||||
}*/
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
public void paint(Graphics g) {
|
||||
debug("paint(" + g + ")");
|
||||
debug("cursor=" + he.cursor + " buff.length=" + he.buff.length);
|
||||
Dimension d = getMinimumSize();
|
||||
|
@ -61,52 +51,49 @@ public class JHexEditorHEX extends JComponent implements MouseListener,KeyListen
|
|||
|
||||
int ini = he.getInicio() * 16;
|
||||
int fin = ini + (he.getLineas() * 16);
|
||||
if(fin>he.buff.length) fin=he.buff.length;
|
||||
if (fin > he.buff.length)
|
||||
fin = he.buff.length;
|
||||
|
||||
// datos hex
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for(int n=ini;n<fin;n++)
|
||||
{
|
||||
if(n==he.cursor)
|
||||
{
|
||||
if(hasFocus())
|
||||
{
|
||||
for (int n = ini; n < fin; n++) {
|
||||
if (n == he.cursor) {
|
||||
if (hasFocus()) {
|
||||
g.setColor(Color.black);
|
||||
he.fondo(g, (x * 3), y, 2);
|
||||
g.setColor(Color.blue);
|
||||
he.fondo(g, (x * 3) + cursor, y, 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
g.setColor(Color.blue);
|
||||
he.cuadro(g, (x * 3), y, 2);
|
||||
}
|
||||
|
||||
if(hasFocus()) g.setColor(Color.white); else g.setColor(Color.black);
|
||||
} else
|
||||
{
|
||||
if (hasFocus())
|
||||
g.setColor(Color.white);
|
||||
else
|
||||
g.setColor(Color.black);
|
||||
} else {
|
||||
g.setColor(Color.black);
|
||||
}
|
||||
|
||||
String s = ("0" + Integer.toHexString(he.buff[n]));
|
||||
s = s.substring(s.length() - 2);
|
||||
he.printString(g, s, ((x++) * 3), y);
|
||||
if(x==16)
|
||||
{
|
||||
if (x == 16) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void debug(String s)
|
||||
{
|
||||
if(he.DEBUG) System.out.println("JHexEditorHEX ==> "+s);
|
||||
private void debug(String s) {
|
||||
if (he.DEBUG)
|
||||
System.out.println("JHexEditorHEX ==> " + s);
|
||||
}
|
||||
|
||||
// calcular la posicion del raton
|
||||
public int calcularPosicionRaton(int x,int y)
|
||||
{
|
||||
public int calcularPosicionRaton(int x, int y) {
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
x = x / ((fn.stringWidth(" ") + 1) * 3);
|
||||
y = y / fn.getHeight();
|
||||
|
@ -115,64 +102,53 @@ public class JHexEditorHEX extends JComponent implements MouseListener,KeyListen
|
|||
}
|
||||
|
||||
// mouselistener
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
debug("mouseClicked(" + e + ")");
|
||||
he.cursor = calcularPosicionRaton(e.getX(), e.getY());
|
||||
this.requestFocus();
|
||||
he.repaint();
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
// KeyListener
|
||||
public void keyTyped(KeyEvent e)
|
||||
{
|
||||
public void keyTyped(KeyEvent e) {
|
||||
debug("keyTyped(" + e + ")");
|
||||
|
||||
/*char c=e.getKeyChar();
|
||||
if(((c>='0')&&(c<='9'))||((c>='A')&&(c<='F'))||((c>='a')&&(c<='f')))
|
||||
{
|
||||
char[] str=new char[2];
|
||||
String n="00"+Integer.toHexString((int)he.buff[he.cursor]);
|
||||
if(n.length()>2) n=n.substring(n.length()-2);
|
||||
str[1-cursor]=n.charAt(1-cursor);
|
||||
str[cursor]=e.getKeyChar();
|
||||
he.buff[he.cursor]=(byte)Integer.parseInt(new String(str),16);
|
||||
|
||||
if(cursor!=1) cursor=1;
|
||||
else if(he.cursor!=(he.buff.length-1)){ he.cursor++; cursor=0;}
|
||||
he.actualizaCursor();
|
||||
}*/
|
||||
/*
|
||||
* char c=e.getKeyChar();
|
||||
* if(((c>='0')&&(c<='9'))||((c>='A')&&(c<='F'))||((c>='a')&&(c<='f')))
|
||||
* { char[] str=new char[2]; String
|
||||
* n="00"+Integer.toHexString((int)he.buff[he.cursor]); if(n.length()>2)
|
||||
* n=n.substring(n.length()-2); str[1-cursor]=n.charAt(1-cursor);
|
||||
* str[cursor]=e.getKeyChar();
|
||||
* he.buff[he.cursor]=(byte)Integer.parseInt(new String(str),16);
|
||||
*
|
||||
* if(cursor!=1) cursor=1; else if(he.cursor!=(he.buff.length-1)){
|
||||
* he.cursor++; cursor=0;} he.actualizaCursor(); }
|
||||
*/
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
public void keyPressed(KeyEvent e) {
|
||||
debug("keyPressed(" + e + ")");
|
||||
he.keyPressed(e);
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e)
|
||||
{
|
||||
public void keyReleased(KeyEvent e) {
|
||||
debug("keyReleased(" + e + ")");
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable()
|
||||
{
|
||||
public boolean isFocusTraversable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ public class DiskReader {
|
|||
/**
|
||||
* Used to load from file, allows caching
|
||||
*/
|
||||
public synchronized static ArrayList<String> loadArrayList(String fileName, boolean cache) {
|
||||
public synchronized static ArrayList<String> loadArrayList(String fileName,
|
||||
boolean cache) {
|
||||
ArrayList<String> array = new ArrayList<String>();
|
||||
if (!map.containsKey(fileName)) {
|
||||
try {
|
||||
|
@ -54,10 +55,12 @@ public class DiskReader {
|
|||
/**
|
||||
* Used to load from file
|
||||
*/
|
||||
public synchronized static String loadAsString(String fileName) throws Exception {
|
||||
public synchronized static String loadAsString(String fileName)
|
||||
throws Exception {
|
||||
String s = "";
|
||||
|
||||
BufferedReader reader = new BufferedReader(new FileReader(new File(fileName)));
|
||||
BufferedReader reader = new BufferedReader(new FileReader(new File(
|
||||
fileName)));
|
||||
String add;
|
||||
|
||||
while ((add = reader.readLine()) != null)
|
||||
|
@ -69,10 +72,10 @@ public class DiskReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Used to load a string via line number
|
||||
* lineNumber = -1 means random.
|
||||
* Used to load a string via line number lineNumber = -1 means random.
|
||||
*/
|
||||
public static String loadString(String fileName, int lineNumber, boolean cache) throws Exception {
|
||||
public static String loadString(String fileName, int lineNumber,
|
||||
boolean cache) throws Exception {
|
||||
|
||||
ArrayList<String> array;
|
||||
if (!map.containsKey(fileName)) {
|
||||
|
|
|
@ -16,9 +16,13 @@ public class DiskWriter {
|
|||
|
||||
/**
|
||||
* Used to insert a difference string with preserving the file extension
|
||||
* @param fileName The file name
|
||||
* @param difference Normally an integer
|
||||
* @return The filename with the difference inserted and the file extension preserved
|
||||
*
|
||||
* @param fileName
|
||||
* The file name
|
||||
* @param difference
|
||||
* Normally an integer
|
||||
* @return The filename with the difference inserted and the file extension
|
||||
* preserved
|
||||
*/
|
||||
public static String insertFileName(String fileName, String difference) {
|
||||
String[] babe = fileName.split("\\.");
|
||||
|
@ -39,12 +43,15 @@ public class DiskWriter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Writes a new line to the file, if it doesn't exist it will automatically create it.
|
||||
* Writes a new line to the file, if it doesn't exist it will automatically
|
||||
* create it.
|
||||
*
|
||||
* @param filename
|
||||
* @param fileContents
|
||||
* @param debug
|
||||
*/
|
||||
public static synchronized void writeNewLine(String filename, byte[] fileContents, boolean debug) {
|
||||
public static synchronized void writeNewLine(String filename,
|
||||
byte[] fileContents, boolean debug) {
|
||||
PrintWriter writer = null;
|
||||
String original = filename;
|
||||
int counter = 0;
|
||||
|
@ -52,14 +59,16 @@ public class DiskWriter {
|
|||
boolean saved = false;
|
||||
while (!saved) {
|
||||
try {
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(
|
||||
filename, true)));
|
||||
writer.println(fileContents);
|
||||
if (debug)
|
||||
System.out.println("Saved " + filename + " to disk");
|
||||
saved = true;
|
||||
} catch (Exception e) {
|
||||
if (debug)
|
||||
System.out.println("Failed saving, trying to save as " + filename);
|
||||
System.out.println("Failed saving, trying to save as "
|
||||
+ filename);
|
||||
if (original.contains(".")) {
|
||||
filename = insertFileName(original, "" + counter);
|
||||
} else
|
||||
|
@ -72,11 +81,13 @@ public class DiskWriter {
|
|||
|
||||
/**
|
||||
* Writes a string to the file
|
||||
*
|
||||
* @param filename
|
||||
* @param lineToWrite
|
||||
* @param debug
|
||||
*/
|
||||
public static synchronized void writeNewLine(String filename, String lineToWrite, boolean debug) {
|
||||
public static synchronized void writeNewLine(String filename,
|
||||
String lineToWrite, boolean debug) {
|
||||
PrintWriter writer = null;
|
||||
String original = filename;
|
||||
int counter = 0;
|
||||
|
@ -84,14 +95,17 @@ public class DiskWriter {
|
|||
boolean saved = false;
|
||||
while (!saved) {
|
||||
try {
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(
|
||||
filename, true)));
|
||||
writer.println(lineToWrite);
|
||||
if (debug)
|
||||
System.out.println("Saved " + filename+">"+lineToWrite + " to disk");
|
||||
System.out.println("Saved " + filename + ">" + lineToWrite
|
||||
+ " to disk");
|
||||
saved = true;
|
||||
} catch (Exception e) {
|
||||
if (debug)
|
||||
System.out.println("Failed saving, trying to save as " + filename);
|
||||
System.out.println("Failed saving, trying to save as "
|
||||
+ filename);
|
||||
if (original.contains(".")) {
|
||||
filename = insertFileName(original, "" + counter);
|
||||
} else
|
||||
|
@ -103,12 +117,15 @@ public class DiskWriter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes the original file if it exists, then writes the fileContents[] to the file.
|
||||
* Deletes the original file if it exists, then writes the fileContents[] to
|
||||
* the file.
|
||||
*
|
||||
* @param filename
|
||||
* @param fileContents
|
||||
* @param debug
|
||||
*/
|
||||
public static synchronized void replaceFile(String filename, byte[] fileContents, boolean debug) {
|
||||
public static synchronized void replaceFile(String filename,
|
||||
byte[] fileContents, boolean debug) {
|
||||
File f = new File(filename);
|
||||
if (f.exists())
|
||||
f.delete();
|
||||
|
@ -119,14 +136,16 @@ public class DiskWriter {
|
|||
boolean saved = false;
|
||||
while (!saved) {
|
||||
try {
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(
|
||||
filename, true)));
|
||||
writer.println(fileContents);
|
||||
if (debug)
|
||||
System.out.println("Saved " + filename + " to disk");
|
||||
saved = true;
|
||||
} catch (Exception e) {
|
||||
if (debug)
|
||||
System.out.println("Failed saving, trying to save as " + filename);
|
||||
System.out.println("Failed saving, trying to save as "
|
||||
+ filename);
|
||||
if (original.contains(".")) {
|
||||
filename = insertFileName(original, "" + counter);
|
||||
} else
|
||||
|
@ -138,12 +157,15 @@ public class DiskWriter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes the original file if it exists, then writes the lineToWrite to the file.
|
||||
* Deletes the original file if it exists, then writes the lineToWrite to
|
||||
* the file.
|
||||
*
|
||||
* @param filename
|
||||
* @param lineToWrite
|
||||
* @param debug
|
||||
*/
|
||||
public static synchronized void replaceFile(String filename, String lineToWrite, boolean debug) {
|
||||
public static synchronized void replaceFile(String filename,
|
||||
String lineToWrite, boolean debug) {
|
||||
File f = new File(filename);
|
||||
if (f.exists())
|
||||
f.delete();
|
||||
|
@ -154,14 +176,17 @@ public class DiskWriter {
|
|||
boolean saved = false;
|
||||
while (!saved) {
|
||||
try {
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
|
||||
writer = new PrintWriter(new BufferedWriter(new FileWriter(
|
||||
filename, true)));
|
||||
writer.println(lineToWrite);
|
||||
if (debug)
|
||||
System.out.println("Saved " + filename+">"+lineToWrite + " to disk");
|
||||
System.out.println("Saved " + filename + ">" + lineToWrite
|
||||
+ " to disk");
|
||||
saved = true;
|
||||
} catch (Exception e) {
|
||||
if (debug)
|
||||
System.out.println("Failed saving, trying to save as " + filename + "_");
|
||||
System.out.println("Failed saving, trying to save as "
|
||||
+ filename + "_");
|
||||
if (original.contains(".")) {
|
||||
filename = insertFileName(original, "" + counter);
|
||||
} else
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -70,8 +70,10 @@ public class FileDrop {
|
|||
* elements contained within as drop targets, though only the top level
|
||||
* container will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.awt.Component c, final Listener listener) {
|
||||
|
@ -89,9 +91,12 @@ public class FileDrop {
|
|||
* its children components will also listen for drops, though only the
|
||||
* parent will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param recursive
|
||||
* Recursively set children as drop targets.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.awt.Component c, final boolean recursive,
|
||||
|
@ -111,10 +116,13 @@ public class FileDrop {
|
|||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for the
|
||||
* parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.io.PrintStream out, final java.awt.Component c,
|
||||
|
@ -136,11 +144,15 @@ public class FileDrop {
|
|||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for the
|
||||
* parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param recursive
|
||||
* Recursively set children as drop targets.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.io.PrintStream out, final java.awt.Component c,
|
||||
|
@ -156,10 +168,12 @@ public class FileDrop {
|
|||
/**
|
||||
* Constructor with a specified border
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging
|
||||
* occurs.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param dragBorder
|
||||
* Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.awt.Component c,
|
||||
|
@ -177,11 +191,14 @@ public class FileDrop {
|
|||
* each of its children components will also listen for drops, though only
|
||||
* the parent will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging
|
||||
* occurs.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param dragBorder
|
||||
* Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param recursive
|
||||
* Recursively set children as drop targets.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.awt.Component c,
|
||||
|
@ -197,11 +214,14 @@ public class FileDrop {
|
|||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for the
|
||||
* parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging
|
||||
* occurs.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param out
|
||||
* PrintStream to record debugging info or null for no debugging.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param dragBorder
|
||||
* Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.io.PrintStream out, final java.awt.Component c,
|
||||
|
@ -220,12 +240,16 @@ public class FileDrop {
|
|||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for the
|
||||
* parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging
|
||||
* occurs.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @param out
|
||||
* PrintStream to record debugging info or null for no debugging.
|
||||
* @param c
|
||||
* Component on which files will be dropped.
|
||||
* @param dragBorder
|
||||
* Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param recursive
|
||||
* Recursively set children as drop targets.
|
||||
* @param listener
|
||||
* Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(final java.io.PrintStream out, final java.awt.Component c,
|
||||
|
@ -293,7 +317,8 @@ public class FileDrop {
|
|||
// Get a useful list
|
||||
final java.util.List fileList = (java.util.List) tr
|
||||
.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor);
|
||||
final java.util.Iterator iterator = fileList.iterator();
|
||||
final java.util.Iterator iterator = fileList
|
||||
.iterator();
|
||||
|
||||
// Convert list to array
|
||||
final java.io.File[] filesTemp = new java.io.File[fileList
|
||||
|
@ -363,7 +388,8 @@ public class FileDrop {
|
|||
catch (final java.awt.datatransfer.UnsupportedFlavorException ufe) {
|
||||
log(out,
|
||||
"FileDrop: UnsupportedFlavorException - abort:");
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(ufe);
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
|
||||
ufe);
|
||||
evt.rejectDrop();
|
||||
} // end catch: UnsupportedFlavorException
|
||||
finally {
|
||||
|
@ -562,7 +588,8 @@ public class FileDrop {
|
|||
* all components contained within <var>c</var> if <var>c</var> is a
|
||||
* {@link java.awt.Container}.
|
||||
*
|
||||
* @param c The component to unregister as a drop target
|
||||
* @param c
|
||||
* The component to unregister as a drop target
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean remove(final java.awt.Component c) {
|
||||
|
@ -574,15 +601,19 @@ public class FileDrop {
|
|||
* the all children. You should call this if you add and remove components
|
||||
* after you've set up the drag-and-drop.
|
||||
*
|
||||
* @param out Optional {@link java.io.PrintStream} for logging drag and drop
|
||||
* @param out
|
||||
* Optional {@link java.io.PrintStream} for logging drag and drop
|
||||
* messages
|
||||
* @param c The component to unregister
|
||||
* @param recursive Recursively unregister components within a container
|
||||
* @param c
|
||||
* The component to unregister
|
||||
* @param recursive
|
||||
* Recursively unregister components within a container
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean remove(final java.io.PrintStream out,
|
||||
final java.awt.Component c, final boolean recursive) { // Make sure
|
||||
// we support
|
||||
// we
|
||||
// support
|
||||
// dnd.
|
||||
if (supportsDnD()) {
|
||||
log(out, "FileDrop: Removing drag-and-drop hooks.");
|
||||
|
@ -623,7 +654,8 @@ public class FileDrop {
|
|||
/**
|
||||
* This method is called when files have been successfully dropped.
|
||||
*
|
||||
* @param files An array of <tt>File</tt>s that were dropped.
|
||||
* @param files
|
||||
* An array of <tt>File</tt>s that were dropped.
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract void filesDropped(java.io.File[] files);
|
||||
|
@ -655,7 +687,8 @@ public class FileDrop {
|
|||
* Constructs an {@link Event} with the array of files that were dropped
|
||||
* and the {@link FileDrop} that initiated the event.
|
||||
*
|
||||
* @param files The array of files that were dropped
|
||||
* @param files
|
||||
* The array of files that were dropped
|
||||
* @source The event source
|
||||
* @since 1.1
|
||||
*/
|
||||
|
@ -761,7 +794,8 @@ public class FileDrop {
|
|||
* from <code>data.getClass()</code> and the MIME type
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @param data The data to transfer
|
||||
* @param data
|
||||
* The data to transfer
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(final Object data) {
|
||||
|
@ -776,7 +810,8 @@ public class FileDrop {
|
|||
* other than the default {@link #DATA_FLAVOR}.
|
||||
*
|
||||
* @see Fetcher
|
||||
* @param fetcher The {@link Fetcher} that will return the data object
|
||||
* @param fetcher
|
||||
* The {@link Fetcher} that will return the data object
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(final Fetcher fetcher) {
|
||||
|
@ -792,9 +827,11 @@ public class FileDrop {
|
|||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @see Fetcher
|
||||
* @param dataClass The {@link java.lang.Class} to use in the custom
|
||||
* data flavor
|
||||
* @param fetcher The {@link Fetcher} that will return the data object
|
||||
* @param dataClass
|
||||
* The {@link java.lang.Class} to use in the custom data
|
||||
* flavor
|
||||
* @param fetcher
|
||||
* The {@link Fetcher} that will return the data object
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(final Class dataClass, final Fetcher fetcher) {
|
||||
|
@ -849,7 +886,8 @@ public class FileDrop {
|
|||
* requested data flavor is not supported, then the
|
||||
* {@link Fetcher#getObject getObject()} method will not be called.
|
||||
*
|
||||
* @param flavor The data flavor for the data to return
|
||||
* @param flavor
|
||||
* The data flavor for the data to return
|
||||
* @return The dropped data
|
||||
* @since 1.1
|
||||
*/
|
||||
|
@ -875,7 +913,8 @@ public class FileDrop {
|
|||
* flavors. Flavors are supported using the <code>equals(...)</code>
|
||||
* method.
|
||||
*
|
||||
* @param flavor The data flavor to check
|
||||
* @param flavor
|
||||
* The data flavor to check
|
||||
* @return Whether or not the flavor is supported
|
||||
* @since 1.1
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,9 @@ public class JarUtils {
|
|||
|
||||
private static JarInputStream jis;
|
||||
private static JarEntry entry;
|
||||
public static void put(final File jarFile, final HashMap<String, ClassNode> clazzList) throws IOException {
|
||||
|
||||
public static void put(final File jarFile,
|
||||
final HashMap<String, ClassNode> clazzList) throws IOException {
|
||||
jis = new JarInputStream(new FileInputStream(jarFile));
|
||||
while ((entry = jis.getNextJarEntry()) != null) {
|
||||
final String name = entry.getName();
|
||||
|
@ -52,6 +54,7 @@ public class JarUtils {
|
|||
private static ByteArrayOutputStream baos = null;
|
||||
private static byte[] buffer = null;
|
||||
private static int a = 0;
|
||||
|
||||
public static byte[] getBytes(final InputStream is) throws IOException {
|
||||
baos = new ByteArrayOutputStream();
|
||||
buffer = new byte[1024];
|
||||
|
@ -66,17 +69,24 @@ public class JarUtils {
|
|||
|
||||
private static ClassReader cr = null;
|
||||
private static ClassNode cn = null;
|
||||
|
||||
public static ClassNode getNode(final byte[] bytez) {
|
||||
cr = new ClassReader(bytez);
|
||||
cn = new ClassNode();
|
||||
try {
|
||||
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||
} catch (Exception e) {
|
||||
cr.accept(cn, ClassReader.SKIP_FRAMES);
|
||||
}
|
||||
cr = null;
|
||||
return cn;
|
||||
}
|
||||
|
||||
public static void saveAsJar(ArrayList<ClassNode> nodeList, String path, String manifest) {
|
||||
public static void saveAsJar(ArrayList<ClassNode> nodeList, String path,
|
||||
String manifest) {
|
||||
try {
|
||||
JarOutputStream out = new JarOutputStream(new FileOutputStream(path));
|
||||
JarOutputStream out = new JarOutputStream(
|
||||
new FileOutputStream(path));
|
||||
for (ClassNode cn : nodeList) {
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
|
@ -90,7 +100,8 @@ public class JarUtils {
|
|||
out.write((manifest.trim() + "\r\n\r\n").getBytes());
|
||||
out.closeEntry();
|
||||
|
||||
for (Entry<String, byte[]> entry : BytecodeViewer.loadedResources.entrySet()) {
|
||||
for (Entry<String, byte[]> entry : BytecodeViewer.loadedResources
|
||||
.entrySet()) {
|
||||
String filename = entry.getKey();
|
||||
if (!filename.startsWith("META-INF")) {
|
||||
out.putNextEntry(new ZipEntry(filename));
|
||||
|
@ -107,7 +118,8 @@ public class JarUtils {
|
|||
|
||||
public static void saveAsJar(ArrayList<ClassNode> nodeList, String path) {
|
||||
try {
|
||||
JarOutputStream out = new JarOutputStream(new FileOutputStream(path));
|
||||
JarOutputStream out = new JarOutputStream(
|
||||
new FileOutputStream(path));
|
||||
for (ClassNode cn : nodeList) {
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
|
@ -117,7 +129,8 @@ public class JarUtils {
|
|||
out.closeEntry();
|
||||
}
|
||||
|
||||
for (Entry<String, byte[]> entry : BytecodeViewer.loadedResources.entrySet()) {
|
||||
for (Entry<String, byte[]> entry : BytecodeViewer.loadedResources
|
||||
.entrySet()) {
|
||||
String filename = entry.getKey();
|
||||
if (!filename.startsWith("META-INF")) {
|
||||
out.putNextEntry(new ZipEntry(filename));
|
||||
|
|
|
@ -40,95 +40,68 @@ public class RuntimeOverride {
|
|||
}
|
||||
}
|
||||
|
||||
/*public Process exec(String command, String[] envp) throws IOException {
|
||||
return exec(command, envp, null);
|
||||
}
|
||||
|
||||
public Process exec(String command, String[] envp, File dir)
|
||||
throws IOException {
|
||||
if (command.length() == 0)
|
||||
throw new IllegalArgumentException("Empty command");
|
||||
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
String[] cmdarray = new String[st.countTokens()];
|
||||
for (int i = 0; st.hasMoreTokens(); i++)
|
||||
cmdarray[i] = st.nextToken();
|
||||
return exec(cmdarray, envp, dir);
|
||||
}
|
||||
|
||||
public Process exec(String cmdarray[]) throws IOException {
|
||||
return exec(cmdarray, null, null);
|
||||
}
|
||||
|
||||
public Process exec(String[] cmdarray, String[] envp) throws IOException {
|
||||
return exec(cmdarray, envp, null);
|
||||
}
|
||||
|
||||
public Process exec(String[] cmdarray, String[] envp, File dir)
|
||||
throws IOException {
|
||||
return new ProcessBuilder(cmdarray)
|
||||
.environment(envp)
|
||||
.directory(dir)
|
||||
.start();
|
||||
}
|
||||
|
||||
public native int availableProcessors();
|
||||
|
||||
public native long freeMemory();
|
||||
|
||||
public native long totalMemory();
|
||||
|
||||
public native long maxMemory();
|
||||
|
||||
public void gc() {
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
public void runFinalization() {
|
||||
Runtime.getRuntime().runFinalization();
|
||||
}
|
||||
|
||||
public native void traceInstructions(boolean on);
|
||||
|
||||
public native void traceMethodCalls(boolean on);
|
||||
|
||||
public void load(String filename) {
|
||||
load0(Reflection.getCallerClass(), filename);
|
||||
}
|
||||
|
||||
synchronized void load0(Class fromClass, String filename) {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkLink(filename);
|
||||
}
|
||||
if (!(new File(filename).isAbsolute())) {
|
||||
throw new UnsatisfiedLinkError(
|
||||
"Expecting an absolute path of the library: " + filename);
|
||||
}
|
||||
ClassLoader.loadLibrary(fromClass, filename, true);
|
||||
}
|
||||
|
||||
public void loadLibrary(String libname) {
|
||||
loadLibrary0(Reflection.getCallerClass(), libname);
|
||||
}
|
||||
|
||||
synchronized void loadLibrary0(Class fromClass, String libname) {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkLink(libname);
|
||||
}
|
||||
if (libname.indexOf((int)File.separatorChar) != -1) {
|
||||
throw new UnsatisfiedLinkError(
|
||||
"Directory separator should not appear in library name: " + libname);
|
||||
}
|
||||
ClassLoader.loadLibrary(fromClass, libname, false);
|
||||
}
|
||||
|
||||
public InputStream getLocalizedInputStream(InputStream in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
public OutputStream getLocalizedOutputStream(OutputStream out) {
|
||||
return out;
|
||||
}*/
|
||||
/*
|
||||
* public Process exec(String command, String[] envp) throws IOException {
|
||||
* return exec(command, envp, null); }
|
||||
*
|
||||
* public Process exec(String command, String[] envp, File dir) throws
|
||||
* IOException { if (command.length() == 0) throw new
|
||||
* IllegalArgumentException("Empty command");
|
||||
*
|
||||
* StringTokenizer st = new StringTokenizer(command); String[] cmdarray =
|
||||
* new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++)
|
||||
* cmdarray[i] = st.nextToken(); return exec(cmdarray, envp, dir); }
|
||||
*
|
||||
* public Process exec(String cmdarray[]) throws IOException { return
|
||||
* exec(cmdarray, null, null); }
|
||||
*
|
||||
* public Process exec(String[] cmdarray, String[] envp) throws IOException
|
||||
* { return exec(cmdarray, envp, null); }
|
||||
*
|
||||
* public Process exec(String[] cmdarray, String[] envp, File dir) throws
|
||||
* IOException { return new ProcessBuilder(cmdarray) .environment(envp)
|
||||
* .directory(dir) .start(); }
|
||||
*
|
||||
* public native int availableProcessors();
|
||||
*
|
||||
* public native long freeMemory();
|
||||
*
|
||||
* public native long totalMemory();
|
||||
*
|
||||
* public native long maxMemory();
|
||||
*
|
||||
* public void gc() { Runtime.getRuntime().gc(); }
|
||||
*
|
||||
* public void runFinalization() { Runtime.getRuntime().runFinalization(); }
|
||||
*
|
||||
* public native void traceInstructions(boolean on);
|
||||
*
|
||||
* public native void traceMethodCalls(boolean on);
|
||||
*
|
||||
* public void load(String filename) { load0(Reflection.getCallerClass(),
|
||||
* filename); }
|
||||
*
|
||||
* synchronized void load0(Class fromClass, String filename) {
|
||||
* SecurityManager security = System.getSecurityManager(); if (security !=
|
||||
* null) { security.checkLink(filename); } if (!(new
|
||||
* File(filename).isAbsolute())) { throw new UnsatisfiedLinkError(
|
||||
* "Expecting an absolute path of the library: " + filename); }
|
||||
* ClassLoader.loadLibrary(fromClass, filename, true); }
|
||||
*
|
||||
* public void loadLibrary(String libname) {
|
||||
* loadLibrary0(Reflection.getCallerClass(), libname); }
|
||||
*
|
||||
* synchronized void loadLibrary0(Class fromClass, String libname) {
|
||||
* SecurityManager security = System.getSecurityManager(); if (security !=
|
||||
* null) { security.checkLink(libname); } if
|
||||
* (libname.indexOf((int)File.separatorChar) != -1) { throw new
|
||||
* UnsatisfiedLinkError(
|
||||
* "Directory separator should not appear in library name: " + libname); }
|
||||
* ClassLoader.loadLibrary(fromClass, libname, false); }
|
||||
*
|
||||
* public InputStream getLocalizedInputStream(InputStream in) { return in; }
|
||||
*
|
||||
* public OutputStream getLocalizedOutputStream(OutputStream out) { return
|
||||
* out; }
|
||||
*/
|
||||
}
|
|
@ -34,7 +34,8 @@ public final class ZipUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compress the given root and all its underlying folders and files to the target file, preserving files hierarchy.
|
||||
* Compress the given root and all its underlying folders and files to the
|
||||
* target file, preserving files hierarchy.
|
||||
*
|
||||
* @param root
|
||||
* The root of the Zip archive
|
||||
|
@ -43,9 +44,11 @@ public final class ZipUtils {
|
|||
* @throws IOException
|
||||
* If an error occurs during the process
|
||||
*/
|
||||
public static void zipDirectory(final File root, final File target) throws IOException {
|
||||
public static void zipDirectory(final File root, final File target)
|
||||
throws IOException {
|
||||
if (!ZIP_FILE_FILTER.accept(target)) {
|
||||
throw new IllegalArgumentException("Target file " + target.getName() + " is not a valid Zip file name");
|
||||
throw new IllegalArgumentException("Target file "
|
||||
+ target.getName() + " is not a valid Zip file name");
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
|
@ -59,7 +62,8 @@ public final class ZipUtils {
|
|||
FileInputStream fileInputStream = null;
|
||||
|
||||
for (File file : ZipUtils.listFilesRecursive(root)) {
|
||||
ZipEntry entry = new ZipEntry(ZipUtils.stripRootInclusive(file, root).getPath());
|
||||
ZipEntry entry = new ZipEntry(ZipUtils.stripRootInclusive(file,
|
||||
root).getPath());
|
||||
zipOutputStream.putNextEntry(entry);
|
||||
try {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
|
@ -79,8 +83,9 @@ public final class ZipUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Unzip the given archive Zip file to the target location. If target location is a file, the extraction will be
|
||||
* performed in the same directory of this target file.
|
||||
* Unzip the given archive Zip file to the target location. If target
|
||||
* location is a file, the extraction will be performed in the same
|
||||
* directory of this target file.
|
||||
*
|
||||
* @param zipFile
|
||||
* The Zip archive file
|
||||
|
@ -89,11 +94,13 @@ public final class ZipUtils {
|
|||
* @throws IOException
|
||||
* If an error occurs during the process
|
||||
*/
|
||||
public static void unzip(final File zipFile, File target) throws IOException {
|
||||
public static void unzip(final File zipFile, File target)
|
||||
throws IOException {
|
||||
if (zipFile == null) {
|
||||
throw new IllegalArgumentException("Cannot unzip a null file!");
|
||||
} else if (!ZIP_FILE_FILTER.accept(zipFile)) {
|
||||
throw new IllegalArgumentException("Given archive is not a valid Zip file!");
|
||||
throw new IllegalArgumentException(
|
||||
"Given archive is not a valid Zip file!");
|
||||
}
|
||||
if (target == null) {
|
||||
throw new IllegalArgumentException("Cannot unzip to a null target!");
|
||||
|
@ -107,13 +114,16 @@ public final class ZipUtils {
|
|||
// Target is a file, will try to unzip in the same folder.
|
||||
target = target.getParentFile();
|
||||
if (target == null) {
|
||||
throw new IllegalArgumentException("Target is a file and has no parent!");
|
||||
throw new IllegalArgumentException(
|
||||
"Target is a file and has no parent!");
|
||||
}
|
||||
}
|
||||
|
||||
ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
|
||||
ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(
|
||||
zipFile));
|
||||
try {
|
||||
for (ZipEntry entry = zipInputStream.getNextEntry(); entry != null; entry = zipInputStream.getNextEntry()) {
|
||||
for (ZipEntry entry = zipInputStream.getNextEntry(); entry != null; entry = zipInputStream
|
||||
.getNextEntry()) {
|
||||
File file = new File(target, entry.getName());
|
||||
|
||||
// Create parent folders (folders are not in the Zip entries).
|
||||
|
@ -164,9 +174,11 @@ public final class ZipUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Strip the given file from any parent path, preserving the root as the absolute parent.
|
||||
* Strip the given file from any parent path, preserving the root as the
|
||||
* absolute parent.
|
||||
* <p>
|
||||
* Ex. with 'Folder' as the root: /home/johnj/Test/Folder/File.txt => /Folder/File.txt
|
||||
* Ex. with 'Folder' as the root: /home/johnj/Test/Folder/File.txt =>
|
||||
* /Folder/File.txt
|
||||
* </p>
|
||||
*
|
||||
* @param file
|
||||
|
|
|
@ -22,9 +22,9 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|||
*/
|
||||
public final class ASMUtil_OLD {
|
||||
|
||||
public static void renameFieldNode(String originalParentName, String originalFieldName,
|
||||
String originalFieldDesc, String newFieldParent, String newFieldName, String newFieldDesc)
|
||||
{
|
||||
public static void renameFieldNode(String originalParentName,
|
||||
String originalFieldName, String originalFieldDesc,
|
||||
String newFieldParent, String newFieldName, String newFieldDesc) {
|
||||
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
||||
for (Object o : c.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
|
@ -32,10 +32,9 @@ public final class ASMUtil_OLD {
|
|||
if (i instanceof FieldInsnNode) {
|
||||
FieldInsnNode field = (FieldInsnNode) i;
|
||||
|
||||
if(field.owner.equals(originalParentName) &&
|
||||
field.name.equals(originalFieldName) &&
|
||||
field.desc.equals(originalFieldDesc))
|
||||
{
|
||||
if (field.owner.equals(originalParentName)
|
||||
&& field.name.equals(originalFieldName)
|
||||
&& field.desc.equals(originalFieldDesc)) {
|
||||
if (newFieldParent != null)
|
||||
field.owner = newFieldParent;
|
||||
if (newFieldName != null)
|
||||
|
@ -49,19 +48,18 @@ public final class ASMUtil_OLD {
|
|||
}
|
||||
}
|
||||
|
||||
public static void renameMethodNode(String originalParentName, String originalMethodName,
|
||||
String originalMethodDesc, String newParent, String newName, String newDesc)
|
||||
{
|
||||
public static void renameMethodNode(String originalParentName,
|
||||
String originalMethodName, String originalMethodDesc,
|
||||
String newParent, String newName, String newDesc) {
|
||||
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
||||
for (Object o : c.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
for (AbstractInsnNode i : m.instructions.toArray()) {
|
||||
if (i instanceof MethodInsnNode) {
|
||||
MethodInsnNode mi = (MethodInsnNode) i;
|
||||
if(mi.owner.equals(originalParentName) &&
|
||||
mi.name.equals(originalMethodName) &&
|
||||
mi.desc.equals(originalMethodDesc))
|
||||
{
|
||||
if (mi.owner.equals(originalParentName)
|
||||
&& mi.name.equals(originalMethodName)
|
||||
&& mi.desc.equals(originalMethodDesc)) {
|
||||
if (newParent != null)
|
||||
mi.owner = newParent;
|
||||
if (newName != null)
|
||||
|
@ -76,14 +74,16 @@ public final class ASMUtil_OLD {
|
|||
|
||||
if (m.signature != null) {
|
||||
if (newName != null)
|
||||
m.signature = m.signature.replace(originalMethodName, newName);
|
||||
m.signature = m.signature.replace(originalMethodName,
|
||||
newName);
|
||||
if (newParent != null)
|
||||
m.signature = m.signature.replace(originalParentName, newParent);
|
||||
m.signature = m.signature.replace(originalParentName,
|
||||
newParent);
|
||||
}
|
||||
|
||||
if( m.name.equals(originalMethodName) &&
|
||||
m.desc.equals(originalMethodDesc) &&
|
||||
c.name.equals(originalParentName)) {
|
||||
if (m.name.equals(originalMethodName)
|
||||
&& m.desc.equals(originalMethodDesc)
|
||||
&& c.name.equals(originalParentName)) {
|
||||
if (newName != null)
|
||||
m.name = newName;
|
||||
if (newDesc != null)
|
||||
|
@ -94,19 +94,20 @@ public final class ASMUtil_OLD {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void renameClassNode(final String oldName, final String newName) {
|
||||
public static void renameClassNode(final String oldName,
|
||||
final String newName) {
|
||||
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
||||
for (Object oo : c.innerClasses) {
|
||||
InnerClassNode innerClassNode = (InnerClassNode) oo;
|
||||
if (innerClassNode.innerName != null &&
|
||||
innerClassNode.innerName.equals(oldName)) {
|
||||
if (innerClassNode.innerName != null
|
||||
&& innerClassNode.innerName.equals(oldName)) {
|
||||
innerClassNode.innerName = newName;
|
||||
}
|
||||
if (innerClassNode.name.equals(oldName)) {
|
||||
innerClassNode.name = newName;
|
||||
}
|
||||
if (innerClassNode.outerName != null &&
|
||||
innerClassNode.outerName.equals(oldName)) {
|
||||
if (innerClassNode.outerName != null
|
||||
&& innerClassNode.outerName.equals(oldName)) {
|
||||
innerClassNode.outerName = newName;
|
||||
}
|
||||
}
|
||||
|
@ -164,18 +165,15 @@ public final class ASMUtil_OLD {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*for(ClassNode oldClass : BytecodeViewer.getLoadedClasses()) {
|
||||
try {
|
||||
ClassReader cr = new ClassReader(oldClass.name);
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cr.accept(new ClassVisitor(0) {
|
||||
@Override
|
||||
|
||||
}, ClassReader.EXPAND_FRAMES);
|
||||
byte[] b = cw.toByteArray();
|
||||
} catch(Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* for(ClassNode oldClass : BytecodeViewer.getLoadedClasses()) { try {
|
||||
* ClassReader cr = new ClassReader(oldClass.name); ClassWriter cw = new
|
||||
* ClassWriter(0); cr.accept(new ClassVisitor(0) {
|
||||
*
|
||||
* @Override
|
||||
*
|
||||
* }, ClassReader.EXPAND_FRAMES); byte[] b = cw.toByteArray(); }
|
||||
* catch(Exception e) { new ExceptionUI(e); } }
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package the.bytecode.club.bytecodeviewer.api;
|
||||
|
||||
/**
|
||||
* Whenever a function is executed, this class will be executed with the function
|
||||
* callHook(String);
|
||||
* Whenever a function is executed, this class will be executed with the
|
||||
* function callHook(String);
|
||||
*
|
||||
* @author Konloch
|
||||
*
|
||||
|
@ -11,9 +11,11 @@ package the.bytecode.club.bytecodeviewer.api;
|
|||
public abstract class BytecodeHook {
|
||||
|
||||
/**
|
||||
* Called whenever a function is called (And EZ-Injection has been injected).
|
||||
* Called whenever a function is called (And EZ-Injection has been
|
||||
* injected).
|
||||
*
|
||||
* @param information the full name of the class, method and method description.
|
||||
* @param information
|
||||
* the full name of the class, method and method description.
|
||||
*/
|
||||
public abstract void callHook(String information);
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
import the.bytecode.club.bytecodeviewer.plugins.EZInjection;
|
||||
|
||||
/**
|
||||
* The official API for BCV, this was mainly designed for plugin authors
|
||||
* and people utilizing EZ-Injection.
|
||||
* The official API for BCV, this was mainly designed for plugin authors and
|
||||
* people utilizing EZ-Injection.
|
||||
*
|
||||
* @author Konloch
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ public class BytecodeViewer {
|
|||
|
||||
/**
|
||||
* Grab the loader instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ClassNodeLoader getClassNodeLoader() {
|
||||
|
@ -40,7 +41,9 @@ public class BytecodeViewer {
|
|||
|
||||
/**
|
||||
* Used to start a plugin from file.
|
||||
* @param plugin the file of the plugin
|
||||
*
|
||||
* @param plugin
|
||||
* the file of the plugin
|
||||
*/
|
||||
public static void startPlugin(File plugin) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.startPlugin(plugin);
|
||||
|
@ -48,7 +51,9 @@ public class BytecodeViewer {
|
|||
|
||||
/**
|
||||
* Used to load classes/jars into BCV.
|
||||
* @param files an array of the files you want loaded.
|
||||
*
|
||||
* @param files
|
||||
* an array of the files you want loaded.
|
||||
*/
|
||||
public static void openFiles(File[] files) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.openFiles(files);
|
||||
|
@ -56,23 +61,29 @@ public class BytecodeViewer {
|
|||
|
||||
/**
|
||||
* Used to load a ClassNode.
|
||||
* @param name the full name of the ClassNode
|
||||
*
|
||||
* @param name
|
||||
* the full name of the ClassNode
|
||||
* @return the ClassNode
|
||||
*/
|
||||
public static ClassNode getClassNode(String name) {
|
||||
return the.bytecode.club.bytecodeviewer.BytecodeViewer.getClassNode(name);
|
||||
return the.bytecode.club.bytecodeviewer.BytecodeViewer
|
||||
.getClassNode(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to grab the loaded ClassNodes.
|
||||
*
|
||||
* @return the loaded classes
|
||||
*/
|
||||
public static ArrayList<ClassNode> getLoadedClasses() {
|
||||
return the.bytecode.club.bytecodeviewer.BytecodeViewer.getLoadedClasses();
|
||||
return the.bytecode.club.bytecodeviewer.BytecodeViewer
|
||||
.getLoadedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to insert a Bytecode Hook using EZ-Injection.
|
||||
*
|
||||
* @param hook
|
||||
*/
|
||||
public static void insertHook(BytecodeHook hook) {
|
||||
|
@ -88,8 +99,11 @@ public class BytecodeViewer {
|
|||
}
|
||||
|
||||
/**
|
||||
* If true, it will display the busy icon, if false it will remove it if it's displayed.
|
||||
* @param busy if it should display the busy icon or not
|
||||
* If true, it will display the busy icon, if false it will remove it if
|
||||
* it's displayed.
|
||||
*
|
||||
* @param busy
|
||||
* if it should display the busy icon or not
|
||||
*/
|
||||
public static void setBusy(boolean busy) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer.setIcon(busy);
|
||||
|
@ -97,7 +111,9 @@ public class BytecodeViewer {
|
|||
|
||||
/**
|
||||
* Sends a small window popup with the defined message.
|
||||
* @param message the message you want to display
|
||||
*
|
||||
* @param message
|
||||
* the message you want to display
|
||||
*/
|
||||
public static void showMessage(String message) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.showMessage(message);
|
||||
|
|
|
@ -24,15 +24,19 @@ public final class ClassNodeLoader extends ClassLoader {
|
|||
|
||||
/**
|
||||
* Adds the provided class node to the class loader
|
||||
* @param name The class name
|
||||
* @param contents The contents of the class (or data)
|
||||
*
|
||||
* @param name
|
||||
* The class name
|
||||
* @param contents
|
||||
* The contents of the class (or data)
|
||||
*/
|
||||
public void addClass(ClassNode cn) {
|
||||
classes.put(cn.name.replace("/", "."), cn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name The name of the class
|
||||
* @param name
|
||||
* The name of the class
|
||||
* @return If this class loader contains the provided class node
|
||||
*/
|
||||
public boolean contains(String name) {
|
||||
|
@ -94,7 +98,9 @@ public final class ClassNodeLoader extends ClassLoader {
|
|||
|
||||
/**
|
||||
* Converts a class node to a class
|
||||
* @param node The node to convert
|
||||
*
|
||||
* @param node
|
||||
* The node to convert
|
||||
* @return The converted class
|
||||
*/
|
||||
public Class<?> nodeToClass(ClassNode node) {
|
||||
|
@ -107,7 +113,8 @@ public final class ClassNodeLoader extends ClassLoader {
|
|||
e.printStackTrace();
|
||||
}
|
||||
byte[] b = cw.toByteArray();
|
||||
return defineClass(node.name.replaceAll("/", "."), b, 0, b.length, getDomain());
|
||||
return defineClass(node.name.replaceAll("/", "."), b, 0, b.length,
|
||||
getDomain());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,15 +24,18 @@ import java.io.StringWriter;
|
|||
public class ExceptionUI extends JFrame {
|
||||
|
||||
/**
|
||||
* @param e The exception to be shown
|
||||
* @param e
|
||||
* The exception to be shown
|
||||
*/
|
||||
public ExceptionUI(Exception e) {
|
||||
setup(e,"@Konloch");
|
||||
setup(e, "@Konloch - konloch@gmail.com");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e The exception to be shown
|
||||
* @param author the author of the plugin throwing this exception.
|
||||
* @param e
|
||||
* The exception to be shown
|
||||
* @param author
|
||||
* the author of the plugin throwing this exception.
|
||||
*/
|
||||
public ExceptionUI(Exception e, String author) {
|
||||
setup(e, author);
|
||||
|
@ -42,13 +45,15 @@ public class ExceptionUI extends JFrame {
|
|||
|
||||
this.setIconImages(BytecodeViewer.iconList);
|
||||
setSize(new Dimension(600, 400));
|
||||
setTitle("Bytecode Viewer "+BytecodeViewer.version+" - Stack Trace - Send this to "+author);
|
||||
setTitle("Bytecode Viewer " + BytecodeViewer.version
|
||||
+ " - Stack Trace - Send this to " + author);
|
||||
getContentPane().setLayout(new CardLayout(0, 0));
|
||||
|
||||
JTextArea txtrBytecodeViewerIs = new JTextArea();
|
||||
txtrBytecodeViewerIs.setDisabledTextColor(Color.BLACK);
|
||||
txtrBytecodeViewerIs.setWrapStyleWord(true);
|
||||
getContentPane().add(new JScrollPane(txtrBytecodeViewerIs), "name_140466576080695");
|
||||
getContentPane().add(new JScrollPane(txtrBytecodeViewerIs),
|
||||
"name_140466576080695");
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -22,8 +22,10 @@ public abstract class Plugin extends Thread {
|
|||
if (!BytecodeViewer.getLoadedClasses().isEmpty())
|
||||
execute(BytecodeViewer.getLoadedClasses());
|
||||
else {
|
||||
System.out.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer.showMessage("Plugin not ran, put some classes in first.");
|
||||
System.out
|
||||
.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer
|
||||
.showMessage("Plugin not ran, put some classes in first.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
|
@ -37,6 +39,7 @@ public abstract class Plugin extends Thread {
|
|||
|
||||
/**
|
||||
* When the plugin is finally finished, this will return true
|
||||
*
|
||||
* @return true if the plugin is finished executing
|
||||
*/
|
||||
public boolean isFinished() {
|
||||
|
@ -44,9 +47,9 @@ public abstract class Plugin extends Thread {
|
|||
}
|
||||
|
||||
/**
|
||||
* If for some reason your plugin needs to keep the thread alive,
|
||||
* yet will still be considered finished (EZ-Injection), you can call this
|
||||
* function and it will set the finished boolean to true.
|
||||
* If for some reason your plugin needs to keep the thread alive, yet will
|
||||
* still be considered finished (EZ-Injection), you can call this function
|
||||
* and it will set the finished boolean to true.
|
||||
*/
|
||||
public void setFinished() {
|
||||
finished = true;
|
||||
|
@ -54,7 +57,9 @@ public abstract class Plugin extends Thread {
|
|||
|
||||
/**
|
||||
* Whenever the plugin is started, this method is called
|
||||
* @param classNodeList all of the loaded classes for easy access.
|
||||
*
|
||||
* @param classNodeList
|
||||
* all of the loaded classes for easy access.
|
||||
*/
|
||||
public abstract void execute(ArrayList<ClassNode> classNodeList);
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public class PluginConsole extends JFrame {
|
|||
JPanel panel = new JPanel(new BorderLayout());
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
public JCheckBox check = new JCheckBox("Exact");
|
||||
|
||||
public PluginConsole(String pluginName) {
|
||||
this.setIconImages(BytecodeViewer.iconList);
|
||||
setTitle("Bytecode Viewer - Plugin Console - " + pluginName);
|
||||
|
@ -48,14 +49,19 @@ public class PluginConsole extends JFrame {
|
|||
|
||||
scrollPane.setViewportView(textArea);
|
||||
|
||||
|
||||
JButton searchNext = new JButton();
|
||||
JButton searchPrev = new JButton();
|
||||
JPanel buttonPane = new JPanel(new BorderLayout());
|
||||
buttonPane.add(searchNext, BorderLayout.WEST);
|
||||
buttonPane.add(searchPrev, BorderLayout.EAST);
|
||||
searchNext.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
searchPrev.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
searchNext
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
searchPrev
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
panel.add(buttonPane, BorderLayout.WEST);
|
||||
final JTextField field = new JTextField();
|
||||
panel.add(field, BorderLayout.CENTER);
|
||||
|
@ -80,16 +86,18 @@ public class PluginConsole extends JFrame {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {}
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0) {}
|
||||
public void keyTyped(KeyEvent arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
scrollPane.setColumnHeaderView(panel);
|
||||
this.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This was really interesting to write.
|
||||
*
|
||||
|
@ -104,7 +112,8 @@ public class PluginConsole extends JFrame {
|
|||
return;
|
||||
}
|
||||
|
||||
int startLine = area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1;
|
||||
int startLine = area.getDocument().getDefaultRootElement()
|
||||
.getElementIndex(area.getCaretPosition()) + 1;
|
||||
int currentLine = 1;
|
||||
boolean canSearch = false;
|
||||
String[] test = null;
|
||||
|
@ -118,8 +127,7 @@ public class PluginConsole extends JFrame {
|
|||
|
||||
if (next) {
|
||||
for (String s : test) {
|
||||
if(!check.isSelected())
|
||||
{
|
||||
if (!check.isSelected()) {
|
||||
s = s.toLowerCase();
|
||||
search = search.toLowerCase();
|
||||
}
|
||||
|
@ -129,7 +137,8 @@ public class PluginConsole extends JFrame {
|
|||
} else if (s.contains(search)) {
|
||||
if (canSearch) {
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(currentLine-1)
|
||||
.getDefaultRootElement()
|
||||
.getElement(currentLine - 1)
|
||||
.getStartOffset());
|
||||
canSearch = false;
|
||||
found = true;
|
||||
|
@ -150,8 +159,7 @@ public class PluginConsole extends JFrame {
|
|||
} else {
|
||||
canSearch = true;
|
||||
for (String s : test) {
|
||||
if(!check.isSelected())
|
||||
{
|
||||
if (!check.isSelected()) {
|
||||
s = s.toLowerCase();
|
||||
search = search.toLowerCase();
|
||||
}
|
||||
|
@ -159,7 +167,8 @@ public class PluginConsole extends JFrame {
|
|||
if (s.contains(search)) {
|
||||
if (lastGoodLine != -1 && canSearch)
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(lastGoodLine-1)
|
||||
.getDefaultRootElement()
|
||||
.getElement(lastGoodLine - 1)
|
||||
.getStartOffset());
|
||||
|
||||
lastGoodLine = currentLine;
|
||||
|
@ -170,10 +179,12 @@ public class PluginConsole extends JFrame {
|
|||
currentLine++;
|
||||
}
|
||||
|
||||
if(lastGoodLine != -1 && area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1 == startLine) {
|
||||
if (lastGoodLine != -1
|
||||
&& area.getDocument().getDefaultRootElement()
|
||||
.getElementIndex(area.getCaretPosition()) + 1 == startLine) {
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(lastGoodLine-1)
|
||||
.getStartOffset());
|
||||
.getDefaultRootElement()
|
||||
.getElement(lastGoodLine - 1).getStartOffset());
|
||||
}
|
||||
}
|
||||
highlight(area, search);
|
||||
|
@ -182,7 +193,8 @@ public class PluginConsole extends JFrame {
|
|||
}
|
||||
}
|
||||
|
||||
private DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,62,150));
|
||||
private DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(
|
||||
new Color(255, 62, 150));
|
||||
|
||||
public void highlight(JTextComponent textComp, String pattern) {
|
||||
if (pattern.isEmpty()) {
|
||||
|
@ -204,7 +216,8 @@ public class PluginConsole extends JFrame {
|
|||
|
||||
// Search for pattern
|
||||
while ((pos = text.indexOf(pattern, pos)) >= 0) {
|
||||
// Create highlighter using private painter and apply around pattern
|
||||
// Create highlighter using private painter and apply around
|
||||
// pattern
|
||||
hilite.addHighlight(pos, pos + pattern.length(), painter);
|
||||
pos += pattern.length();
|
||||
}
|
||||
|
@ -215,16 +228,22 @@ public class PluginConsole extends JFrame {
|
|||
|
||||
/**
|
||||
* Appends \r\n to the end of your string, then it puts it on the top.
|
||||
* @param t the string you want to append
|
||||
*
|
||||
* @param t
|
||||
* the string you want to append
|
||||
*/
|
||||
public void appendText(String t) {
|
||||
textArea.setText((textArea.getText().isEmpty() ? "" : textArea.getText()+"\r\n")+t);
|
||||
textArea.setText((textArea.getText().isEmpty() ? "" : textArea
|
||||
.getText() + "\r\n")
|
||||
+ t);
|
||||
textArea.setCaretPosition(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text
|
||||
* @param t the text you want set
|
||||
*
|
||||
* @param t
|
||||
* the text you want set
|
||||
*/
|
||||
public void setText(String t) {
|
||||
textArea.setText(t);
|
||||
|
|
|
@ -21,11 +21,14 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|||
public class ClassNodeDecompiler {
|
||||
|
||||
public static String decompile(ClassNode cn) {
|
||||
return decompileClassNode(new PrefixedStringBuilder(), new ArrayList<String>(), cn).toString();
|
||||
return decompileClassNode(new PrefixedStringBuilder(),
|
||||
new ArrayList<String>(), cn).toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static PrefixedStringBuilder decompileClassNode(PrefixedStringBuilder sb, ArrayList<String> decompiledClasses, ClassNode cn) {
|
||||
protected static PrefixedStringBuilder decompileClassNode(
|
||||
PrefixedStringBuilder sb, ArrayList<String> decompiledClasses,
|
||||
ClassNode cn) {
|
||||
ArrayList<String> unableToDecompile = new ArrayList<String>();
|
||||
decompiledClasses.add(cn.name);
|
||||
sb.append(getAccessString(cn.access));
|
||||
|
@ -66,7 +69,8 @@ public class ClassNodeDecompiler {
|
|||
for (Object o : cn.innerClasses) {
|
||||
InnerClassNode innerClassNode = (InnerClassNode) o;
|
||||
String innerClassName = innerClassNode.name;
|
||||
if ((innerClassName != null) && !decompiledClasses.contains(innerClassName)) {
|
||||
if ((innerClassName != null)
|
||||
&& !decompiledClasses.contains(innerClassName)) {
|
||||
decompiledClasses.add(innerClassName);
|
||||
ClassNode cn1 = BytecodeViewer.getClassNode(innerClassName);
|
||||
if (cn1 != null) {
|
||||
|
@ -91,7 +95,8 @@ public class ClassNodeDecompiler {
|
|||
}
|
||||
|
||||
sb.append("}");
|
||||
// System.out.println("Wrote end for " + cn.name + " with prefix length: " + sb.prefix.length());
|
||||
// System.out.println("Wrote end for " + cn.name +
|
||||
// " with prefix length: " + sb.prefix.length());
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,8 @@ public class ClassNodeDecompiler {
|
|||
tokens.add("enum");
|
||||
if ((access & Opcodes.ACC_ANNOTATION) != 0)
|
||||
tokens.add("annotation");
|
||||
if (!tokens.contains("interface") && !tokens.contains("enum") && !tokens.contains("annotation"))
|
||||
if (!tokens.contains("interface") && !tokens.contains("enum")
|
||||
&& !tokens.contains("annotation"))
|
||||
tokens.add("class");
|
||||
if (tokens.size() == 0)
|
||||
return "[Error parsing]";
|
||||
|
|
|
@ -16,7 +16,8 @@ import org.objectweb.asm.tree.FieldNode;
|
|||
|
||||
public class FieldNodeDecompiler {
|
||||
|
||||
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, FieldNode f) {
|
||||
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb,
|
||||
FieldNode f) {
|
||||
String s = getAccessString(f.access);
|
||||
sb.append(s);
|
||||
if (s.length() > 0)
|
||||
|
|
|
@ -29,6 +29,7 @@ import eu.bibl.banalysis.filter.insn.VarInstructionFilter;
|
|||
|
||||
/**
|
||||
* Pattern filter holder and stepper.
|
||||
*
|
||||
* @author Bibl
|
||||
*
|
||||
*/
|
||||
|
@ -43,7 +44,9 @@ public class InstructionPattern implements Opcodes {
|
|||
|
||||
/**
|
||||
* Construct a new pattern from the specified instructions.
|
||||
* @param insns {@link AbstractInsnNode} pattern array.
|
||||
*
|
||||
* @param insns
|
||||
* {@link AbstractInsnNode} pattern array.
|
||||
*/
|
||||
public InstructionPattern(AbstractInsnNode[] insns) {
|
||||
filters = translate(insns);
|
||||
|
@ -52,7 +55,9 @@ public class InstructionPattern implements Opcodes {
|
|||
|
||||
/**
|
||||
* Construct a new pattern from the specified opcode.
|
||||
* @param opcodes Opcodes to convert to {@link OpcodeFilter}s.
|
||||
*
|
||||
* @param opcodes
|
||||
* Opcodes to convert to {@link OpcodeFilter}s.
|
||||
*/
|
||||
public InstructionPattern(int[] opcodes) {
|
||||
filters = new InstructionFilter[opcodes.length];
|
||||
|
@ -64,7 +69,9 @@ public class InstructionPattern implements Opcodes {
|
|||
|
||||
/**
|
||||
* Construct an absolute pattern from user-defined filters.
|
||||
* @param filters User-defined {@link InstructionFilter}s.
|
||||
*
|
||||
* @param filters
|
||||
* User-defined {@link InstructionFilter}s.
|
||||
*/
|
||||
public InstructionPattern(InstructionFilter[] filters) {
|
||||
this.filters = filters;
|
||||
|
@ -72,8 +79,11 @@ public class InstructionPattern implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Steps through the instruction list checking if the current instruction ended a successful pattern-match sequence.
|
||||
* @param ain {@link AbstractInsnNode} to check.
|
||||
* Steps through the instruction list checking if the current instruction
|
||||
* ended a successful pattern-match sequence.
|
||||
*
|
||||
* @param ain
|
||||
* {@link AbstractInsnNode} to check.
|
||||
* @return True if this instruction successfully completed the pattern.
|
||||
*/
|
||||
public boolean accept(AbstractInsnNode ain) {
|
||||
|
@ -94,7 +104,8 @@ public class InstructionPattern implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Last pattern sequence match equivilent from the inputted {@link AbstractInsnNode}s.
|
||||
* @return Last pattern sequence match equivilent from the inputted
|
||||
* {@link AbstractInsnNode}s.
|
||||
*/
|
||||
public AbstractInsnNode[] getLastMatch() {
|
||||
return lastMatch;
|
||||
|
@ -117,8 +128,11 @@ public class InstructionPattern implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts an array of {@link AbstractInsnNode}s to their {@link InstructionFilter} counterparts.
|
||||
* @param ains {@link AbstractInsnNode}s to convert.
|
||||
* Converts an array of {@link AbstractInsnNode}s to their
|
||||
* {@link InstructionFilter} counterparts.
|
||||
*
|
||||
* @param ains
|
||||
* {@link AbstractInsnNode}s to convert.
|
||||
* @return Array of {@link InstructionFilter}s.
|
||||
*/
|
||||
public static InstructionFilter[] translate(AbstractInsnNode[] ains) {
|
||||
|
@ -130,31 +144,45 @@ public class InstructionPattern implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Translate a single {@link AbstractInsnNode} to an {@link InstructionFilter}.
|
||||
* @param ain Instruction to convert.
|
||||
* Translate a single {@link AbstractInsnNode} to an
|
||||
* {@link InstructionFilter}.
|
||||
*
|
||||
* @param ain
|
||||
* Instruction to convert.
|
||||
* @return A filter an an equivilent to the inputted instruction.
|
||||
*/
|
||||
public static InstructionFilter translate(AbstractInsnNode ain) {
|
||||
if (ain instanceof LdcInsnNode) {
|
||||
return new LdcInstructionFilter(((LdcInsnNode) ain).cst);
|
||||
} else if (ain instanceof TypeInsnNode) {
|
||||
return new TypeInstructionFilter(ain.getOpcode(), ((TypeInsnNode) ain).desc);
|
||||
return new TypeInstructionFilter(ain.getOpcode(),
|
||||
((TypeInsnNode) ain).desc);
|
||||
} else if (ain instanceof FieldInsnNode) {
|
||||
return new FieldInstructionFilter(ain.getOpcode(), ((FieldInsnNode) ain).owner, ((FieldInsnNode) ain).name, ((FieldInsnNode) ain).desc);
|
||||
return new FieldInstructionFilter(ain.getOpcode(),
|
||||
((FieldInsnNode) ain).owner, ((FieldInsnNode) ain).name,
|
||||
((FieldInsnNode) ain).desc);
|
||||
} else if (ain instanceof MethodInsnNode) {
|
||||
return new MethodInstructionFilter(ain.getOpcode(), ((MethodInsnNode) ain).owner, ((MethodInsnNode) ain).name, ((MethodInsnNode) ain).desc);
|
||||
return new MethodInstructionFilter(ain.getOpcode(),
|
||||
((MethodInsnNode) ain).owner, ((MethodInsnNode) ain).name,
|
||||
((MethodInsnNode) ain).desc);
|
||||
} else if (ain instanceof VarInsnNode) {
|
||||
return new VarInstructionFilter(ain.getOpcode(), ((VarInsnNode) ain).var);
|
||||
return new VarInstructionFilter(ain.getOpcode(),
|
||||
((VarInsnNode) ain).var);
|
||||
} else if (ain instanceof InsnNode) {
|
||||
return new InsnInstructionFilter(ain.getOpcode());
|
||||
} else if (ain instanceof IincInsnNode) {
|
||||
return new IincInstructionFilter(((IincInsnNode) ain).incr, ((IincInsnNode) ain).var);
|
||||
return new IincInstructionFilter(((IincInsnNode) ain).incr,
|
||||
((IincInsnNode) ain).var);
|
||||
} else if (ain instanceof JumpInsnNode) {
|
||||
return new JumpInstructionFilter(ain.getOpcode());
|
||||
} else if (ain instanceof LabelNode) {
|
||||
return InstructionFilter.ACCEPT_ALL; // TODO: Cache labels and check. // TODO: That's a fucking stupid idea.
|
||||
return InstructionFilter.ACCEPT_ALL; // TODO: Cache labels and
|
||||
// check. // TODO: That's a
|
||||
// fucking stupid idea.
|
||||
} else if (ain instanceof MultiANewArrayInsnNode) {
|
||||
return new MultiANewArrayInstructionFilter(((MultiANewArrayInsnNode) ain).desc, ((MultiANewArrayInsnNode) ain).dims);
|
||||
return new MultiANewArrayInstructionFilter(
|
||||
((MultiANewArrayInsnNode) ain).desc,
|
||||
((MultiANewArrayInsnNode) ain).dims);
|
||||
} else {
|
||||
return InstructionFilter.ACCEPT_ALL;
|
||||
}
|
||||
|
@ -162,11 +190,10 @@ public class InstructionPattern implements Opcodes {
|
|||
|
||||
public static void main(String[] args) {
|
||||
AbstractInsnNode[] ains = new AbstractInsnNode[] {
|
||||
new LdcInsnNode("ldc"),
|
||||
new VarInsnNode(ASTORE, 0),
|
||||
new LdcInsnNode("ldc"), new VarInsnNode(ASTORE, 0),
|
||||
new LdcInsnNode("ldc") };
|
||||
InstructionPattern pattern = new InstructionPattern(new AbstractInsnNode[] {
|
||||
new LdcInsnNode("ldc"),
|
||||
InstructionPattern pattern = new InstructionPattern(
|
||||
new AbstractInsnNode[] { new LdcInsnNode("ldc"),
|
||||
new VarInsnNode(-1, -1) });
|
||||
for (AbstractInsnNode ain : ains) {
|
||||
if (pattern.accept(ain)) {
|
||||
|
|
|
@ -57,11 +57,13 @@ public class InstructionPrinter {
|
|||
this.args = args;
|
||||
mNode = m;
|
||||
labels = new HashMap<LabelNode, Integer>();
|
||||
// matchedInsns = new ArrayList<AbstractInsnNode>(); // ingnored because match = false
|
||||
// matchedInsns = new ArrayList<AbstractInsnNode>(); // ingnored because
|
||||
// match = false
|
||||
match = false;
|
||||
}
|
||||
|
||||
public InstructionPrinter(MethodNode m, InstructionPattern pattern, TypeAndName[] args) {
|
||||
public InstructionPrinter(MethodNode m, InstructionPattern pattern,
|
||||
TypeAndName[] args) {
|
||||
this.args = args;
|
||||
mNode = m;
|
||||
labels = new HashMap<LabelNode, Integer>();
|
||||
|
@ -78,6 +80,7 @@ public class InstructionPrinter {
|
|||
|
||||
/**
|
||||
* Creates the print
|
||||
*
|
||||
* @return The print as an ArrayList
|
||||
*/
|
||||
public ArrayList<String> createPrint() {
|
||||
|
@ -104,7 +107,9 @@ public class InstructionPrinter {
|
|||
} else if (ain instanceof LineNumberNode) {
|
||||
line = printLineNumberNode((LineNumberNode) ain, it);
|
||||
} else if (ain instanceof LabelNode) {
|
||||
if(firstLabel && BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected())
|
||||
if (firstLabel
|
||||
&& BytecodeViewer.viewer.chckbxmntmAppendBrackets
|
||||
.isSelected())
|
||||
info.add("}");
|
||||
|
||||
line = printLabelnode((LabelNode) ain);
|
||||
|
@ -125,7 +130,8 @@ public class InstructionPrinter {
|
|||
} else if (ain instanceof LookupSwitchInsnNode) {
|
||||
line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain);
|
||||
} else {
|
||||
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " " + ain.toString();
|
||||
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
|
||||
+ ain.toString();
|
||||
}
|
||||
if (!line.equals("")) {
|
||||
if (match)
|
||||
|
@ -135,7 +141,8 @@ public class InstructionPrinter {
|
|||
info.add(line);
|
||||
}
|
||||
}
|
||||
if(firstLabel && BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected())
|
||||
if (firstLabel
|
||||
&& BytecodeViewer.viewer.chckbxmntmAppendBrackets.isSelected())
|
||||
info.add("}");
|
||||
return info;
|
||||
}
|
||||
|
@ -148,7 +155,8 @@ public class InstructionPrinter {
|
|||
if (vin.var == 0 && !Modifier.isStatic(mNode.access)) {
|
||||
sb.append(" // reference to self");
|
||||
} else {
|
||||
final int refIndex = vin.var - (Modifier.isStatic(mNode.access) ? 0 : 1);
|
||||
final int refIndex = vin.var
|
||||
- (Modifier.isStatic(mNode.access) ? 0 : 1);
|
||||
if (refIndex >= 0 && refIndex < args.length - 1) {
|
||||
sb.append(" // reference to " + args[refIndex].name);
|
||||
}
|
||||
|
@ -166,12 +174,14 @@ public class InstructionPrinter {
|
|||
String desc = Type.getType(fin.desc).getClassName();
|
||||
if (desc == null || desc.equals("null"))
|
||||
desc = fin.desc;
|
||||
return nameOpcode(fin.getOpcode()) + " " + fin.owner + "." + fin.name + ":" + desc;
|
||||
return nameOpcode(fin.getOpcode()) + " " + fin.owner + "." + fin.name
|
||||
+ ":" + desc;
|
||||
}
|
||||
|
||||
protected String printMethodInsnNode(MethodInsnNode min, ListIterator<?> it) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(nameOpcode(min.getOpcode()) + " " + min.owner + " " + min.name + "(");
|
||||
sb.append(nameOpcode(min.getOpcode()) + " " + min.owner + " "
|
||||
+ min.name + "(");
|
||||
|
||||
String desc = Type.getType(min.desc).getClassName();
|
||||
if (desc == null || desc.equals("null"))
|
||||
|
@ -184,18 +194,14 @@ public class InstructionPrinter {
|
|||
}
|
||||
|
||||
protected String printLdcInsnNode(LdcInsnNode ldc, ListIterator<?> it) {
|
||||
if(BytecodeViewer.viewer.chckbxmntmNewCheckItem.isSelected()) { //ascii only
|
||||
if (ldc.cst instanceof String)
|
||||
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||
return nameOpcode(ldc.getOpcode()) + " \""
|
||||
+ StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" ("
|
||||
+ ldc.cst.getClass().getCanonicalName() + ")";
|
||||
|
||||
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString()) + " (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||
|
||||
} else {
|
||||
if (ldc.cst instanceof String)
|
||||
return nameOpcode(ldc.getOpcode()) + " \"" + ((String)ldc.cst).replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r").replaceAll("\\\"", "\\\\\"") + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||
|
||||
return nameOpcode(ldc.getOpcode()) + " " + ldc.cst + " (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||
}
|
||||
return nameOpcode(ldc.getOpcode()) + " "
|
||||
+ StringEscapeUtils.escapeJava(ldc.cst.toString()) + " ("
|
||||
+ ldc.cst.getClass().getCanonicalName() + ")";
|
||||
}
|
||||
|
||||
protected String printInsnNode(InsnNode in, ListIterator<?> it) {
|
||||
|
@ -203,7 +209,8 @@ public class InstructionPrinter {
|
|||
}
|
||||
|
||||
protected String printJumpInsnNode(JumpInsnNode jin, ListIterator<?> it) {
|
||||
String line = nameOpcode(jin.getOpcode()) + " L" + resolveLabel(jin.label);
|
||||
String line = nameOpcode(jin.getOpcode()) + " L"
|
||||
+ resolveLabel(jin.label);
|
||||
return line;
|
||||
}
|
||||
|
||||
|
@ -236,9 +243,11 @@ public class InstructionPrinter {
|
|||
List<?> labels = tin.labels;
|
||||
int count = 0;
|
||||
for (int i = tin.min; i < tin.max; i++) {
|
||||
line += " val: " + i + " -> " + "L" + resolveLabel((LabelNode) labels.get(count++)) + "\n";
|
||||
line += " val: " + i + " -> " + "L"
|
||||
+ resolveLabel((LabelNode) labels.get(count++)) + "\n";
|
||||
}
|
||||
line += " default" + " -> L" + resolveLabel(tin.dflt) + "";
|
||||
line += " default" + " -> L" + resolveLabel(tin.dflt)
|
||||
+ "";
|
||||
return line;
|
||||
}
|
||||
|
||||
|
@ -250,13 +259,14 @@ public class InstructionPrinter {
|
|||
for (int i = 0; i < keys.size(); i++) {
|
||||
int key = (Integer) keys.get(i);
|
||||
LabelNode label = (LabelNode) labels.get(i);
|
||||
line += " val: " + key + " -> " + "L" + resolveLabel(label) + "\n";
|
||||
line += " val: " + key + " -> " + "L"
|
||||
+ resolveLabel(label) + "\n";
|
||||
}
|
||||
line += " default" + " -> L" + resolveLabel(lin.dflt) + "";
|
||||
line += " default" + " -> L" + resolveLabel(lin.dflt)
|
||||
+ "";
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
protected String nameOpcode(int opcode) {
|
||||
return " " + OpcodeInfo.OPCODES.get(opcode).toLowerCase();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ import the.bytecode.club.bytecodeviewer.decompilers.bytecode.TypeAndName;
|
|||
public class MethodNodeDecompiler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, MethodNode m, ClassNode cn) {
|
||||
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb,
|
||||
MethodNode m, ClassNode cn) {
|
||||
String package_ = null;
|
||||
String class_ = null;
|
||||
if (cn.name.contains("/")) {
|
||||
|
@ -68,7 +69,8 @@ public class MethodNodeDecompiler {
|
|||
|
||||
args[i] = tan;
|
||||
|
||||
sb.append(type.getClassName() + " " + argName + (i < argTypes.length-1 ? ", " : ""));
|
||||
sb.append(type.getClassName() + " " + argName
|
||||
+ (i < argTypes.length - 1 ? ", " : ""));
|
||||
}
|
||||
|
||||
sb.append(")");
|
||||
|
@ -113,12 +115,16 @@ public class MethodNodeDecompiler {
|
|||
|
||||
addAttrList(m.attrs, "attr", sb, insnPrinter);
|
||||
addAttrList(m.invisibleAnnotations, "invisAnno", sb, insnPrinter);
|
||||
addAttrList(m.invisibleAnnotations, "invisLocalVarAnno", sb, insnPrinter);
|
||||
addAttrList(m.invisibleTypeAnnotations, "invisTypeAnno", sb, insnPrinter);
|
||||
addAttrList(m.invisibleAnnotations, "invisLocalVarAnno", sb,
|
||||
insnPrinter);
|
||||
addAttrList(m.invisibleTypeAnnotations, "invisTypeAnno", sb,
|
||||
insnPrinter);
|
||||
addAttrList(m.localVariables, "localVar", sb, insnPrinter);
|
||||
addAttrList(m.visibleAnnotations, "visAnno", sb, insnPrinter);
|
||||
addAttrList(m.visibleLocalVariableAnnotations, "visLocalVarAnno", sb, insnPrinter);
|
||||
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb, insnPrinter);
|
||||
addAttrList(m.visibleLocalVariableAnnotations, "visLocalVarAnno",
|
||||
sb, insnPrinter);
|
||||
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb,
|
||||
insnPrinter);
|
||||
|
||||
for (Object o : m.tryCatchBlocks) {
|
||||
TryCatchBlockNode tcbn = (TryCatchBlockNode) o;
|
||||
|
@ -146,7 +152,8 @@ public class MethodNodeDecompiler {
|
|||
return sb;
|
||||
}
|
||||
|
||||
private static void addAttrList(List<?> list, String name, PrefixedStringBuilder sb, InstructionPrinter insnPrinter) {
|
||||
private static void addAttrList(List<?> list, String name,
|
||||
PrefixedStringBuilder sb, InstructionPrinter insnPrinter) {
|
||||
if (list == null)
|
||||
return;
|
||||
if (list.size() > 0) {
|
||||
|
@ -165,7 +172,10 @@ public class MethodNodeDecompiler {
|
|||
private static String printAttr(Object o, InstructionPrinter insnPrinter) {
|
||||
if (o instanceof LocalVariableNode) {
|
||||
LocalVariableNode lvn = (LocalVariableNode) o;
|
||||
return "index=" + lvn.index + " , name=" + lvn.name + " , desc=" + lvn.desc + ", sig=" + lvn.signature + ", start=L" + insnPrinter.resolveLabel(lvn.start) + ", end=L" + insnPrinter.resolveLabel(lvn.end);
|
||||
return "index=" + lvn.index + " , name=" + lvn.name + " , desc="
|
||||
+ lvn.desc + ", sig=" + lvn.signature + ", start=L"
|
||||
+ insnPrinter.resolveLabel(lvn.start) + ", end=L"
|
||||
+ insnPrinter.resolveLabel(lvn.end);
|
||||
} else if (o instanceof AnnotationNode) {
|
||||
AnnotationNode an = (AnnotationNode) o;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -17,7 +17,14 @@ public class PrefixedStringBuilder {
|
|||
|
||||
public PrefixedStringBuilder append(String s) {
|
||||
sb.append(s);
|
||||
if (s.contains("\n") && (prefix != null) && (prefix.length() > 0))// insert the prefix at every new line, overridable
|
||||
if (s.contains("\n") && (prefix != null) && (prefix.length() > 0))// insert
|
||||
// the
|
||||
// prefix
|
||||
// at
|
||||
// every
|
||||
// new
|
||||
// line,
|
||||
// overridable
|
||||
sb.append(prefix);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ package the.bytecode.club.bytecodeviewer.decompilers.bytecode;
|
|||
import org.objectweb.asm.Type;
|
||||
|
||||
/**
|
||||
* Container class for type and name. Used to pass arguments and local variables around
|
||||
* Container class for type and name. Used to pass arguments and local variables
|
||||
* around
|
||||
*
|
||||
* @author Waterwolf
|
||||
*
|
||||
|
|
|
@ -34,7 +34,8 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||
+ "temp";
|
||||
int fileNumber = getClassNumber(fileStart, ".class");
|
||||
|
||||
final File tempClass = new File(fileStart + fileNumber + ".class");
|
||||
|
@ -50,17 +51,18 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
}
|
||||
|
||||
String fuckery = fuckery(fileStart);
|
||||
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery));
|
||||
org.benf.cfr.reader.Main.main(generateMainMethod(
|
||||
tempClass.getAbsolutePath(), fuckery));
|
||||
|
||||
tempClass.delete();
|
||||
|
||||
|
||||
return findFile(new File(fuckery).listFiles());
|
||||
|
||||
}
|
||||
|
||||
Random r = new Random();
|
||||
File f;
|
||||
|
||||
public String fuckery(String start) {
|
||||
boolean b = false;
|
||||
while (!b) {
|
||||
|
@ -96,31 +98,40 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
"--outputdir",
|
||||
outputPath,
|
||||
"--decodeenumswitch",
|
||||
String.valueOf(BytecodeViewer.viewer.decodeenumswitch.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.decodeenumswitch
|
||||
.isSelected()),
|
||||
"--sugarenums",
|
||||
String.valueOf(BytecodeViewer.viewer.sugarenums.isSelected()),
|
||||
"--decodestringswitch",
|
||||
String.valueOf(BytecodeViewer.viewer.decodestringswitch.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.decodestringswitch
|
||||
.isSelected()),
|
||||
"--arrayiter",
|
||||
String.valueOf(BytecodeViewer.viewer.arrayiter.isSelected()),
|
||||
"--collectioniter",
|
||||
String.valueOf(BytecodeViewer.viewer.collectioniter.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.collectioniter
|
||||
.isSelected()),
|
||||
"--innerclasses",
|
||||
String.valueOf(BytecodeViewer.viewer.innerclasses.isSelected()),
|
||||
"--removeboilerplate",
|
||||
String.valueOf(BytecodeViewer.viewer.removeboilerplate.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.removeboilerplate
|
||||
.isSelected()),
|
||||
"--removeinnerclasssynthetics",
|
||||
String.valueOf(BytecodeViewer.viewer.removeinnerclasssynthetics.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.removeinnerclasssynthetics
|
||||
.isSelected()),
|
||||
"--decodelambdas",
|
||||
String.valueOf(BytecodeViewer.viewer.decodelambdas.isSelected()),
|
||||
"--hidebridgemethods",
|
||||
String.valueOf(BytecodeViewer.viewer.hidebridgemethods.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.hidebridgemethods
|
||||
.isSelected()),
|
||||
"--liftconstructorinit",
|
||||
String.valueOf(BytecodeViewer.viewer.liftconstructorinit.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.liftconstructorinit
|
||||
.isSelected()),
|
||||
"--removedeadmethods",
|
||||
String.valueOf(BytecodeViewer.viewer.removedeadmethods.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.removedeadmethods
|
||||
.isSelected()),
|
||||
"--removebadgenerics",
|
||||
String.valueOf(BytecodeViewer.viewer.removebadgenerics.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.removebadgenerics
|
||||
.isSelected()),
|
||||
"--sugarasserts",
|
||||
String.valueOf(BytecodeViewer.viewer.sugarasserts.isSelected()),
|
||||
"--sugarboxing",
|
||||
|
@ -140,7 +151,8 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
"--forcetopsort",
|
||||
String.valueOf(BytecodeViewer.viewer.forcetopsort.isSelected()),
|
||||
"--forcetopsortaggress",
|
||||
String.valueOf(BytecodeViewer.viewer.forcetopsortaggress.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.forcetopsortaggress
|
||||
.isSelected()),
|
||||
"--stringbuffer",
|
||||
String.valueOf(BytecodeViewer.viewer.stringbuffer.isSelected()),
|
||||
"--stringbuilder",
|
||||
|
@ -154,50 +166,65 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
"--override",
|
||||
String.valueOf(BytecodeViewer.viewer.override.isSelected()),
|
||||
"--showinferrable",
|
||||
String.valueOf(BytecodeViewer.viewer.showinferrable.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.showinferrable
|
||||
.isSelected()),
|
||||
"--aexagg",
|
||||
String.valueOf(BytecodeViewer.viewer.aexagg.isSelected()),
|
||||
"--forcecondpropagate",
|
||||
String.valueOf(BytecodeViewer.viewer.forcecondpropagate.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.forcecondpropagate
|
||||
.isSelected()),
|
||||
"--hideutf",
|
||||
String.valueOf(BytecodeViewer.viewer.hideutf.isSelected()),
|
||||
"--hidelongstrings",
|
||||
String.valueOf(BytecodeViewer.viewer.hidelongstrings.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.hidelongstrings
|
||||
.isSelected()),
|
||||
"--commentmonitors",
|
||||
String.valueOf(BytecodeViewer.viewer.commentmonitor.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.commentmonitor
|
||||
.isSelected()),
|
||||
"--allowcorrecting",
|
||||
String.valueOf(BytecodeViewer.viewer.allowcorrecting.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.allowcorrecting
|
||||
.isSelected()),
|
||||
"--labelledblocks",
|
||||
String.valueOf(BytecodeViewer.viewer.labelledblocks.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.labelledblocks
|
||||
.isSelected()),
|
||||
"--j14classobj",
|
||||
String.valueOf(BytecodeViewer.viewer.j14classobj.isSelected()),
|
||||
"--hidelangimports",
|
||||
String.valueOf(BytecodeViewer.viewer.hidelangimports.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.hidelangimports
|
||||
.isSelected()),
|
||||
"--recovertypeclash",
|
||||
String.valueOf(BytecodeViewer.viewer.recoverytypeclash.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.recoverytypeclash
|
||||
.isSelected()),
|
||||
"--recovertypehints",
|
||||
String.valueOf(BytecodeViewer.viewer.recoverytypehints.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.recoverytypehints
|
||||
.isSelected()),
|
||||
"--forcereturningifs",
|
||||
String.valueOf(BytecodeViewer.viewer.forceturningifs.isSelected()),
|
||||
String.valueOf(BytecodeViewer.viewer.forceturningifs
|
||||
.isSelected()),
|
||||
"--forloopaggcapture",
|
||||
String.valueOf(BytecodeViewer.viewer.forloopaggcapture.isSelected()),
|
||||
};
|
||||
String.valueOf(BytecodeViewer.viewer.forloopaggcapture
|
||||
.isSelected()), };
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
@Override
|
||||
public void decompileToZip(String zipName) {
|
||||
File tempZip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
|
||||
File tempZip = new File(BytecodeViewer.tempDirectory
|
||||
+ BytecodeViewer.fs + "temp.jar");
|
||||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
tempZip.getAbsolutePath());
|
||||
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||
+ "temp";
|
||||
|
||||
String fuckery = fuckery(fileStart);
|
||||
|
||||
org.benf.cfr.reader.Main.main(generateMainMethod(tempZip.getAbsolutePath(), fuckery));
|
||||
org.benf.cfr.reader.Main.main(generateMainMethod(
|
||||
tempZip.getAbsolutePath(), fuckery));
|
||||
|
||||
tempZip.delete();
|
||||
File fuck = new File(fuckery);
|
||||
|
@ -242,7 +269,8 @@ public class CFRDecompiler extends JavaDecompiler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream in, OutputStream out) throws IOException {
|
||||
private static void copy(InputStream in, OutputStream out)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
while (true) {
|
||||
int readCount = in.read(buffer);
|
||||
|
|
|
@ -28,18 +28,25 @@ public class FernFlowerDecompiler extends JavaDecompiler {
|
|||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs +"temp" + BytecodeViewer.fs);
|
||||
File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||
+ "temp" + BytecodeViewer.fs);
|
||||
f.mkdir();
|
||||
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
tempZip.getAbsolutePath());
|
||||
|
||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/"));
|
||||
File tempZip2 = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs +tempZip.getName());
|
||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler
|
||||
.main(generateMainMethod(tempZip.getAbsolutePath(),
|
||||
BytecodeViewer.tempDirectory + "./temp/"));
|
||||
File tempZip2 = new File(BytecodeViewer.tempDirectory
|
||||
+ BytecodeViewer.fs + "temp" + BytecodeViewer.fs
|
||||
+ tempZip.getName());
|
||||
if (tempZip2.exists())
|
||||
tempZip2.renameTo(new File(zipName));
|
||||
|
||||
tempZip.delete();
|
||||
new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp").delete();
|
||||
new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp")
|
||||
.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +54,8 @@ public class FernFlowerDecompiler extends JavaDecompiler {
|
|||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||
+ "temp";
|
||||
int fileNumber = getClassNumber(fileStart, ".class");
|
||||
|
||||
final File tempClass = new File(fileStart + fileNumber + ".class");
|
||||
|
@ -62,7 +70,8 @@ public class FernFlowerDecompiler extends JavaDecompiler {
|
|||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), "."));
|
||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler
|
||||
.main(generateMainMethod(tempClass.getAbsolutePath(), "."));
|
||||
|
||||
tempClass.delete();
|
||||
|
||||
|
@ -101,8 +110,7 @@ public class FernFlowerDecompiler extends JavaDecompiler {
|
|||
"-udv=" + r(BytecodeViewer.viewer.udv.isSelected()),
|
||||
"-rer=" + r(BytecodeViewer.viewer.rer.isSelected()),
|
||||
"-fdi=" + r(BytecodeViewer.viewer.fdi.isSelected()),
|
||||
"-asc="+r(BytecodeViewer.viewer.asc.isSelected()),
|
||||
className,
|
||||
"-asc=" + r(BytecodeViewer.viewer.asc.isSelected()), className,
|
||||
folder };
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,11 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
public abstract class JavaDecompiler {
|
||||
|
||||
public abstract String decompileClassNode(ClassNode cn);
|
||||
|
||||
public abstract void decompileToZip(String zipName);
|
||||
|
||||
File tempF = null;
|
||||
|
||||
public int getClassNumber(String start, String ext) {
|
||||
boolean b = true;
|
||||
int i = 0;
|
||||
|
|
|
@ -48,20 +48,34 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
|
||||
public DecompilerSettings getDecompilerSettings() {
|
||||
DecompilerSettings settings = new DecompilerSettings();
|
||||
settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6.isSelected());
|
||||
settings.setExcludeNestedTypes(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11.isSelected());
|
||||
settings.setShowDebugLineNumbers(BytecodeViewer.viewer.chckbxmntmShowDebugLine.isSelected());
|
||||
settings.setIncludeLineNumbersInBytecode(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3.isSelected());
|
||||
settings.setIncludeErrorDiagnostics(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4.isSelected());
|
||||
settings.setShowSyntheticMembers(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7.isSelected());
|
||||
settings.setSimplifyMemberReferences(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences.isSelected());
|
||||
settings.setMergeVariables(BytecodeViewer.viewer.mnMergeVariables.isSelected());
|
||||
settings.setForceExplicitTypeArguments(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8.isSelected());
|
||||
settings.setForceExplicitImports(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9.isSelected());
|
||||
settings.setFlattenSwitchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10.isSelected());
|
||||
settings.setRetainPointlessSwitches(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2.isSelected());
|
||||
settings.setRetainRedundantCasts(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5.isSelected());
|
||||
settings.setUnicodeOutputEnabled(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1.isSelected());
|
||||
settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6
|
||||
.isSelected());
|
||||
settings.setExcludeNestedTypes(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11
|
||||
.isSelected());
|
||||
settings.setShowDebugLineNumbers(BytecodeViewer.viewer.chckbxmntmShowDebugLine
|
||||
.isSelected());
|
||||
settings.setIncludeLineNumbersInBytecode(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3
|
||||
.isSelected());
|
||||
settings.setIncludeErrorDiagnostics(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4
|
||||
.isSelected());
|
||||
settings.setShowSyntheticMembers(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7
|
||||
.isSelected());
|
||||
settings.setSimplifyMemberReferences(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences
|
||||
.isSelected());
|
||||
settings.setMergeVariables(BytecodeViewer.viewer.mnMergeVariables
|
||||
.isSelected());
|
||||
settings.setForceExplicitTypeArguments(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8
|
||||
.isSelected());
|
||||
settings.setForceExplicitImports(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9
|
||||
.isSelected());
|
||||
settings.setFlattenSwitchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10
|
||||
.isSelected());
|
||||
settings.setRetainPointlessSwitches(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2
|
||||
.isSelected());
|
||||
settings.setRetainRedundantCasts(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5
|
||||
.isSelected());
|
||||
settings.setUnicodeOutputEnabled(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1
|
||||
.isSelected());
|
||||
settings.setFormattingOptions(JavaFormattingOptions.createDefault());
|
||||
return settings;
|
||||
}
|
||||
|
@ -72,7 +86,8 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
|
||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||
+ "temp";
|
||||
int fileNumber = getClassNumber(fileStart, ".class");
|
||||
|
||||
final File tempClass = new File(fileStart + fileNumber + ".class");
|
||||
|
@ -87,12 +102,12 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
||||
|
||||
DecompilerSettings settings = getDecompilerSettings();
|
||||
|
||||
LuytenTypeLoader typeLoader = new LuytenTypeLoader();
|
||||
MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
|
||||
TypeReference type = metadataSystem.lookupType(tempClass.getCanonicalPath());
|
||||
TypeReference type = metadataSystem.lookupType(tempClass
|
||||
.getCanonicalPath());
|
||||
|
||||
DecompilationOptions decompilationOptions = new DecompilationOptions();
|
||||
decompilationOptions.setSettings(DecompilerSettings.javaDefaults());
|
||||
|
@ -103,10 +118,10 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
throw new Exception("Unable to resolve type.");
|
||||
}
|
||||
StringWriter stringwriter = new StringWriter();
|
||||
settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions);
|
||||
settings.getLanguage().decompileType(resolvedType,
|
||||
new PlainTextOutput(stringwriter), decompilationOptions);
|
||||
String decompiledSource = stringwriter.toString();
|
||||
|
||||
|
||||
return decompiledSource;
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
|
@ -116,11 +131,13 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
|
||||
@Override
|
||||
public void decompileToZip(String zipName) {
|
||||
File tempZip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
|
||||
File tempZip = new File(BytecodeViewer.tempDirectory
|
||||
+ BytecodeViewer.fs + "temp.jar");
|
||||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
tempZip.getAbsolutePath());
|
||||
|
||||
try {
|
||||
doSaveJarDecompiled(tempZip, new File(zipName));
|
||||
|
@ -134,7 +151,8 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
* @author DeathMarine
|
||||
*
|
||||
*/
|
||||
private void doSaveJarDecompiled(File inFile, File outFile) throws Exception {
|
||||
private void doSaveJarDecompiled(File inFile, File outFile)
|
||||
throws Exception {
|
||||
try (JarFile jfile = new JarFile(inFile);
|
||||
FileOutputStream dest = new FileOutputStream(outFile);
|
||||
BufferedOutputStream buffDest = new BufferedOutputStream(dest);
|
||||
|
@ -155,19 +173,24 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
while (ent.hasMoreElements()) {
|
||||
JarEntry entry = ent.nextElement();
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
JarEntry etn = new JarEntry(entry.getName().replace(".class", ".java"));
|
||||
JarEntry etn = new JarEntry(entry.getName().replace(
|
||||
".class", ".java"));
|
||||
if (history.add(etn)) {
|
||||
out.putNextEntry(etn);
|
||||
try {
|
||||
String internalName = StringUtilities.removeRight(entry.getName(), ".class");
|
||||
TypeReference type = metadataSystem.lookupType(internalName);
|
||||
String internalName = StringUtilities.removeRight(
|
||||
entry.getName(), ".class");
|
||||
TypeReference type = metadataSystem
|
||||
.lookupType(internalName);
|
||||
TypeDefinition resolvedType = null;
|
||||
if ((type == null) || ((resolvedType = type.resolve()) == null)) {
|
||||
if ((type == null)
|
||||
|| ((resolvedType = type.resolve()) == null)) {
|
||||
throw new Exception("Unable to resolve type.");
|
||||
}
|
||||
Writer writer = new OutputStreamWriter(out);
|
||||
settings.getLanguage().decompileType(resolvedType,
|
||||
new PlainTextOutput(writer), decompilationOptions);
|
||||
new PlainTextOutput(writer),
|
||||
decompilationOptions);
|
||||
writer.flush();
|
||||
} finally {
|
||||
out.closeEntry();
|
||||
|
@ -196,7 +219,8 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
out.closeEntry();
|
||||
}
|
||||
} catch (ZipException ze) {
|
||||
// some jar-s contain duplicate pom.xml entries: ignore it
|
||||
// some jar-s contain duplicate pom.xml entries: ignore
|
||||
// it
|
||||
if (!ze.getMessage().contains("duplicate")) {
|
||||
throw ze;
|
||||
}
|
||||
|
@ -206,7 +230,6 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author DeathMarine
|
||||
|
@ -225,7 +248,8 @@ public class ProcyonDecompiler extends JavaDecompiler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean tryLoadType(final String internalName, final Buffer buffer) {
|
||||
public boolean tryLoadType(final String internalName,
|
||||
final Buffer buffer) {
|
||||
for (final ITypeLoader typeLoader : _typeLoaders) {
|
||||
if (typeLoader.tryLoadType(internalName, buffer)) {
|
||||
return true;
|
||||
|
|
|
@ -23,7 +23,10 @@ public class AboutWindow extends JFrame {
|
|||
txtrBytecodeViewerIs.setDisabledTextColor(Color.BLACK);
|
||||
txtrBytecodeViewerIs.setWrapStyleWord(true);
|
||||
getContentPane().add(txtrBytecodeViewerIs, "name_140466526081695");
|
||||
txtrBytecodeViewerIs.setText("Bytecode Viewer " + BytecodeViewer.version+ " is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\nDir: "+BytecodeViewer.getBCVDirectory()+"\r\n\r\nIt uses code from the following:\r\n J-RET by WaterWolf\r\n JHexPane by Sam Koivu\r\n RSyntaxTextArea by Bobbylight\r\n Commons IO by Apache\r\n ASM by OW2\r\n CFIDE by Bibl\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee Benfield\r\n\r\nIf you're interested in Java Reverse\r\nEngineering, join The Bytecode Club\r\nhttp://the.bytecode.club");
|
||||
txtrBytecodeViewerIs
|
||||
.setText("Bytecode Viewer 2.3.0 is an open source program\r\ndeveloped by Konloch (konloch@gmail.com)\r\nDir: "
|
||||
+ BytecodeViewer.getBCVDirectory()
|
||||
+ "\r\n\r\nIt uses code from the following:\r\n J-RET by WaterWolf\r\n JHexPane by Sam Koivu\r\n RSyntaxTextArea by Bobbylight\r\n Commons IO by Apache\r\n ASM by OW2\r\n CFIDE by Bibl\r\n FernFlower by Stiver\r\n Procyon by Mstrobel\r\n CFR by Lee Benfield\r\n\r\nIf you're interested in Java Reverse\r\nEngineering, join The Bytecode Club\r\nhttps://the.bytecode.club");
|
||||
txtrBytecodeViewerIs.setEnabled(false);
|
||||
this.setResizable(false);
|
||||
this.setLocationRelativeTo(null);
|
||||
|
|
|
@ -14,16 +14,12 @@ import java.awt.event.KeyEvent;
|
|||
import java.awt.event.KeyListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static javax.swing.ScrollPaneConstants.*;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.AbstractDocument;
|
||||
import javax.swing.text.BoxView;
|
||||
import javax.swing.text.ComponentView;
|
||||
|
@ -64,10 +60,9 @@ import the.bytecode.club.bytecodeviewer.decompilers.java.ProcyonDecompiler;
|
|||
|
||||
public class ClassViewer extends JPanel {
|
||||
|
||||
private boolean sourcePane = false, bytecodePane = false, hexPane = false;
|
||||
|
||||
/**
|
||||
* Whoever wrote this function, THANK YOU!
|
||||
*
|
||||
* @param splitter
|
||||
* @param proportion
|
||||
* @return
|
||||
|
@ -77,8 +72,7 @@ public class ClassViewer extends JPanel {
|
|||
if (splitter.isShowing()) {
|
||||
if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
|
||||
splitter.setDividerLocation(proportion);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
splitter.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent ce) {
|
||||
|
@ -87,13 +81,12 @@ public class ClassViewer extends JPanel {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
splitter.addHierarchyListener(new HierarchyListener() {
|
||||
@Override
|
||||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
if((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 &&
|
||||
splitter.isShowing()) {
|
||||
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0
|
||||
&& splitter.isShowing()) {
|
||||
splitter.removeHierarchyListener(this);
|
||||
setDividerLocation(splitter, proportion);
|
||||
}
|
||||
|
@ -109,12 +102,18 @@ public class ClassViewer extends JPanel {
|
|||
ClassNode cn;
|
||||
JSplitPane sp;
|
||||
JSplitPane sp2;
|
||||
public JCheckBox byteCheck = new JCheckBox("Exact");
|
||||
public JPanel bytePanelSearch = new JPanel(new BorderLayout());
|
||||
public JPanel decompPanelSearch = new JPanel(new BorderLayout());
|
||||
public JCheckBox decompCheck = new JCheckBox("Exact");
|
||||
public JPanel bytePanel = new JPanel(new BorderLayout());
|
||||
public JPanel decompPanel = new JPanel(new BorderLayout());
|
||||
public JPanel panel1Search = new JPanel(new BorderLayout());
|
||||
public JPanel panel2Search = new JPanel(new BorderLayout());
|
||||
public JPanel panel3Search = new JPanel(new BorderLayout());
|
||||
public JCheckBox check1 = new JCheckBox("Exact");
|
||||
public JCheckBox check2 = new JCheckBox("Exact");
|
||||
public JCheckBox check3 = new JCheckBox("Exact");
|
||||
public JPanel panel1 = new JPanel(new BorderLayout());
|
||||
public JPanel panel2 = new JPanel(new BorderLayout());
|
||||
public JPanel panel3 = new JPanel(new BorderLayout());
|
||||
int pane1 = -1;
|
||||
int pane2 = -1;
|
||||
int pane3 = -1;
|
||||
|
||||
/**
|
||||
* This was really interesting to write.
|
||||
|
@ -126,23 +125,27 @@ public class ClassViewer extends JPanel {
|
|||
try {
|
||||
Component[] com = null;
|
||||
if (pane == 0) // bytecode
|
||||
com = bytePanel.getComponents();
|
||||
com = panel1.getComponents();
|
||||
else if (pane == 1)
|
||||
com = decompPanel.getComponents();
|
||||
com = panel2.getComponents();
|
||||
else if (pane == 2)
|
||||
com = panel3.getComponents();
|
||||
|
||||
if (com == null) // someone fucked up, lets prevent a nullpointer.
|
||||
return;
|
||||
|
||||
for (Component c : com) {
|
||||
if (c instanceof RTextScrollPane) {
|
||||
RSyntaxTextArea area = (RSyntaxTextArea) ((RTextScrollPane)c).getViewport().getComponent(0);
|
||||
RSyntaxTextArea area = (RSyntaxTextArea) ((RTextScrollPane) c)
|
||||
.getViewport().getComponent(0);
|
||||
|
||||
if (search.isEmpty()) {
|
||||
highlight(pane, area, "");
|
||||
return;
|
||||
}
|
||||
|
||||
int startLine = area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1;
|
||||
int startLine = area.getDocument().getDefaultRootElement()
|
||||
.getElementIndex(area.getCaretPosition()) + 1;
|
||||
int currentLine = 1;
|
||||
boolean canSearch = false;
|
||||
String[] test = null;
|
||||
|
@ -156,9 +159,8 @@ public class ClassViewer extends JPanel {
|
|||
|
||||
if (next) {
|
||||
for (String s : test) {
|
||||
if(pane == 0 && !byteCheck.isSelected() ||
|
||||
pane == 1 && !decompCheck.isSelected())
|
||||
{
|
||||
if (pane == 0 && !check1.isSelected() || pane == 1
|
||||
&& !check2.isSelected()) {
|
||||
s = s.toLowerCase();
|
||||
search = search.toLowerCase();
|
||||
}
|
||||
|
@ -168,7 +170,8 @@ public class ClassViewer extends JPanel {
|
|||
} else if (s.contains(search)) {
|
||||
if (canSearch) {
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(currentLine-1)
|
||||
.getDefaultRootElement()
|
||||
.getElement(currentLine - 1)
|
||||
.getStartOffset());
|
||||
canSearch = false;
|
||||
found = true;
|
||||
|
@ -183,15 +186,15 @@ public class ClassViewer extends JPanel {
|
|||
|
||||
if (!found && firstPos != -1) {
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(firstPos-1)
|
||||
.getStartOffset());
|
||||
.getDefaultRootElement()
|
||||
.getElement(firstPos - 1).getStartOffset());
|
||||
}
|
||||
} else {
|
||||
canSearch = true;
|
||||
for (String s : test) {
|
||||
if(pane == 0 && !byteCheck.isSelected() ||
|
||||
pane == 1 && !decompCheck.isSelected())
|
||||
{
|
||||
if (pane == 0 && !check1.isSelected() || pane == 1
|
||||
&& !check2.isSelected() || pane == 2
|
||||
&& !check3.isSelected()) {
|
||||
s = s.toLowerCase();
|
||||
search = search.toLowerCase();
|
||||
}
|
||||
|
@ -199,7 +202,8 @@ public class ClassViewer extends JPanel {
|
|||
if (s.contains(search)) {
|
||||
if (lastGoodLine != -1 && canSearch)
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(lastGoodLine-1)
|
||||
.getDefaultRootElement()
|
||||
.getElement(lastGoodLine - 1)
|
||||
.getStartOffset());
|
||||
|
||||
lastGoodLine = currentLine;
|
||||
|
@ -210,9 +214,14 @@ public class ClassViewer extends JPanel {
|
|||
currentLine++;
|
||||
}
|
||||
|
||||
if(lastGoodLine != -1 && area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1 == startLine) {
|
||||
if (lastGoodLine != -1
|
||||
&& area.getDocument()
|
||||
.getDefaultRootElement()
|
||||
.getElementIndex(
|
||||
area.getCaretPosition()) + 1 == startLine) {
|
||||
area.setCaretPosition(area.getDocument()
|
||||
.getDefaultRootElement().getElement(lastGoodLine-1)
|
||||
.getDefaultRootElement()
|
||||
.getElement(lastGoodLine - 1)
|
||||
.getStartOffset());
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +233,8 @@ public class ClassViewer extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
private DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,62,150));
|
||||
private DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(
|
||||
new Color(255, 62, 150));
|
||||
|
||||
public void highlight(int pane, JTextComponent textComp, String pattern) {
|
||||
if (pattern.isEmpty()) {
|
||||
|
@ -239,14 +249,17 @@ public class ClassViewer extends JPanel {
|
|||
String text = doc.getText(0, doc.getLength());
|
||||
int pos = 0;
|
||||
|
||||
if((pane == 0 && !byteCheck.isSelected()) || pane == 1 && !decompCheck.isSelected()) {
|
||||
if ((pane == 0 && !check1.isSelected()) || pane == 1
|
||||
&& !check2.isSelected() || pane == 2
|
||||
&& !check3.isSelected()) {
|
||||
pattern = pattern.toLowerCase();
|
||||
text = text.toLowerCase();
|
||||
}
|
||||
|
||||
// Search for pattern
|
||||
while ((pos = text.indexOf(pattern, pos)) >= 0) {
|
||||
// Create highlighter using private painter and apply around pattern
|
||||
// Create highlighter using private painter and apply around
|
||||
// pattern
|
||||
hilite.addHighlight(pos, pos + pattern.length(), painter);
|
||||
pos += pattern.length();
|
||||
}
|
||||
|
@ -261,106 +274,152 @@ public class ClassViewer extends JPanel {
|
|||
JPanel byteButtonPane = new JPanel(new BorderLayout());
|
||||
byteButtonPane.add(byteSearchNext, BorderLayout.WEST);
|
||||
byteButtonPane.add(byteSearchPrev, BorderLayout.EAST);
|
||||
byteSearchNext.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
byteSearchPrev.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
bytePanelSearch.add(byteButtonPane, BorderLayout.WEST);
|
||||
final JTextField byteField = new JTextField();
|
||||
bytePanelSearch.add(byteField, BorderLayout.CENTER);
|
||||
bytePanelSearch.add(byteCheck, BorderLayout.EAST);
|
||||
byteSearchNext
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
byteSearchPrev
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
panel1Search.add(byteButtonPane, BorderLayout.WEST);
|
||||
final JTextField field1 = new JTextField();
|
||||
panel1Search.add(field1, BorderLayout.CENTER);
|
||||
panel1Search.add(check1, BorderLayout.EAST);
|
||||
byteSearchNext.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(0,byteField.getText(), true);
|
||||
search(0, field1.getText(), true);
|
||||
}
|
||||
});
|
||||
byteSearchPrev.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(0,byteField.getText(), false);
|
||||
search(0, field1.getText(), false);
|
||||
}
|
||||
});
|
||||
byteField.addKeyListener(new KeyListener() {
|
||||
field1.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0) {
|
||||
if (arg0.getKeyCode() == KeyEvent.VK_ENTER)
|
||||
search(0,byteField.getText(), true);
|
||||
search(0, field1.getText(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {}
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0) {}
|
||||
public void keyTyped(KeyEvent arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
JButton decompSearchNext = new JButton();
|
||||
JButton decompSearchPrev = new JButton();
|
||||
JPanel decompButtonPane = new JPanel(new BorderLayout());
|
||||
decompButtonPane.add(decompSearchNext, BorderLayout.WEST);
|
||||
decompButtonPane.add(decompSearchPrev, BorderLayout.EAST);
|
||||
decompSearchNext.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
decompSearchPrev.setIcon(new ImageIcon(BytecodeViewer.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
decompPanelSearch.add(decompButtonPane, BorderLayout.WEST);
|
||||
final JTextField decompField = new JTextField();
|
||||
decompPanelSearch.add(decompField, BorderLayout.CENTER);
|
||||
decompPanelSearch.add(decompCheck, BorderLayout.EAST);
|
||||
decompSearchNext.addActionListener(new ActionListener() {
|
||||
JButton searchNext2 = new JButton();
|
||||
JButton searchPrev2 = new JButton();
|
||||
JPanel buttonPane2 = new JPanel(new BorderLayout());
|
||||
buttonPane2.add(searchNext2, BorderLayout.WEST);
|
||||
buttonPane2.add(searchPrev2, BorderLayout.EAST);
|
||||
searchNext2
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
searchPrev2
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
panel2Search.add(buttonPane2, BorderLayout.WEST);
|
||||
final JTextField field2 = new JTextField();
|
||||
panel2Search.add(field2, BorderLayout.CENTER);
|
||||
panel2Search.add(check2, BorderLayout.EAST);
|
||||
searchNext2.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(1,decompField.getText(), true);
|
||||
search(1, field2.getText(), true);
|
||||
}
|
||||
});
|
||||
decompSearchPrev.addActionListener(new ActionListener() {
|
||||
searchPrev2.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(1,decompField.getText(), false);
|
||||
search(1, field2.getText(), false);
|
||||
}
|
||||
});
|
||||
decompField.addKeyListener(new KeyListener() {
|
||||
field2.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0) {
|
||||
if (arg0.getKeyCode() == KeyEvent.VK_ENTER)
|
||||
search(1,decompField.getText(), true);
|
||||
search(1, field2.getText(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {}
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0) {}
|
||||
public void keyTyped(KeyEvent arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
sourcePane = BytecodeViewer.viewer.sourcePane.isSelected();
|
||||
bytecodePane = BytecodeViewer.viewer.bytecodePane.isSelected();
|
||||
hexPane = BytecodeViewer.viewer.hexPane.isSelected();
|
||||
JButton searchNext3 = new JButton();
|
||||
JButton searchPrev3 = new JButton();
|
||||
JPanel buttonPane3 = new JPanel(new BorderLayout());
|
||||
buttonPane3.add(searchNext3, BorderLayout.WEST);
|
||||
buttonPane3.add(searchPrev3, BorderLayout.EAST);
|
||||
searchNext3
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")));
|
||||
searchPrev3
|
||||
.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")));
|
||||
panel3Search.add(buttonPane3, BorderLayout.WEST);
|
||||
final JTextField field3 = new JTextField();
|
||||
panel3Search.add(field3, BorderLayout.CENTER);
|
||||
panel3Search.add(check3, BorderLayout.EAST);
|
||||
searchNext3.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(2, field3.getText(), true);
|
||||
}
|
||||
});
|
||||
searchPrev3.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
search(2, field3.getText(), false);
|
||||
}
|
||||
});
|
||||
field3.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0) {
|
||||
if (arg0.getKeyCode() == KeyEvent.VK_ENTER)
|
||||
search(2, field3.getText(), true);
|
||||
}
|
||||
|
||||
if(bytecodePane)
|
||||
bytePanel.add(bytePanelSearch, BorderLayout.NORTH);
|
||||
if(sourcePane)
|
||||
decompPanel.add(decompPanelSearch, BorderLayout.NORTH);
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
this.name = name;
|
||||
this.cn = cn;
|
||||
this.setName(name);
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
this.sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, decompPanel, bytePanel);
|
||||
this.sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2);
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
JHexEditor hex = new JHexEditor(cw.toByteArray());
|
||||
JScrollPane penis;
|
||||
if(hexPane) {
|
||||
penis = new JScrollPane(hex);
|
||||
} else {
|
||||
penis = new JScrollPane();
|
||||
}
|
||||
penis.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
||||
this.sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, penis);
|
||||
this.sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, panel3);
|
||||
this.add(sp2, BorderLayout.CENTER);
|
||||
|
||||
hex.setMaximumSize(new Dimension(0, Integer.MAX_VALUE));
|
||||
hex.setSize(0, Integer.MAX_VALUE);
|
||||
resetDivider();
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
startPaneUpdater();
|
||||
this.addComponentListener(new ComponentAdapter() {
|
||||
public void componentResized(ComponentEvent e) {
|
||||
|
@ -370,19 +429,22 @@ public class ClassViewer extends JPanel {
|
|||
}
|
||||
|
||||
public void resetDivider() {
|
||||
if(!sourcePane) {
|
||||
sp.setResizeWeight(0);
|
||||
} else if(!bytecodePane) {
|
||||
sp.setResizeWeight(1);
|
||||
} else {
|
||||
sp.setResizeWeight(0.5);
|
||||
}
|
||||
if(hexPane) {
|
||||
if(!sourcePane && !bytecodePane)
|
||||
sp2 = setDividerLocation(sp2, 0);
|
||||
if (pane2 != 0 && pane1 != 0)
|
||||
sp = setDividerLocation(sp, 0.5);
|
||||
else if (pane1 != 0)
|
||||
sp = setDividerLocation(sp, 1);
|
||||
else
|
||||
sp = setDividerLocation(sp, 0);
|
||||
if (pane3 != 0) {
|
||||
sp2.setResizeWeight(0.7);
|
||||
sp2 = setDividerLocation(sp2, 0.7);
|
||||
if ((pane2 == 0 && pane1 != 0) || (pane1 == 0 && pane2 != 0))
|
||||
sp2 = setDividerLocation(sp2, 0.5);
|
||||
else if (pane1 == 0 && pane2 == 0)
|
||||
sp2 = setDividerLocation(sp2, 0);
|
||||
} else {
|
||||
sp2.setResizeWeight(0);
|
||||
sp2 = setDividerLocation(sp2, 1);
|
||||
}
|
||||
}
|
||||
|
@ -391,55 +453,245 @@ public class ClassViewer extends JPanel {
|
|||
static ProcyonDecompiler proc_dc = new ProcyonDecompiler();
|
||||
static CFRDecompiler cfr_dc = new CFRDecompiler();
|
||||
PaneUpdaterThread t;
|
||||
|
||||
public void startPaneUpdater() {
|
||||
if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1None.getModel()))
|
||||
pane1 = 0;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1Proc.getModel()))
|
||||
pane1 = 1;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1CFR.getModel()))
|
||||
pane1 = 2;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1Fern.getModel()))
|
||||
pane1 = 3;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1Bytecode.getModel()))
|
||||
pane1 = 4;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup1
|
||||
.isSelected(BytecodeViewer.viewer.panel1Hexcode.getModel()))
|
||||
pane1 = 5;
|
||||
|
||||
if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2None.getModel()))
|
||||
pane2 = 0;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2Proc.getModel()))
|
||||
pane2 = 1;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2CFR.getModel()))
|
||||
pane2 = 2;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2Fern.getModel()))
|
||||
pane2 = 3;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2Bytecode.getModel()))
|
||||
pane2 = 4;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup2
|
||||
.isSelected(BytecodeViewer.viewer.panel2Hexcode.getModel()))
|
||||
pane2 = 5;
|
||||
|
||||
if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3None.getModel()))
|
||||
pane3 = 0;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3Proc.getModel()))
|
||||
pane3 = 1;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3CFR.getModel()))
|
||||
pane3 = 2;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3Fern.getModel()))
|
||||
pane3 = 3;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3Bytecode.getModel()))
|
||||
pane3 = 4;
|
||||
else if (BytecodeViewer.viewer.decompilerGroup3
|
||||
.isSelected(BytecodeViewer.viewer.panel3Hexcode.getModel()))
|
||||
pane3 = 5;
|
||||
|
||||
t = new PaneUpdaterThread() {
|
||||
String s = "";
|
||||
@Override
|
||||
public void doShit() {
|
||||
final String b = ClassNodeDecompiler.decompile(cn);
|
||||
panel1.removeAll();
|
||||
panel2.removeAll();
|
||||
panel3.removeAll();
|
||||
|
||||
if(BytecodeViewer.viewer.sourcePane.isSelected()) {
|
||||
if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.fernflowerDec.getModel()))
|
||||
s = ff_dc.decompileClassNode(cn);
|
||||
else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.procyonDec.getModel()))
|
||||
s = proc_dc.decompileClassNode(cn);
|
||||
else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.cfrDec.getModel()))
|
||||
s = cfr_dc.decompileClassNode(cn);
|
||||
if (pane1 != 0 && pane1 != 5)
|
||||
panel1.add(panel1Search, BorderLayout.NORTH);
|
||||
if (pane2 != 0 && pane2 != 5)
|
||||
panel2.add(panel2Search, BorderLayout.NORTH);
|
||||
if (pane3 != 0 && pane3 != 5)
|
||||
panel3.add(panel3Search, BorderLayout.NORTH);
|
||||
|
||||
if (pane1 == 1) { // procyon
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(proc_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel1.add(scrollPane);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (pane1 == 2) {// cfr
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(cfr_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel1.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane1 == 3) {// fern
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(ff_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel1.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane1 == 4) {// bytecode
|
||||
RSyntaxTextArea bytecodeArea = new RSyntaxTextArea();
|
||||
bytecodeArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
bytecodeArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
bytecodeArea.setCodeFoldingEnabled(true);
|
||||
bytecodeArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane bytecodeSPane = new RTextScrollPane(bytecodeArea);
|
||||
bytecodeArea.setText(b);
|
||||
|
||||
RSyntaxTextArea sourcecodeArea = new RSyntaxTextArea();
|
||||
sourcecodeArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
sourcecodeArea.setCodeFoldingEnabled(true);
|
||||
sourcecodeArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane sourcecodeSPane = new RTextScrollPane(sourcecodeArea);
|
||||
sourcecodeArea.setText(s);
|
||||
|
||||
if(BytecodeViewer.viewer.bytecodePane.isSelected()) {
|
||||
if(bytePanel.getComponents().length == 2)
|
||||
bytePanel.remove(1);
|
||||
bytePanel.add(bytecodeSPane);
|
||||
}
|
||||
|
||||
if(BytecodeViewer.viewer.sourcePane.isSelected()) {
|
||||
if(decompPanel.getComponents().length == 2)
|
||||
decompPanel.remove(1);
|
||||
decompPanel.add(sourcecodeSPane);
|
||||
}
|
||||
RTextScrollPane bytecodeSPane = new RTextScrollPane(
|
||||
bytecodeArea);
|
||||
bytecodeArea.setText(ClassNodeDecompiler.decompile(cn));
|
||||
bytecodeArea.setCaretPosition(0);
|
||||
sourcecodeArea.setCaretPosition(0);
|
||||
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
panel1.add(bytecodeSPane);
|
||||
}
|
||||
});
|
||||
|
||||
if (pane1 == 5) {// hex
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
JHexEditor hex = new JHexEditor(cw.toByteArray());
|
||||
panel1.add(hex);
|
||||
}
|
||||
|
||||
if (pane2 == 1) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(proc_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel2.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane2 == 2) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(cfr_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel2.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane2 == 3) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(ff_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel2.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane2 == 4) {
|
||||
RSyntaxTextArea paneArea = new RSyntaxTextArea();
|
||||
paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
paneArea.setCodeFoldingEnabled(true);
|
||||
paneArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(paneArea);
|
||||
paneArea.setText(ClassNodeDecompiler.decompile(cn));
|
||||
paneArea.setCaretPosition(0);
|
||||
panel2.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane2 == 5) {
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
JHexEditor hex = new JHexEditor(cw.toByteArray());
|
||||
panel2.add(hex);
|
||||
}
|
||||
|
||||
if (pane3 == 1) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(proc_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel3.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane3 == 2) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(cfr_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel3.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane3 == 3) {
|
||||
RSyntaxTextArea panelArea = new RSyntaxTextArea();
|
||||
panelArea
|
||||
.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
panelArea.setCodeFoldingEnabled(true);
|
||||
panelArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
|
||||
panelArea.setText(ff_dc.decompileClassNode(cn));
|
||||
panelArea.setCaretPosition(0);
|
||||
panel3.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane3 == 4) {
|
||||
RSyntaxTextArea paneArea = new RSyntaxTextArea();
|
||||
paneArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
paneArea.setCodeFoldingEnabled(true);
|
||||
paneArea.setAntiAliasingEnabled(true);
|
||||
RTextScrollPane scrollPane = new RTextScrollPane(paneArea);
|
||||
paneArea.setText(ClassNodeDecompiler.decompile(cn));
|
||||
paneArea.setCaretPosition(0);
|
||||
panel3.add(scrollPane);
|
||||
}
|
||||
|
||||
if (pane3 == 5) {
|
||||
final ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
JHexEditor hex = new JHexEditor(cw.toByteArray());
|
||||
panel3.add(hex);
|
||||
}
|
||||
|
||||
resetDivider();
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -520,5 +772,4 @@ public class ClassViewer extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ public class EZInjectionOptions extends JFrame {
|
|||
setTitle("EZ Injection Options");
|
||||
getContentPane().setLayout(null);
|
||||
|
||||
final JCheckBox accessModifiers = new JCheckBox("Set All Access Modifiers Public");
|
||||
final JCheckBox accessModifiers = new JCheckBox(
|
||||
"Set All Access Modifiers Public");
|
||||
accessModifiers.setSelected(true);
|
||||
accessModifiers.setBounds(6, 7, 232, 23);
|
||||
getContentPane().add(accessModifiers);
|
||||
|
@ -69,17 +70,20 @@ public class EZInjectionOptions extends JFrame {
|
|||
for (Object o : classNode.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
|
||||
if(m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V")) {
|
||||
if (m.name.equals("main")
|
||||
&& m.desc.equals("([Ljava/lang/String;)V")) {
|
||||
if (!b) {
|
||||
b = true;
|
||||
txtThebytecodeclubexamplemainlstring.setText(classNode.name+"."+m.name);
|
||||
txtThebytecodeclubexamplemainlstring
|
||||
.setText(classNode.name + "." + m.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!b)
|
||||
txtThebytecodeclubexamplemainlstring.setText("the/bytecode/club/Example.main");
|
||||
txtThebytecodeclubexamplemainlstring
|
||||
.setText("the/bytecode/club/Example.main");
|
||||
|
||||
txtThebytecodeclubexamplemainlstring.setBounds(6, 281, 232, 20);
|
||||
getContentPane().add(txtThebytecodeclubexamplemainlstring);
|
||||
|
@ -101,11 +105,13 @@ public class EZInjectionOptions extends JFrame {
|
|||
textField_1.setBounds(6, 220, 232, 20);
|
||||
getContentPane().add(textField_1);
|
||||
|
||||
final JCheckBox forceProxy = new JCheckBox("Force Proxy (socks5, host:port):");
|
||||
final JCheckBox forceProxy = new JCheckBox(
|
||||
"Force Proxy (socks5, host:port):");
|
||||
forceProxy.setBounds(6, 190, 232, 23);
|
||||
getContentPane().add(forceProxy);
|
||||
|
||||
final JCheckBox launchReflectionKit = new JCheckBox("Launch Reflection Kit On Successful Invoke");
|
||||
final JCheckBox launchReflectionKit = new JCheckBox(
|
||||
"Launch Reflection Kit On Successful Invoke");
|
||||
launchReflectionKit.setEnabled(false);
|
||||
launchReflectionKit.setBounds(6, 308, 232, 23);
|
||||
getContentPane().add(launchReflectionKit);
|
||||
|
@ -115,14 +121,24 @@ public class EZInjectionOptions extends JFrame {
|
|||
console.setSelected(true);
|
||||
getContentPane().add(console);
|
||||
|
||||
final JCheckBox chckbxPrintToTerminal = new JCheckBox("Print To Command Line");
|
||||
final JCheckBox chckbxPrintToTerminal = new JCheckBox(
|
||||
"Print To Command Line");
|
||||
chckbxPrintToTerminal.setSelected(true);
|
||||
chckbxPrintToTerminal.setBounds(6, 363, 232, 23);
|
||||
getContentPane().add(chckbxPrintToTerminal);
|
||||
this.setLocationRelativeTo(null);
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
PluginManager.runPlugin(new EZInjection(accessModifiers.isSelected(), injectHooks.isSelected(), debugMethodCalls.isSelected(), invokeMethod.isSelected(), txtThebytecodeclubexamplemainlstring.getText(), runtime.isSelected(), system.isSelected(), textField.getText(), textField_1.getText(), forceProxy.isSelected(), launchReflectionKit.isSelected(), console.isSelected(), chckbxPrintToTerminal.isSelected()));
|
||||
PluginManager.runPlugin(new EZInjection(accessModifiers
|
||||
.isSelected(), injectHooks.isSelected(),
|
||||
debugMethodCalls.isSelected(), invokeMethod
|
||||
.isSelected(),
|
||||
txtThebytecodeclubexamplemainlstring.getText(), runtime
|
||||
.isSelected(), system.isSelected(), textField
|
||||
.getText(), textField_1.getText(), forceProxy
|
||||
.isSelected(),
|
||||
launchReflectionKit.isSelected(), console.isSelected(),
|
||||
chckbxPrintToTerminal.isSelected()));
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,7 +25,8 @@ public class ExportJar extends JFrame {
|
|||
btnNewButton.setMaximumSize(new Dimension(999, 23));
|
||||
btnNewButton.setMinimumSize(new Dimension(999, 23));
|
||||
btnNewButton.setSize(new Dimension(999, 0));
|
||||
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
||||
getContentPane().setLayout(
|
||||
new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
getContentPane().add(scrollPane);
|
||||
|
@ -41,7 +42,8 @@ public class ExportJar extends JFrame {
|
|||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
BytecodeViewer.viewer.setC(true);
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath, mani.getText());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath,
|
||||
mani.getText());
|
||||
BytecodeViewer.viewer.setC(false);
|
||||
dispose();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
import the.bytecode.club.bytecodeviewer.*;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FileNavigationPane extends VisibleComponent implements FileDrop.Listener {
|
||||
public class FileNavigationPane extends VisibleComponent implements
|
||||
FileDrop.Listener {
|
||||
|
||||
FileChangeNotifier fcn;
|
||||
JCheckBox exact = new JCheckBox("Exact");
|
||||
|
@ -67,7 +68,8 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
nameBuffer.append("/");
|
||||
}
|
||||
}
|
||||
final ClassNode cn = BytecodeViewer.getClassNode(nameBuffer.toString());
|
||||
final ClassNode cn = BytecodeViewer.getClassNode(nameBuffer
|
||||
.toString());
|
||||
if (cn != null) {
|
||||
openClassFileToWorkSpace(nameBuffer.toString(), cn);
|
||||
}
|
||||
|
@ -90,25 +92,27 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
|
||||
if (qt.contains(".")) {
|
||||
path = qt.split("\\.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
path = new String[] { qt };
|
||||
}
|
||||
|
||||
MyTreeNode curNode = treeRoot;
|
||||
pathLoop:
|
||||
for (int i = 0;i < path.length; i++) {
|
||||
if (exact.isSelected()) {
|
||||
pathLoop: for (int i = 0; i < path.length; i++) {
|
||||
final String pathName = path[i];
|
||||
final boolean isLast = i == path.length - 1;
|
||||
|
||||
for (int c = 0; c < curNode.getChildCount(); c++) {
|
||||
final MyTreeNode child = (MyTreeNode) curNode.getChildAt(c);
|
||||
final MyTreeNode child = (MyTreeNode) curNode
|
||||
.getChildAt(c);
|
||||
|
||||
if(!exact.isSelected()) {
|
||||
if (((String)child.getUserObject()).toLowerCase().contains(pathName.toLowerCase())) {
|
||||
if (((String) child.getUserObject())
|
||||
.toLowerCase().contains(
|
||||
pathName.toLowerCase())) {
|
||||
curNode = child;
|
||||
if (isLast) {
|
||||
final TreePath pathn = new TreePath(curNode.getPath());
|
||||
final TreePath pathn = new TreePath(
|
||||
curNode.getPath());
|
||||
tree.setSelectionPath(pathn);
|
||||
tree.makeVisible(pathn);
|
||||
tree.scrollPathToVisible(pathn);
|
||||
|
@ -117,25 +121,50 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
}
|
||||
continue pathLoop;
|
||||
}
|
||||
} else {
|
||||
if (((String)child.getUserObject()).equals(pathName)) {
|
||||
curNode = child;
|
||||
if (isLast) {
|
||||
final TreePath pathn = new TreePath(curNode.getPath());
|
||||
tree.setSelectionPath(pathn);
|
||||
tree.makeVisible(pathn);
|
||||
tree.scrollPathToVisible(pathn);
|
||||
System.out.println("Found! " + curNode);
|
||||
break pathLoop;
|
||||
}
|
||||
continue pathLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Could not find " + pathName);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<MyTreeNode> enums = curNode
|
||||
.depthFirstEnumeration();
|
||||
while (enums != null && enums.hasMoreElements()) {
|
||||
|
||||
MyTreeNode node = enums.nextElement();
|
||||
// System.out.println("enum " +
|
||||
// node.getUserObject());
|
||||
if (node.isLeaf()) {
|
||||
if (((String) (node.getUserObject()))
|
||||
.equalsIgnoreCase(path[path.length - 1])) {
|
||||
TreeNode pathArray[] = node.getPath();
|
||||
int k = 0;
|
||||
StringBuffer fullPath = new StringBuffer();
|
||||
while (pathArray != null
|
||||
&& k < pathArray.length) {
|
||||
MyTreeNode n = (MyTreeNode) pathArray[k];
|
||||
fullPath.append((String) (n
|
||||
.getUserObject()));
|
||||
if (k++ != pathArray.length - 1) {
|
||||
fullPath.append(".");
|
||||
}
|
||||
}
|
||||
String fullPathString = fullPath.toString();
|
||||
if (fullPathString != null
|
||||
&& fullPathString.toLowerCase()
|
||||
.contains(qt.toLowerCase())) {
|
||||
System.out.println("Found! " + node);
|
||||
final TreePath pathn = new TreePath(
|
||||
node.getPath());
|
||||
tree.setSelectionPath(pathn);
|
||||
tree.makeVisible(pathn);
|
||||
tree.scrollPathToVisible(pathn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +177,7 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
quickSearch.setForeground(Color.black);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(final FocusEvent arg0) {
|
||||
if (quickSearch.getText().isEmpty()) {
|
||||
|
@ -181,18 +211,19 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
|
||||
public void updateTree() {
|
||||
treeRoot.removeAllChildren();
|
||||
for (final Entry<String, ClassNode> entry : BytecodeViewer.loadedClasses.entrySet()) {
|
||||
for (final Entry<String, ClassNode> entry : BytecodeViewer.loadedClasses
|
||||
.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
final String[] spl = name.split("\\/");
|
||||
if (spl.length < 2) {
|
||||
treeRoot.add(new MyTreeNode(name));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
MyTreeNode parent = treeRoot;
|
||||
for (final String s : spl) {
|
||||
MyTreeNode child = null;
|
||||
for (int i = 0; i < parent.getChildCount(); i++) {
|
||||
if (((MyTreeNode) parent.getChildAt(i)).getUserObject().equals(s)) {
|
||||
if (((MyTreeNode) parent.getChildAt(i)).getUserObject()
|
||||
.equals(s)) {
|
||||
child = (MyTreeNode) parent.getChildAt(i);
|
||||
break;
|
||||
}
|
||||
|
@ -206,7 +237,6 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
treeRoot.sort();
|
||||
tree.expandPath(new TreePath(tree.getModel().getRoot()));
|
||||
tree.updateUI();
|
||||
|
@ -266,7 +296,9 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
g.setColor(Color.white);
|
||||
String s = "Drag class/jar here";
|
||||
g.drawString(s, ((int)((getWidth()/2)-(m.getWidth(s)/2))), getHeight()/2);
|
||||
g.drawString(s,
|
||||
((int) ((getWidth() / 2) - (m.getWidth(s) / 2))),
|
||||
getHeight() / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +338,8 @@ public class FileNavigationPane extends VisibleComponent implements FileDrop.Lis
|
|||
// To make sure nodes with children are always on top
|
||||
final int firstOffset = o1.getChildCount() > 0 ? -1000 : 0;
|
||||
final int secondOffset = o2.getChildCount() > 0 ? 1000 : 0;
|
||||
return o1.toString().compareToIgnoreCase(o2.toString()) + firstOffset + secondOffset;
|
||||
return o1.toString().compareToIgnoreCase(o2.toString())
|
||||
+ firstOffset + secondOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.ArrayList;
|
|||
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
|
||||
|
||||
public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||
|
||||
final FernFlowerDecompiler ff_dc = new FernFlowerDecompiler();
|
||||
|
@ -53,131 +52,245 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
final CFRDecompiler cfr_dc = new CFRDecompiler();
|
||||
|
||||
private static final long serialVersionUID = 1851409230530948543L;
|
||||
public JCheckBoxMenuItem debugHelpers = new JCheckBoxMenuItem("Debug Helpers");
|
||||
public JCheckBoxMenuItem debugHelpers = new JCheckBoxMenuItem(
|
||||
"Debug Helpers");
|
||||
private JSplitPane sp1;
|
||||
private JSplitPane sp2;
|
||||
static ArrayList<VisibleComponent> rfComps = new ArrayList<VisibleComponent>();
|
||||
public JCheckBoxMenuItem rbr = new JCheckBoxMenuItem("Hide bridge methods");
|
||||
public JCheckBoxMenuItem rsy = new JCheckBoxMenuItem("Hide synthetic class members");
|
||||
public JCheckBoxMenuItem din = new JCheckBoxMenuItem("Decompile inner classes");
|
||||
public JCheckBoxMenuItem dc4 = new JCheckBoxMenuItem("Collapse 1.4 class references");
|
||||
public JCheckBoxMenuItem rsy = new JCheckBoxMenuItem(
|
||||
"Hide synthetic class members");
|
||||
public JCheckBoxMenuItem din = new JCheckBoxMenuItem(
|
||||
"Decompile inner classes");
|
||||
public JCheckBoxMenuItem dc4 = new JCheckBoxMenuItem(
|
||||
"Collapse 1.4 class references");
|
||||
public JCheckBoxMenuItem das = new JCheckBoxMenuItem("Decompile assertions");
|
||||
public JCheckBoxMenuItem hes = new JCheckBoxMenuItem("Hide empty super invocation");
|
||||
public JCheckBoxMenuItem hdc = new JCheckBoxMenuItem("Hide empty default constructor");
|
||||
public JCheckBoxMenuItem dgs = new JCheckBoxMenuItem("Decompile generic signatures");
|
||||
public JCheckBoxMenuItem ner = new JCheckBoxMenuItem("Assume return not throwing exceptions");
|
||||
public JCheckBoxMenuItem den = new JCheckBoxMenuItem("Decompile enumerations");
|
||||
public JCheckBoxMenuItem rgn = new JCheckBoxMenuItem("Remove getClass() invocation");
|
||||
public JCheckBoxMenuItem bto = new JCheckBoxMenuItem("Interpret int 1 as boolean true");
|
||||
public JCheckBoxMenuItem nns = new JCheckBoxMenuItem("Allow for not set synthetic attribute");
|
||||
public JCheckBoxMenuItem uto = new JCheckBoxMenuItem("Consider nameless types as java.lang.Object");
|
||||
public JCheckBoxMenuItem udv = new JCheckBoxMenuItem("Reconstruct variable names from debug info");
|
||||
public JCheckBoxMenuItem rer = new JCheckBoxMenuItem("Remove empty exception ranges");
|
||||
public JCheckBoxMenuItem fdi = new JCheckBoxMenuItem("Deinline finally structures");
|
||||
public JCheckBoxMenuItem asc = new JCheckBoxMenuItem("Allow only ASCII characters in strings");
|
||||
public JCheckBoxMenuItem sourcePane = new JCheckBoxMenuItem("Source Pane");
|
||||
public JCheckBoxMenuItem bytecodePane = new JCheckBoxMenuItem("Bytecode Pane");
|
||||
public JCheckBoxMenuItem hexPane = new JCheckBoxMenuItem("Hex Pane");
|
||||
public JCheckBoxMenuItem hes = new JCheckBoxMenuItem(
|
||||
"Hide empty super invocation");
|
||||
public JCheckBoxMenuItem hdc = new JCheckBoxMenuItem(
|
||||
"Hide empty default constructor");
|
||||
public JCheckBoxMenuItem dgs = new JCheckBoxMenuItem(
|
||||
"Decompile generic signatures");
|
||||
public JCheckBoxMenuItem ner = new JCheckBoxMenuItem(
|
||||
"Assume return not throwing exceptions");
|
||||
public JCheckBoxMenuItem den = new JCheckBoxMenuItem(
|
||||
"Decompile enumerations");
|
||||
public JCheckBoxMenuItem rgn = new JCheckBoxMenuItem(
|
||||
"Remove getClass() invocation");
|
||||
public JCheckBoxMenuItem bto = new JCheckBoxMenuItem(
|
||||
"Interpret int 1 as boolean true");
|
||||
public JCheckBoxMenuItem nns = new JCheckBoxMenuItem(
|
||||
"Allow for not set synthetic attribute");
|
||||
public JCheckBoxMenuItem uto = new JCheckBoxMenuItem(
|
||||
"Consider nameless types as java.lang.Object");
|
||||
public JCheckBoxMenuItem udv = new JCheckBoxMenuItem(
|
||||
"Reconstruct variable names from debug info");
|
||||
public JCheckBoxMenuItem rer = new JCheckBoxMenuItem(
|
||||
"Remove empty exception ranges");
|
||||
public JCheckBoxMenuItem fdi = new JCheckBoxMenuItem(
|
||||
"Deinline finally structures");
|
||||
public JCheckBoxMenuItem asc = new JCheckBoxMenuItem(
|
||||
"Allow only ASCII characters in strings");
|
||||
private final JMenuItem mntmNewWorkspace = new JMenuItem("New Workspace");
|
||||
public JMenu mnRecentFiles = new JMenu("Recent Files");
|
||||
private final JMenuItem mntmNewMenuItem = new JMenuItem("Save Java Files As..");
|
||||
private final JMenuItem mntmNewMenuItem = new JMenuItem(
|
||||
"Save Java Files As..");
|
||||
private final JMenuItem mntmAbout = new JMenuItem("About");
|
||||
private AboutWindow aboutWindow = new AboutWindow();
|
||||
private final JSeparator separator_3 = new JSeparator();
|
||||
private final JMenu mnNewMenu_1 = new JMenu("Plugins");
|
||||
private final JMenuItem mntmStartExternalPlugin = new JMenuItem("Open Plugin..");
|
||||
private final JMenuItem mntmStartExternalPlugin = new JMenuItem(
|
||||
"Open Plugin..");
|
||||
private final JSeparator separator_4 = new JSeparator();
|
||||
public JMenu mnRecentPlugins = new JMenu("Recent Plugins");
|
||||
private final JSeparator separator_5 = new JSeparator();
|
||||
private final JMenuItem mntmStartZkmString = new JMenuItem("ZKM String Decrypter");
|
||||
private final JMenuItem mntmNewMenuItem_1 = new JMenuItem("Malicious Code Scanner");
|
||||
private final JMenuItem mntmNewMenuItem_2 = new JMenuItem("Allatori String Decrypter");
|
||||
private final JMenuItem mntmShowAllStrings = new JMenuItem("Show All Strings");
|
||||
private final JMenuItem mntmShowMainMethods = new JMenuItem("Show Main Methods");
|
||||
private final JMenuItem mntmStartZkmString = new JMenuItem(
|
||||
"ZKM String Decrypter");
|
||||
private final JMenuItem mntmNewMenuItem_1 = new JMenuItem(
|
||||
"Malicious Code Scanner");
|
||||
private final JMenuItem mntmNewMenuItem_2 = new JMenuItem(
|
||||
"Allatori String Decrypter");
|
||||
private final JMenuItem mntmShowAllStrings = new JMenuItem(
|
||||
"Show All Strings");
|
||||
private final JMenuItem mntmShowMainMethods = new JMenuItem(
|
||||
"Show Main Methods");
|
||||
private final JMenuItem mntmNewMenuItem_3 = new JMenuItem("Save As Jar..");
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
public JCheckBoxMenuItem chckbxmntmNewCheckItem = new JCheckBoxMenuItem("Allow Only ASCII Characters In Strings");
|
||||
private final JMenuItem mntmReplaceStrings = new JMenuItem("Replace Strings");
|
||||
private final JMenuItem mntmReplaceStrings = new JMenuItem(
|
||||
"Replace Strings");
|
||||
private final JMenuItem mntmNewMenuItem_4 = new JMenuItem("");
|
||||
private final JMenu mnNewMenu_2 = new JMenu("Java Decompiler");
|
||||
public final JRadioButtonMenuItem fernflowerDec = new JRadioButtonMenuItem("FernFlower");
|
||||
public final JRadioButtonMenuItem procyonDec = new JRadioButtonMenuItem("Procyon");
|
||||
public final JRadioButtonMenuItem cfrDec = new JRadioButtonMenuItem("CFR");
|
||||
public final ButtonGroup decompilerGroup = new ButtonGroup();
|
||||
private final JMenu mnNewMenu_3 = new JMenu("CFR");
|
||||
private final JMenu mnNewMenu_4 = new JMenu("Procyon");
|
||||
public final JCheckBoxMenuItem decodeenumswitch = new JCheckBoxMenuItem("Decode Enum Switch");
|
||||
public final JCheckBoxMenuItem sugarenums = new JCheckBoxMenuItem("SugarEnums");
|
||||
public final JCheckBoxMenuItem decodestringswitch = new JCheckBoxMenuItem("Decode String Switch");
|
||||
public final JCheckBoxMenuItem arrayiter = new JCheckBoxMenuItem("Arrayiter");
|
||||
public final JCheckBoxMenuItem collectioniter = new JCheckBoxMenuItem("Collectioniter");
|
||||
public final JCheckBoxMenuItem innerclasses = new JCheckBoxMenuItem("Inner Classes");
|
||||
public final JCheckBoxMenuItem removeboilerplate = new JCheckBoxMenuItem("Remove Boiler Plate");
|
||||
public final JCheckBoxMenuItem removeinnerclasssynthetics = new JCheckBoxMenuItem("Remove Inner Class Synthetics");
|
||||
public final JCheckBoxMenuItem decodelambdas = new JCheckBoxMenuItem("Decode Lambdas");
|
||||
public final JCheckBoxMenuItem hidebridgemethods = new JCheckBoxMenuItem("Hide Bridge Methods");
|
||||
public final JCheckBoxMenuItem liftconstructorinit = new JCheckBoxMenuItem("Lift Constructor Init");
|
||||
public final JCheckBoxMenuItem removedeadmethods = new JCheckBoxMenuItem("Remove Dead Methods");
|
||||
public final JCheckBoxMenuItem removebadgenerics = new JCheckBoxMenuItem("Remove Bad Generics");
|
||||
public final JCheckBoxMenuItem sugarasserts = new JCheckBoxMenuItem("Sugar Asserts");
|
||||
public final JCheckBoxMenuItem sugarboxing = new JCheckBoxMenuItem("Sugar Boxing");
|
||||
public final JCheckBoxMenuItem showversion = new JCheckBoxMenuItem("Show Version");
|
||||
public final JCheckBoxMenuItem decodefinally = new JCheckBoxMenuItem("Decode Finally");
|
||||
public final JCheckBoxMenuItem tidymonitors = new JCheckBoxMenuItem("Tidy Monitors");
|
||||
public final JCheckBoxMenuItem decodeenumswitch = new JCheckBoxMenuItem(
|
||||
"Decode Enum Switch");
|
||||
public final JCheckBoxMenuItem sugarenums = new JCheckBoxMenuItem(
|
||||
"SugarEnums");
|
||||
public final JCheckBoxMenuItem decodestringswitch = new JCheckBoxMenuItem(
|
||||
"Decode String Switch");
|
||||
public final JCheckBoxMenuItem arrayiter = new JCheckBoxMenuItem(
|
||||
"Arrayiter");
|
||||
public final JCheckBoxMenuItem collectioniter = new JCheckBoxMenuItem(
|
||||
"Collectioniter");
|
||||
public final JCheckBoxMenuItem innerclasses = new JCheckBoxMenuItem(
|
||||
"Inner Classes");
|
||||
public final JCheckBoxMenuItem removeboilerplate = new JCheckBoxMenuItem(
|
||||
"Remove Boiler Plate");
|
||||
public final JCheckBoxMenuItem removeinnerclasssynthetics = new JCheckBoxMenuItem(
|
||||
"Remove Inner Class Synthetics");
|
||||
public final JCheckBoxMenuItem decodelambdas = new JCheckBoxMenuItem(
|
||||
"Decode Lambdas");
|
||||
public final JCheckBoxMenuItem hidebridgemethods = new JCheckBoxMenuItem(
|
||||
"Hide Bridge Methods");
|
||||
public final JCheckBoxMenuItem liftconstructorinit = new JCheckBoxMenuItem(
|
||||
"Lift Constructor Init");
|
||||
public final JCheckBoxMenuItem removedeadmethods = new JCheckBoxMenuItem(
|
||||
"Remove Dead Methods");
|
||||
public final JCheckBoxMenuItem removebadgenerics = new JCheckBoxMenuItem(
|
||||
"Remove Bad Generics");
|
||||
public final JCheckBoxMenuItem sugarasserts = new JCheckBoxMenuItem(
|
||||
"Sugar Asserts");
|
||||
public final JCheckBoxMenuItem sugarboxing = new JCheckBoxMenuItem(
|
||||
"Sugar Boxing");
|
||||
public final JCheckBoxMenuItem showversion = new JCheckBoxMenuItem(
|
||||
"Show Version");
|
||||
public final JCheckBoxMenuItem decodefinally = new JCheckBoxMenuItem(
|
||||
"Decode Finally");
|
||||
public final JCheckBoxMenuItem tidymonitors = new JCheckBoxMenuItem(
|
||||
"Tidy Monitors");
|
||||
public final JCheckBoxMenuItem lenient = new JCheckBoxMenuItem("Lenient");
|
||||
public final JCheckBoxMenuItem dumpclasspath = new JCheckBoxMenuItem("Dump Classpath");
|
||||
public final JCheckBoxMenuItem dumpclasspath = new JCheckBoxMenuItem(
|
||||
"Dump Classpath");
|
||||
public final JCheckBoxMenuItem comments = new JCheckBoxMenuItem("Comments");
|
||||
public final JCheckBoxMenuItem forcetopsort = new JCheckBoxMenuItem("Force Top Sort");
|
||||
public final JCheckBoxMenuItem forcetopsortaggress = new JCheckBoxMenuItem("Force Top Sort Aggress");
|
||||
public final JCheckBoxMenuItem stringbuffer = new JCheckBoxMenuItem("String Buffer");
|
||||
public final JCheckBoxMenuItem stringbuilder = new JCheckBoxMenuItem("String Builder");
|
||||
public final JCheckBoxMenuItem forcetopsort = new JCheckBoxMenuItem(
|
||||
"Force Top Sort");
|
||||
public final JCheckBoxMenuItem forcetopsortaggress = new JCheckBoxMenuItem(
|
||||
"Force Top Sort Aggress");
|
||||
public final JCheckBoxMenuItem stringbuffer = new JCheckBoxMenuItem(
|
||||
"String Buffer");
|
||||
public final JCheckBoxMenuItem stringbuilder = new JCheckBoxMenuItem(
|
||||
"String Builder");
|
||||
public final JCheckBoxMenuItem silent = new JCheckBoxMenuItem("Silent");
|
||||
public final JCheckBoxMenuItem recover = new JCheckBoxMenuItem("Recover");
|
||||
public final JCheckBoxMenuItem eclipse = new JCheckBoxMenuItem("Eclipse");
|
||||
public final JCheckBoxMenuItem override = new JCheckBoxMenuItem("Override");
|
||||
public final JCheckBoxMenuItem showinferrable = new JCheckBoxMenuItem("Show Inferrable");
|
||||
public final JCheckBoxMenuItem showinferrable = new JCheckBoxMenuItem(
|
||||
"Show Inferrable");
|
||||
public final JCheckBoxMenuItem aexagg = new JCheckBoxMenuItem("Aexagg");
|
||||
public final JCheckBoxMenuItem forcecondpropagate = new JCheckBoxMenuItem("Force Cond Propagate");
|
||||
public final JCheckBoxMenuItem forcecondpropagate = new JCheckBoxMenuItem(
|
||||
"Force Cond Propagate");
|
||||
public final JCheckBoxMenuItem hideutf = new JCheckBoxMenuItem("Hide UTF");
|
||||
public final JCheckBoxMenuItem hidelongstrings = new JCheckBoxMenuItem("Hide Long Strings");
|
||||
public final JCheckBoxMenuItem commentmonitor = new JCheckBoxMenuItem("Comment Monitors");
|
||||
public final JCheckBoxMenuItem allowcorrecting = new JCheckBoxMenuItem("Allow Correcting");
|
||||
public final JCheckBoxMenuItem labelledblocks = new JCheckBoxMenuItem("Labelled Blocks");
|
||||
public final JCheckBoxMenuItem j14classobj = new JCheckBoxMenuItem("J14ClassOBJ");
|
||||
public final JCheckBoxMenuItem hidelangimports = new JCheckBoxMenuItem("Hide Lang Imports");
|
||||
public final JCheckBoxMenuItem recoverytypeclash = new JCheckBoxMenuItem("Recover Type Clash");
|
||||
public final JCheckBoxMenuItem recoverytypehints = new JCheckBoxMenuItem("Recover Type Hints");
|
||||
public final JCheckBoxMenuItem forceturningifs = new JCheckBoxMenuItem("Force Returning IFs");
|
||||
public final JCheckBoxMenuItem forloopaggcapture = new JCheckBoxMenuItem("For Loop AGG Capture");
|
||||
public final JCheckBoxMenuItem forceexceptionprune = new JCheckBoxMenuItem("Force Exception Prune");
|
||||
public final JCheckBoxMenuItem chckbxmntmShowDebugLine = new JCheckBoxMenuItem("Show Debug Line Numbers");
|
||||
public final JCheckBoxMenuItem chckbxmntmSimplifyMemberReferences = new JCheckBoxMenuItem("Simplify Member References");
|
||||
public final JCheckBoxMenuItem mnMergeVariables = new JCheckBoxMenuItem("Merge Variables");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_1 = new JCheckBoxMenuItem("Unicode Output Enabled");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_2 = new JCheckBoxMenuItem("Retain Pointless Switches");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_3 = new JCheckBoxMenuItem("Include Line Numbers In Bytecode");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_4 = new JCheckBoxMenuItem("Include Error Diagnostics");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_5 = new JCheckBoxMenuItem("Retain Redundant Casts");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_6 = new JCheckBoxMenuItem("Always Generate Exception Variable For Catch Blocks");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_7 = new JCheckBoxMenuItem("Show Synthetic Members");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_8 = new JCheckBoxMenuItem("Force Explicit Type Arguments");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_9 = new JCheckBoxMenuItem("Force Explicit Imports");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_10 = new JCheckBoxMenuItem("Flatten Switch Blocks");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_11 = new JCheckBoxMenuItem("Exclude Nested Types");
|
||||
public final JCheckBoxMenuItem chckbxmntmAppendBrackets = new JCheckBoxMenuItem("Append Brackets To Labels");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_12 = new JCheckBoxMenuItem("Update Check");
|
||||
public final JCheckBoxMenuItem hidelongstrings = new JCheckBoxMenuItem(
|
||||
"Hide Long Strings");
|
||||
public final JCheckBoxMenuItem commentmonitor = new JCheckBoxMenuItem(
|
||||
"Comment Monitors");
|
||||
public final JCheckBoxMenuItem allowcorrecting = new JCheckBoxMenuItem(
|
||||
"Allow Correcting");
|
||||
public final JCheckBoxMenuItem labelledblocks = new JCheckBoxMenuItem(
|
||||
"Labelled Blocks");
|
||||
public final JCheckBoxMenuItem j14classobj = new JCheckBoxMenuItem(
|
||||
"J14ClassOBJ");
|
||||
public final JCheckBoxMenuItem hidelangimports = new JCheckBoxMenuItem(
|
||||
"Hide Lang Imports");
|
||||
public final JCheckBoxMenuItem recoverytypeclash = new JCheckBoxMenuItem(
|
||||
"Recover Type Clash");
|
||||
public final JCheckBoxMenuItem recoverytypehints = new JCheckBoxMenuItem(
|
||||
"Recover Type Hints");
|
||||
public final JCheckBoxMenuItem forceturningifs = new JCheckBoxMenuItem(
|
||||
"Force Returning IFs");
|
||||
public final JCheckBoxMenuItem forloopaggcapture = new JCheckBoxMenuItem(
|
||||
"For Loop AGG Capture");
|
||||
public final JCheckBoxMenuItem forceexceptionprune = new JCheckBoxMenuItem(
|
||||
"Force Exception Prune");
|
||||
public final JCheckBoxMenuItem chckbxmntmShowDebugLine = new JCheckBoxMenuItem(
|
||||
"Show Debug Line Numbers");
|
||||
public final JCheckBoxMenuItem chckbxmntmSimplifyMemberReferences = new JCheckBoxMenuItem(
|
||||
"Simplify Member References");
|
||||
public final JCheckBoxMenuItem mnMergeVariables = new JCheckBoxMenuItem(
|
||||
"Merge Variables");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_1 = new JCheckBoxMenuItem(
|
||||
"Unicode Output Enabled");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_2 = new JCheckBoxMenuItem(
|
||||
"Retain Pointless Switches");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_3 = new JCheckBoxMenuItem(
|
||||
"Include Line Numbers In Bytecode");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_4 = new JCheckBoxMenuItem(
|
||||
"Include Error Diagnostics");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_5 = new JCheckBoxMenuItem(
|
||||
"Retain Redundant Casts");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_6 = new JCheckBoxMenuItem(
|
||||
"Always Generate Exception Variable For Catch Blocks");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_7 = new JCheckBoxMenuItem(
|
||||
"Show Synthetic Members");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_8 = new JCheckBoxMenuItem(
|
||||
"Force Explicit Type Arguments");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_9 = new JCheckBoxMenuItem(
|
||||
"Force Explicit Imports");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_10 = new JCheckBoxMenuItem(
|
||||
"Flatten Switch Blocks");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_11 = new JCheckBoxMenuItem(
|
||||
"Exclude Nested Types");
|
||||
public final JCheckBoxMenuItem chckbxmntmAppendBrackets = new JCheckBoxMenuItem(
|
||||
"Append Brackets To Labels");
|
||||
public final JCheckBoxMenuItem chckbxmntmNewCheckItem_12 = new JCheckBoxMenuItem(
|
||||
"Update Check");
|
||||
private final JMenuItem mntmNewMenuItem_5 = new JMenuItem("EZ Inject");
|
||||
private final JMenu mnNewMenu_5 = new JMenu("Obfuscate");
|
||||
private final JMenuItem mntmNewMenuItem_6 = new JMenuItem("Rename Fields");
|
||||
private final JMenuItem mntmNewMenuItem_7 = new JMenuItem("Rename Methods");
|
||||
private final JMenuItem mntmNewMenuItem_8 = new JMenuItem("Move All Classes Into Root Package");
|
||||
private final JMenuItem mntmNewMenuItem_8 = new JMenuItem(
|
||||
"Move All Classes Into Root Package");
|
||||
private final JMenuItem mntmNewMenuItem_9 = new JMenuItem("Control Flow");
|
||||
private final JMenuItem mntmNewMenuItem_10 = new JMenuItem("Junk Code");
|
||||
public final ButtonGroup obfuscatorGroup = new ButtonGroup();
|
||||
public final JRadioButtonMenuItem strongObf = new JRadioButtonMenuItem("Strong Obfuscation");
|
||||
public final JRadioButtonMenuItem lightObf = new JRadioButtonMenuItem("Light Obfuscation");
|
||||
public final JRadioButtonMenuItem strongObf = new JRadioButtonMenuItem(
|
||||
"Strong Obfuscation");
|
||||
public final JRadioButtonMenuItem lightObf = new JRadioButtonMenuItem(
|
||||
"Light Obfuscation");
|
||||
private final JMenuItem mntmNewMenuItem_11 = new JMenuItem("Rename Classes");
|
||||
private final JSeparator separator_2 = new JSeparator();
|
||||
public final ButtonGroup decompilerGroup1 = new ButtonGroup();
|
||||
public final ButtonGroup decompilerGroup2 = new ButtonGroup();
|
||||
public final ButtonGroup decompilerGroup3 = new ButtonGroup();
|
||||
private final JMenu mnNewMenu_6 = new JMenu("View");
|
||||
private final JMenu mnNewMenu_7 = new JMenu("Pane 1");
|
||||
private final JMenu mnNewMenu_8 = new JMenu("Pane 2");
|
||||
private final JMenu mnNewMenu_9 = new JMenu("Pane 3");
|
||||
public final JRadioButtonMenuItem panel1None = new JRadioButtonMenuItem(
|
||||
"None");
|
||||
public final JRadioButtonMenuItem panel1Hexcode = new JRadioButtonMenuItem(
|
||||
"Hexcode");
|
||||
public final JRadioButtonMenuItem panel1Bytecode = new JRadioButtonMenuItem(
|
||||
"Bytecode");
|
||||
public final JRadioButtonMenuItem panel1Fern = new JRadioButtonMenuItem(
|
||||
"FernFlower");
|
||||
public final JRadioButtonMenuItem panel1CFR = new JRadioButtonMenuItem(
|
||||
"CFR");
|
||||
public final JRadioButtonMenuItem panel1Proc = new JRadioButtonMenuItem(
|
||||
"Procyon");
|
||||
public final JRadioButtonMenuItem panel2None = new JRadioButtonMenuItem(
|
||||
"None");
|
||||
public final JRadioButtonMenuItem panel2Proc = new JRadioButtonMenuItem(
|
||||
"Procyon");
|
||||
public final JRadioButtonMenuItem panel2CFR = new JRadioButtonMenuItem(
|
||||
"CFR");
|
||||
public final JRadioButtonMenuItem panel2Bytecode = new JRadioButtonMenuItem(
|
||||
"Bytecode");
|
||||
public final JRadioButtonMenuItem panel2Fern = new JRadioButtonMenuItem(
|
||||
"FernFlower");
|
||||
public final JRadioButtonMenuItem panel2Hexcode = new JRadioButtonMenuItem(
|
||||
"Hexcode");
|
||||
public final JRadioButtonMenuItem panel3None = new JRadioButtonMenuItem(
|
||||
"None");
|
||||
public final JRadioButtonMenuItem panel3Proc = new JRadioButtonMenuItem(
|
||||
"Procyon");
|
||||
public final JRadioButtonMenuItem panel3CFR = new JRadioButtonMenuItem(
|
||||
"CFR");
|
||||
public final JRadioButtonMenuItem panel3Fern = new JRadioButtonMenuItem(
|
||||
"FernFlower");
|
||||
public final JRadioButtonMenuItem panel3Bytecode = new JRadioButtonMenuItem(
|
||||
"Bytecode");
|
||||
public final JRadioButtonMenuItem panel3Hexcode = new JRadioButtonMenuItem(
|
||||
"Hexcode");
|
||||
|
||||
public void setC(boolean busy) {
|
||||
if (busy) {
|
||||
|
@ -193,7 +306,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (c instanceof WorkPane) {
|
||||
WorkPane w = (WorkPane) c;
|
||||
for (Component c2 : w.tabs.getComponents())
|
||||
c2.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
c2.setCursor(Cursor
|
||||
.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -209,7 +323,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (c instanceof WorkPane) {
|
||||
WorkPane w = (WorkPane) c;
|
||||
for (Component c2 : w.tabs.getComponents())
|
||||
c2.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
c2.setCursor(Cursor
|
||||
.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,9 +335,13 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
public void run() {
|
||||
if (busy) {
|
||||
try {
|
||||
mntmNewMenuItem_4.setIcon(new ImageIcon(getClass().getResource("/resources/1.gif")));
|
||||
mntmNewMenuItem_4.setIcon(new ImageIcon(getClass()
|
||||
.getResource("/resources/1.gif")));
|
||||
} catch (NullPointerException e) {
|
||||
mntmNewMenuItem_4.setIcon(new ImageIcon(BytecodeViewer.b642IMG("R0lGODlhEAALAPQAAP///wAAANra2tDQ0Orq6gcHBwAAAC8vL4KCgmFhYbq6uiMjI0tLS4qKimVlZb6+vicnJwUFBU9PT+bm5tjY2PT09Dk5Odzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH5BAkLAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7"), ""));
|
||||
mntmNewMenuItem_4.setIcon(new ImageIcon(
|
||||
BytecodeViewer
|
||||
.b642IMG("R0lGODlhEAALAPQAAP///wAAANra2tDQ0Orq6gcHBwAAAC8vL4KCgmFhYbq6uiMjI0tLS4qKimVlZb6+vicnJwUFBU9PT+bm5tjY2PT09Dk5Odzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH5BAkLAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7"),
|
||||
""));
|
||||
}
|
||||
} else
|
||||
mntmNewMenuItem_4.setIcon(null);
|
||||
|
@ -233,10 +352,27 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
public MainViewerGUI() {
|
||||
this.setIconImages(BytecodeViewer.iconList);
|
||||
decompilerGroup.add(fernflowerDec);
|
||||
decompilerGroup.add(procyonDec);
|
||||
decompilerGroup.add(cfrDec);
|
||||
decompilerGroup.setSelected(procyonDec.getModel(), true);
|
||||
decompilerGroup1.add(panel1None);
|
||||
decompilerGroup1.add(panel1Fern);
|
||||
decompilerGroup1.add(panel1Proc);
|
||||
decompilerGroup1.add(panel1CFR);
|
||||
decompilerGroup1.add(panel1Bytecode);
|
||||
decompilerGroup1.add(panel1Hexcode);
|
||||
decompilerGroup1.setSelected(panel1Proc.getModel(), true);
|
||||
decompilerGroup2.add(panel2None);
|
||||
decompilerGroup2.add(panel2Fern);
|
||||
decompilerGroup2.add(panel2Proc);
|
||||
decompilerGroup2.add(panel2CFR);
|
||||
decompilerGroup2.add(panel2Bytecode);
|
||||
decompilerGroup2.add(panel2Hexcode);
|
||||
decompilerGroup2.setSelected(panel2Bytecode.getModel(), true);
|
||||
decompilerGroup3.add(panel3None);
|
||||
decompilerGroup3.add(panel3Fern);
|
||||
decompilerGroup3.add(panel3Proc);
|
||||
decompilerGroup3.add(panel3CFR);
|
||||
decompilerGroup3.add(panel3Bytecode);
|
||||
decompilerGroup3.add(panel3Hexcode);
|
||||
decompilerGroup3.setSelected(panel3None.getModel(), true);
|
||||
obfuscatorGroup.add(strongObf);
|
||||
obfuscatorGroup.add(lightObf);
|
||||
obfuscatorGroup.setSelected(strongObf.getModel(), true);
|
||||
|
@ -253,8 +389,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
fdi.setSelected(true);
|
||||
asc.setSelected(false);
|
||||
debugHelpers.setSelected(true);
|
||||
sourcePane.setSelected(true);
|
||||
bytecodePane.setSelected(true);
|
||||
// cfr
|
||||
decodeenumswitch.setSelected(true);
|
||||
sugarenums.setSelected(true);
|
||||
|
@ -330,7 +464,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||
try {
|
||||
BytecodeViewer.viewer.setC(true);
|
||||
BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()});
|
||||
BytecodeViewer.openFiles(new File[] { fc
|
||||
.getSelectedFile() });
|
||||
BytecodeViewer.viewer.setC(false);
|
||||
} catch (Exception e1) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
|
||||
|
@ -352,7 +487,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
BytecodeViewer.viewer.setC(true);
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file.getAbsolutePath());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
file.getAbsolutePath());
|
||||
BytecodeViewer.viewer.setC(false);
|
||||
}
|
||||
}
|
||||
|
@ -387,17 +523,69 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
int returnVal = fc.showSaveDialog(MainViewerGUI.this);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
BytecodeViewer.viewer.setC(true);
|
||||
String path = file.getAbsolutePath();
|
||||
if(!path.endsWith(".zip"))
|
||||
path = path + ".zip";
|
||||
if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.fernflowerDec.getModel()))
|
||||
ff_dc.decompileToZip(path);
|
||||
else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.procyonDec.getModel()))
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String path = appendZip(file);// cheap hax cause
|
||||
// string is final
|
||||
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"What decompiler will you use?");
|
||||
Object[] options = new String[] { "Procyon", "CFR",
|
||||
"Fernflower", "Cancel" };
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Select Decompiler");
|
||||
dialog.setVisible(true);
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
|
||||
if (result == 0) {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
proc_dc.decompileToZip(path);
|
||||
else if(BytecodeViewer.viewer.decompilerGroup.isSelected(BytecodeViewer.viewer.cfrDec.getModel()))
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
|
||||
e);
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
if (result == 1) {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
cfr_dc.decompileToZip(path);
|
||||
BytecodeViewer.viewer.setC(false);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
|
||||
e);
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
if (result == 2) {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ff_dc.decompileToZip(path);
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
|
||||
e);
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -425,10 +613,12 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
mntmExit.addActionListener(new ActionListener() {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
JOptionPane pane = new JOptionPane("Are you sure you want to exit?");
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you want to exit?");
|
||||
Object[] options = new String[] { "Yes", "No" };
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Exit");
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Exit");
|
||||
dialog.show();
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
|
@ -436,7 +626,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
|
||||
|
||||
if (result == 0) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
@ -444,20 +633,49 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
});
|
||||
mnNewMenu.add(mntmExit);
|
||||
|
||||
JMenu mnView = new JMenu("View");
|
||||
menuBar.add(mnView);
|
||||
menuBar.add(mnNewMenu_6);
|
||||
|
||||
mnView.add(sourcePane);
|
||||
mnView.add(bytecodePane);
|
||||
mnView.add(hexPane);
|
||||
mnNewMenu_6.add(mnNewMenu_7);
|
||||
|
||||
menuBar.add(mnNewMenu_2);
|
||||
mnNewMenu_7.add(panel1None);
|
||||
|
||||
mnNewMenu_2.add(procyonDec);
|
||||
mnNewMenu_7.add(panel1Proc);
|
||||
|
||||
mnNewMenu_2.add(cfrDec);
|
||||
mnNewMenu_7.add(panel1CFR);
|
||||
|
||||
mnNewMenu_2.add(fernflowerDec);
|
||||
mnNewMenu_7.add(panel1Fern);
|
||||
|
||||
mnNewMenu_7.add(panel1Bytecode);
|
||||
|
||||
mnNewMenu_7.add(panel1Hexcode);
|
||||
|
||||
mnNewMenu_6.add(mnNewMenu_8);
|
||||
|
||||
mnNewMenu_8.add(panel2None);
|
||||
|
||||
mnNewMenu_8.add(panel2Proc);
|
||||
|
||||
mnNewMenu_8.add(panel2CFR);
|
||||
|
||||
mnNewMenu_8.add(panel2Fern);
|
||||
|
||||
mnNewMenu_8.add(panel2Bytecode);
|
||||
|
||||
mnNewMenu_8.add(panel2Hexcode);
|
||||
|
||||
mnNewMenu_6.add(mnNewMenu_9);
|
||||
|
||||
mnNewMenu_9.add(panel3None);
|
||||
|
||||
mnNewMenu_9.add(panel3Proc);
|
||||
|
||||
mnNewMenu_9.add(panel3CFR);
|
||||
|
||||
mnNewMenu_9.add(panel3Fern);
|
||||
|
||||
mnNewMenu_9.add(panel3Bytecode);
|
||||
|
||||
mnNewMenu_9.add(panel3Hexcode);
|
||||
|
||||
menuBar.add(mnNewMenu_4);
|
||||
|
||||
|
@ -615,14 +833,14 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
mnBytecodeDecompilerSettings.add(chckbxmntmAppendBrackets);
|
||||
|
||||
mnBytecodeDecompilerSettings.add(chckbxmntmNewCheckItem);
|
||||
mnNewMenu_5.setVisible(false);
|
||||
|
||||
menuBar.add(mnNewMenu_5);
|
||||
mntmNewMenuItem_6.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (BytecodeViewer.runningObfuscation) {
|
||||
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
BytecodeViewer
|
||||
.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
return;
|
||||
}
|
||||
new RenameFields().start();
|
||||
|
@ -642,7 +860,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
mntmNewMenuItem_7.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (BytecodeViewer.runningObfuscation) {
|
||||
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
BytecodeViewer
|
||||
.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
return;
|
||||
}
|
||||
new RenameMethods().start();
|
||||
|
@ -653,7 +872,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
mntmNewMenuItem_11.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (BytecodeViewer.runningObfuscation) {
|
||||
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
BytecodeViewer
|
||||
.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||
return;
|
||||
}
|
||||
new RenameClasses().start();
|
||||
|
@ -681,8 +901,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (!BytecodeViewer.loadedClasses.isEmpty())
|
||||
new ReplaceStringsOptions().setVisible(true);
|
||||
else {
|
||||
System.out.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer.showMessage("Plugin not ran, put some classes in first.");
|
||||
System.out
|
||||
.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer
|
||||
.showMessage("Plugin not ran, put some classes in first.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -695,8 +917,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (!BytecodeViewer.loadedClasses.isEmpty())
|
||||
new EZInjectionOptions().setVisible(true);
|
||||
else {
|
||||
System.out.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer.showMessage("Plugin not ran, put some classes in first.");
|
||||
System.out
|
||||
.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer
|
||||
.showMessage("Plugin not ran, put some classes in first.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -705,7 +929,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
menuBar.add(mntmNewMenuItem_4);
|
||||
|
||||
|
||||
mntmStartExternalPlugin.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
|
@ -739,8 +962,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
if (!BytecodeViewer.loadedClasses.isEmpty())
|
||||
new MaliciousCodeScannerOptions().setVisible(true);
|
||||
else {
|
||||
System.out.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer.showMessage("Plugin not ran, put some classes in first.");
|
||||
System.out
|
||||
.println("Plugin not ran, put some classes in first.");
|
||||
BytecodeViewer
|
||||
.showMessage("Plugin not ran, put some classes in first.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -757,8 +982,9 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
});
|
||||
|
||||
setSize(new Dimension(800, 400));
|
||||
setTitle("Bytecode Viewer " + BytecodeViewer.version + " - http://the.bytecode.club - @Konloch");
|
||||
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
|
||||
setTitle("Bytecode Viewer 2.3.0 - https://the.bytecode.club - @Konloch");
|
||||
getContentPane().setLayout(
|
||||
new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
|
||||
|
||||
// scrollPane.setViewportView(tree);
|
||||
FileNavigationPane cn = new FileNavigationPane(this);
|
||||
|
@ -785,6 +1011,13 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
this.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
public String appendZip(File file) {
|
||||
String path = file.getAbsolutePath();
|
||||
if (!path.endsWith(".zip"))
|
||||
path = path + ".zip";
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openClassFile(final String name, final ClassNode cn) {
|
||||
for (final VisibleComponent vc : rfComps) {
|
||||
|
@ -809,9 +1042,9 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
String extension = getExtension(f);
|
||||
if (extension != null)
|
||||
return (extension.equals("gy") || extension.equals("groovy") ||
|
||||
extension.equals("py") || extension.equals("python") ||
|
||||
extension.equals("rb") || extension.equals("ruby"));
|
||||
return (extension.equals("gy") || extension.equals("groovy")
|
||||
|| extension.equals("py") || extension.equals("python")
|
||||
|| extension.equals("rb") || extension.equals("ruby"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -841,7 +1074,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
String extension = getExtension(f);
|
||||
if (extension != null)
|
||||
return (extension.equals("jar") || extension.equals("zip") || extension.equals("class"));
|
||||
return (extension.equals("jar") || extension.equals("zip") || extension
|
||||
.equals("class"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ public class MaliciousCodeScannerOptions extends JFrame {
|
|||
setTitle("Malicious Code Scanner Options");
|
||||
getContentPane().setLayout(null);
|
||||
|
||||
final JCheckBox chckbxJavalangreflection = new JCheckBox("java/lang/reflection");
|
||||
final JCheckBox chckbxJavalangreflection = new JCheckBox(
|
||||
"java/lang/reflection");
|
||||
chckbxJavalangreflection.setSelected(true);
|
||||
chckbxJavalangreflection.setBounds(6, 7, 232, 23);
|
||||
getContentPane().add(chckbxJavalangreflection);
|
||||
|
@ -36,27 +37,32 @@ public class MaliciousCodeScannerOptions extends JFrame {
|
|||
chckbxJavaio.setBounds(6, 85, 232, 23);
|
||||
getContentPane().add(chckbxJavaio);
|
||||
|
||||
final JCheckBox chckbxJavalangruntime = new JCheckBox("java/lang/Runtime");
|
||||
final JCheckBox chckbxJavalangruntime = new JCheckBox(
|
||||
"java/lang/Runtime");
|
||||
chckbxJavalangruntime.setSelected(true);
|
||||
chckbxJavalangruntime.setBounds(6, 33, 232, 23);
|
||||
getContentPane().add(chckbxJavalangruntime);
|
||||
|
||||
final JCheckBox chckbxLdcContainswww = new JCheckBox("LDC contains 'www.'");
|
||||
final JCheckBox chckbxLdcContainswww = new JCheckBox(
|
||||
"LDC contains 'www.'");
|
||||
chckbxLdcContainswww.setSelected(true);
|
||||
chckbxLdcContainswww.setBounds(6, 111, 232, 23);
|
||||
getContentPane().add(chckbxLdcContainswww);
|
||||
|
||||
final JCheckBox chckbxLdcContainshttp = new JCheckBox("LDC contains 'http://'");
|
||||
final JCheckBox chckbxLdcContainshttp = new JCheckBox(
|
||||
"LDC contains 'http://'");
|
||||
chckbxLdcContainshttp.setSelected(true);
|
||||
chckbxLdcContainshttp.setBounds(6, 137, 232, 23);
|
||||
getContentPane().add(chckbxLdcContainshttp);
|
||||
|
||||
final JCheckBox chckbxLdcContainshttps = new JCheckBox("LDC contains 'https://'");
|
||||
final JCheckBox chckbxLdcContainshttps = new JCheckBox(
|
||||
"LDC contains 'https://'");
|
||||
chckbxLdcContainshttps.setSelected(true);
|
||||
chckbxLdcContainshttps.setBounds(6, 163, 232, 23);
|
||||
getContentPane().add(chckbxLdcContainshttps);
|
||||
|
||||
final JCheckBox chckbxLdcMatchesIp = new JCheckBox("LDC matches IP regex");
|
||||
final JCheckBox chckbxLdcMatchesIp = new JCheckBox(
|
||||
"LDC matches IP regex");
|
||||
chckbxLdcMatchesIp.setSelected(true);
|
||||
chckbxLdcMatchesIp.setBounds(6, 189, 232, 23);
|
||||
getContentPane().add(chckbxLdcMatchesIp);
|
||||
|
@ -64,10 +70,14 @@ public class MaliciousCodeScannerOptions extends JFrame {
|
|||
JButton btnNewButton = new JButton("Start Scanning");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
PluginManager.runPlugin(new MaliciousCodeScanner(chckbxJavalangreflection.isSelected(),
|
||||
chckbxJavalangruntime.isSelected(), chckbxJavanet.isSelected(), chckbxJavaio.isSelected(),
|
||||
chckbxLdcContainswww.isSelected(), chckbxLdcContainshttp.isSelected(), chckbxLdcContainshttps.isSelected(),
|
||||
chckbxLdcMatchesIp.isSelected()));
|
||||
PluginManager.runPlugin(new MaliciousCodeScanner(
|
||||
chckbxJavalangreflection.isSelected(),
|
||||
chckbxJavalangruntime.isSelected(), chckbxJavanet
|
||||
.isSelected(), chckbxJavaio.isSelected(),
|
||||
chckbxLdcContainswww.isSelected(),
|
||||
chckbxLdcContainshttp.isSelected(),
|
||||
chckbxLdcContainshttps.isSelected(), chckbxLdcMatchesIp
|
||||
.isSelected()));
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -57,13 +57,17 @@ public class ReplaceStringsOptions extends JFrame {
|
|||
getContentPane().add(textField_2);
|
||||
textField_2.setColumns(10);
|
||||
|
||||
final JCheckBox chckbxNewCheckBox = new JCheckBox("Replace All Contains");
|
||||
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.");
|
||||
final JCheckBox chckbxNewCheckBox = new JCheckBox(
|
||||
"Replace All Contains");
|
||||
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.");
|
||||
chckbxNewCheckBox.setBounds(6, 7, 232, 23);
|
||||
getContentPane().add(chckbxNewCheckBox);
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
PluginManager.runPlugin(new ReplaceStrings(textField.getText(), textField_1.getText(), textField_2.getText(), chckbxNewCheckBox.isSelected()));
|
||||
PluginManager.runPlugin(new ReplaceStrings(textField.getText(),
|
||||
textField_1.getText(), textField_2.getText(),
|
||||
chckbxNewCheckBox.isSelected()));
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -122,7 +122,8 @@ public class SearchingPane extends VisibleComponent {
|
|||
public void actionPerformed(final ActionEvent arg0) {
|
||||
treeRoot.removeAllChildren();
|
||||
searchType = (SearchType) typeBox.getSelectedItem();
|
||||
final SearchRadius radius = (SearchRadius) searchRadiusBox.getSelectedItem();
|
||||
final SearchRadius radius = (SearchRadius) searchRadiusBox
|
||||
.getSelectedItem();
|
||||
final SearchResultNotifier srn = new SearchResultNotifier() {
|
||||
@Override
|
||||
public void notifyOfResult(String debug) {
|
||||
|
@ -134,27 +135,36 @@ public class SearchingPane extends VisibleComponent {
|
|||
t = new BackgroundSearchThread() {
|
||||
@Override
|
||||
public void doSearch() {
|
||||
for (ClassNode cln : BytecodeViewer.getLoadedClasses())
|
||||
searchType.details.search(cln, srn, exact.isSelected());
|
||||
for (ClassNode cln : BytecodeViewer
|
||||
.getLoadedClasses())
|
||||
searchType.details.search(cln, srn,
|
||||
exact.isSelected());
|
||||
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search.setEnabled(true);
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search.setText("Search");
|
||||
tree.expandPath(new TreePath(tree.getModel().getRoot()));
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search
|
||||
.setEnabled(true);
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search
|
||||
.setText("Search");
|
||||
tree.expandPath(new TreePath(tree.getModel()
|
||||
.getRoot()));
|
||||
tree.updateUI();
|
||||
}
|
||||
|
||||
};
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search.setEnabled(false);
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search.setText("Searching, please wait..");
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search
|
||||
.setEnabled(false);
|
||||
MainViewerGUI.getComponent(SearchingPane.class).search
|
||||
.setText("Searching, please wait..");
|
||||
t.start();
|
||||
} else { // this should really never be called.
|
||||
BytecodeViewer.showMessage("You currently have a search performing in the background, please wait for that to finish.");
|
||||
BytecodeViewer
|
||||
.showMessage("You currently have a search performing in the background, please wait for that to finish.");
|
||||
}
|
||||
}
|
||||
else if (radius == SearchRadius.Current_Class) {
|
||||
final ClassViewer cv = MainViewerGUI.getComponent(WorkPane.class).getCurrentClass();
|
||||
} else if (radius == SearchRadius.Current_Class) {
|
||||
final ClassViewer cv = MainViewerGUI.getComponent(
|
||||
WorkPane.class).getCurrentClass();
|
||||
if (cv != null) {
|
||||
searchType.details.search(cv.cn, srn, exact.isSelected());
|
||||
searchType.details.search(cv.cn, srn,
|
||||
exact.isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +187,8 @@ public class SearchingPane extends VisibleComponent {
|
|||
String className = path.split(", ")[1].split("\\.")[0];
|
||||
final ClassNode fN = BytecodeViewer.getClassNode(className);
|
||||
if (fN != null) {
|
||||
MainViewerGUI.getComponent(FileNavigationPane.class).openClassFileToWorkSpace(className, fN);
|
||||
MainViewerGUI.getComponent(FileNavigationPane.class)
|
||||
.openClassFileToWorkSpace(className, fN);
|
||||
}
|
||||
|
||||
System.out.println(className);
|
||||
|
@ -189,10 +200,8 @@ public class SearchingPane extends VisibleComponent {
|
|||
}
|
||||
|
||||
public enum SearchType {
|
||||
LDC (new LDCSearch()),
|
||||
Regex (new RegexSearch()),
|
||||
MethodCall (new MethodCallSearch()),
|
||||
FieldCall (new FieldCallSearch());
|
||||
LDC(new LDCSearch()), Regex(new RegexSearch()), MethodCall(
|
||||
new MethodCallSearch()), FieldCall(new FieldCallSearch());
|
||||
|
||||
public final SearchTypeDetails details;
|
||||
|
||||
|
@ -202,8 +211,7 @@ public class SearchingPane extends VisibleComponent {
|
|||
}
|
||||
|
||||
public enum SearchRadius {
|
||||
All_Classes,
|
||||
Current_Class;
|
||||
All_Classes, Current_Class;
|
||||
}
|
||||
|
||||
public void resetWorkspace() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package the.bytecode.club.bytecodeviewer.gui;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
@ -21,8 +22,7 @@ import javax.swing.JTabbedPane;
|
|||
import javax.swing.plaf.basic.BasicButtonUI;
|
||||
|
||||
/**
|
||||
* Component to be used as tabComponent;
|
||||
* Contains a JLabel to show the text and
|
||||
* Component to be used as tabComponent; Contains a JLabel to show the text and
|
||||
* a JButton to close the tab it belongs to
|
||||
*
|
||||
* @author Konloch
|
||||
|
@ -76,10 +76,22 @@ public class TabbedPane extends JPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
@Override public void mouseEntered(MouseEvent arg0) {}
|
||||
@Override public void mouseExited(MouseEvent arg0) {}
|
||||
@Override public void mousePressed(MouseEvent arg0) {}
|
||||
@Override public void mouseReleased(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -134,8 +146,10 @@ public class TabbedPane extends JPanel {
|
|||
g2.setColor(Color.MAGENTA);
|
||||
}
|
||||
final int delta = 6;
|
||||
g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
|
||||
g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
|
||||
g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight()
|
||||
- delta - 1);
|
||||
g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight()
|
||||
- delta - 1);
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ import the.bytecode.club.bytecodeviewer.FileChangeNotifier;
|
|||
*
|
||||
*/
|
||||
|
||||
public abstract class VisibleComponent extends JInternalFrame implements FileChangeNotifier {
|
||||
public abstract class VisibleComponent extends JInternalFrame implements
|
||||
FileChangeNotifier {
|
||||
|
||||
private static final long serialVersionUID = -6453413772343643526L;
|
||||
|
||||
|
@ -25,11 +26,13 @@ public abstract class VisibleComponent extends JInternalFrame implements FileCha
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VisibleComponent() { //because we want to enforce the title argument
|
||||
private VisibleComponent() { // because we want to enforce the title
|
||||
// argument
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openClassFile(final String name, final ClassNode cn) {}
|
||||
public void openClassFile(final String name, final ClassNode cn) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ public class WorkPane extends VisibleComponent implements ActionListener {
|
|||
|
||||
private static final long serialVersionUID = 6542337997679487946L;
|
||||
|
||||
|
||||
FileChangeNotifier fcn;
|
||||
JTabbedPane tabs;
|
||||
|
||||
|
@ -93,12 +92,6 @@ public class WorkPane extends VisibleComponent implements ActionListener {
|
|||
int tabCount = 0;
|
||||
|
||||
public void addWorkingFile(final String name, final ClassNode cn) {
|
||||
if(!BytecodeViewer.viewer.hexPane.isSelected() &&
|
||||
!BytecodeViewer.viewer.sourcePane.isSelected() &&
|
||||
!BytecodeViewer.viewer.bytecodePane.isSelected()) {
|
||||
BytecodeViewer.showMessage("You currently have no viewing panes selected.");
|
||||
return;
|
||||
}
|
||||
if (!workingOn.containsKey(name)) {
|
||||
final Component tabComp = new ClassViewer(name, cn);
|
||||
tabs.add(tabComp);
|
||||
|
|
|
@ -17,9 +17,11 @@ public abstract class JavaObfuscator extends Thread {
|
|||
}
|
||||
|
||||
public int getStringLength() {
|
||||
if(BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.strongObf.getModel())) {
|
||||
if (BytecodeViewer.viewer.obfuscatorGroup
|
||||
.isSelected(BytecodeViewer.viewer.strongObf.getModel())) {
|
||||
return MAX_STRING_LENGTH;
|
||||
} else { //if(BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.lightObf.getModel())) {
|
||||
} else { // if(BytecodeViewer.viewer.obfuscatorGroup.isSelected(BytecodeViewer.viewer.lightObf.getModel()))
|
||||
// {
|
||||
return MIN_STRING_LENGTH;
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +32,14 @@ public abstract class JavaObfuscator extends Thread {
|
|||
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private static Random rnd = new Random();
|
||||
|
||||
private static String randomString(int len) {
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++)
|
||||
sb.append(AB.charAt(rnd.nextInt(AB.length())));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String randomStringNum(int len) {
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++)
|
||||
|
|
|
@ -17,7 +17,8 @@ public class RenameFields extends JavaObfuscator {
|
|||
for (Object o : c.fields.toArray()) {
|
||||
FieldNode f = (FieldNode) o;
|
||||
String newName = generateUniqueName(stringLength);
|
||||
ASMUtil_OLD.renameFieldNode(c.name,f.name,f.desc, null, newName, null);
|
||||
ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null,
|
||||
newName, null);
|
||||
f.name = newName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,21 +17,26 @@ public class RenameMethods extends JavaObfuscator {
|
|||
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
||||
for (Object o : c.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
if( m.access != Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE &&
|
||||
m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED)
|
||||
{
|
||||
if(!m.name.equals("main") &&
|
||||
!m.name.equals("<init>") &&
|
||||
!m.name.equals("<clinit>"))
|
||||
{
|
||||
if (m.access != Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_STATIC
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_PUBLIC
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_PRIVATE
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
+ Opcodes.ACC_PROTECTED) {
|
||||
if (!m.name.equals("main") && !m.name.equals("<init>")
|
||||
&& !m.name.equals("<clinit>")) {
|
||||
String newName = generateUniqueName(stringLength);
|
||||
ASMUtil_OLD.renameMethodNode(c.name,m.name,m.desc,null,newName,null);
|
||||
ASMUtil_OLD.renameMethodNode(c.name, m.name, m.desc,
|
||||
null, newName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,16 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
|||
import the.bytecode.club.bytecodeviewer.gui.GraphicialReflectionKit;
|
||||
|
||||
/**
|
||||
* EZ Injection - This plugin is designed to provide a graphical way for the user to
|
||||
* easily change the access modifiers of all fields/methods, insert hooks into all
|
||||
* functions, and invoke the main function. It also contains an option to launch the
|
||||
* graphical reflection kit, which is pretty much a GUI for reflection.
|
||||
* EZ Injection - This plugin is designed to provide a graphical way for the
|
||||
* user to easily change the access modifiers of all fields/methods, insert
|
||||
* hooks into all functions, and invoke the main function. It also contains an
|
||||
* option to launch the graphical reflection kit, which is pretty much a GUI for
|
||||
* reflection.
|
||||
*
|
||||
* @author Konloch
|
||||
*
|
||||
* TODO:
|
||||
* figure out a way to block runtime.exec without java agents, maybe by replacing the method call?
|
||||
* TODO: figure out a way to block runtime.exec without java agents,
|
||||
* maybe by replacing the method call?
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -36,37 +37,30 @@ public class EZInjection extends Plugin {
|
|||
|
||||
public static ArrayList<BytecodeHook> hookArray = new ArrayList<BytecodeHook>();
|
||||
private static String version = "1.0";
|
||||
private static PluginConsole gui = new PluginConsole("EZ Injection v"+version);
|
||||
private boolean
|
||||
accessModifiers,
|
||||
injectHooks,
|
||||
invokeMethod,
|
||||
useProxy,
|
||||
launchKit,
|
||||
console;
|
||||
public static boolean
|
||||
sandboxSystem,
|
||||
sandboxRuntime,
|
||||
printCmdL;
|
||||
private static boolean
|
||||
debugHooks,
|
||||
all = false;
|
||||
private String
|
||||
invokeMethodInformation,
|
||||
proxy;
|
||||
private static PluginConsole gui = new PluginConsole("EZ Injection v"
|
||||
+ version);
|
||||
private boolean accessModifiers, injectHooks, invokeMethod, useProxy,
|
||||
launchKit, console;
|
||||
public static boolean sandboxSystem, sandboxRuntime, printCmdL;
|
||||
private static boolean debugHooks, all = false;
|
||||
private String invokeMethodInformation, proxy;
|
||||
|
||||
private static String[] debugClasses;
|
||||
|
||||
public EZInjection(boolean accessModifiers, boolean injectHooks, boolean debugHooks,
|
||||
boolean invokeMethod, String invokeMethodInformation, boolean sandboxRuntime,
|
||||
boolean sandboxSystem, String debugClasses, String proxy, boolean useProxy,
|
||||
boolean launchKit, boolean console, boolean printCmdL) {
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.createNewClassNodeLoaderInstance();
|
||||
public EZInjection(boolean accessModifiers, boolean injectHooks,
|
||||
boolean debugHooks, boolean invokeMethod,
|
||||
String invokeMethodInformation, boolean sandboxRuntime,
|
||||
boolean sandboxSystem, String debugClasses, String proxy,
|
||||
boolean useProxy, boolean launchKit, boolean console,
|
||||
boolean printCmdL) {
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer
|
||||
.createNewClassNodeLoaderInstance();
|
||||
this.accessModifiers = accessModifiers;
|
||||
this.injectHooks = injectHooks;
|
||||
EZInjection.debugHooks = debugHooks;
|
||||
this.invokeMethod = invokeMethod;
|
||||
this.invokeMethodInformation = invokeMethodInformation+"([Ljava/lang/String;)V";
|
||||
this.invokeMethodInformation = invokeMethodInformation
|
||||
+ "([Ljava/lang/String;)V";
|
||||
EZInjection.sandboxRuntime = sandboxRuntime;
|
||||
EZInjection.sandboxSystem = sandboxSystem;
|
||||
if (debugClasses.equals("*"))
|
||||
|
@ -87,6 +81,7 @@ public class EZInjection extends Plugin {
|
|||
}
|
||||
|
||||
private static String lastMessage = "";
|
||||
|
||||
public static void hook(String info) {
|
||||
for (BytecodeHook hook : hookArray)
|
||||
hook.callHook(info);
|
||||
|
@ -120,14 +115,18 @@ public class EZInjection extends Plugin {
|
|||
}
|
||||
|
||||
public static void exit(int i) {
|
||||
print("[SANDBOX] Tried to call on System.exit("+i+"), it's been blocked.");
|
||||
print("[SANDBOX] Tried to call on System.exit(" + i
|
||||
+ "), it's been blocked.");
|
||||
}
|
||||
|
||||
public static void exitR(int i) {
|
||||
print("[SANDBOX] Tried to call on Runtime.exit("+i+"), it's been blocked.");
|
||||
print("[SANDBOX] Tried to call on Runtime.exit(" + i
|
||||
+ "), it's been blocked.");
|
||||
}
|
||||
|
||||
public static void announceSystem(String s) {
|
||||
print("[SANDBOX] Tried to call on Runtime.exec("+s+"), it's been blocked.");
|
||||
print("[SANDBOX] Tried to call on Runtime.exec(" + s
|
||||
+ "), it's been blocked.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -150,7 +149,8 @@ public class EZInjection extends Plugin {
|
|||
else
|
||||
print("Hooks are disabled completely.");
|
||||
if (sandboxRuntime || sandboxSystem)
|
||||
print("Sandboxing runtime: " + sandboxRuntime+", system: " +sandboxSystem+".");
|
||||
print("Sandboxing runtime: " + sandboxRuntime + ", system: "
|
||||
+ sandboxSystem + ".");
|
||||
else
|
||||
print("WARNING: Sandboxing is disabled, this is NOT SAFE!");
|
||||
if (useProxy)
|
||||
|
@ -163,72 +163,111 @@ public class EZInjection extends Plugin {
|
|||
FieldNode f = (FieldNode) o;
|
||||
|
||||
if (accessModifiers) {
|
||||
if(f.access == Opcodes.ACC_PRIVATE || f.access == Opcodes.ACC_PROTECTED)
|
||||
if (f.access == Opcodes.ACC_PRIVATE
|
||||
|| f.access == Opcodes.ACC_PROTECTED)
|
||||
f.access = Opcodes.ACC_PUBLIC;
|
||||
|
||||
if(f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC || f.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC)
|
||||
if (f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC
|
||||
|| f.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_STATIC)
|
||||
f.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC;
|
||||
|
||||
if(f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL || f.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_FINAL)
|
||||
if (f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
|| f.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL)
|
||||
f.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL;
|
||||
|
||||
if(f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC || f.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC)
|
||||
f.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC;
|
||||
if (f.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC
|
||||
|| f.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL + Opcodes.ACC_STATIC)
|
||||
f.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC;
|
||||
}
|
||||
}
|
||||
for (Object o : classNode.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
|
||||
if (accessModifiers) {
|
||||
if(m.access == Opcodes.ACC_PRIVATE || m.access == Opcodes.ACC_PROTECTED)
|
||||
if (m.access == Opcodes.ACC_PRIVATE
|
||||
|| m.access == Opcodes.ACC_PROTECTED)
|
||||
m.access = Opcodes.ACC_PUBLIC;
|
||||
|
||||
if(m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC || m.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC)
|
||||
if (m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC
|
||||
|| m.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_STATIC)
|
||||
m.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC;
|
||||
|
||||
if(m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL || m.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_FINAL)
|
||||
if (m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
|| m.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL)
|
||||
m.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL;
|
||||
|
||||
if(m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC || m.access == Opcodes.ACC_PROTECTED + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC)
|
||||
m.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC;
|
||||
if (m.access == Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC
|
||||
|| m.access == Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL + Opcodes.ACC_STATIC)
|
||||
m.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC;
|
||||
}
|
||||
|
||||
if(injectHooks && m.access != Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PUBLIC+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PRIVATE+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PROTECTED+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_FINAL+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PUBLIC+Opcodes.ACC_FINAL+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PRIVATE+Opcodes.ACC_FINAL+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PROTECTED+Opcodes.ACC_FINAL+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PUBLIC+Opcodes.ACC_FINAL+Opcodes.ACC_STATIC+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PRIVATE+Opcodes.ACC_FINAL+Opcodes.ACC_STATIC+Opcodes.ACC_ABSTRACT &&
|
||||
m.access != Opcodes.ACC_PROTECTED+Opcodes.ACC_FINAL+Opcodes.ACC_STATIC+Opcodes.ACC_ABSTRACT)
|
||||
{
|
||||
if (injectHooks
|
||||
&& m.access != Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PUBLIC
|
||||
+ Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PRIVATE
|
||||
+ Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_FINAL + Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL + Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC + Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL
|
||||
+ Opcodes.ACC_STATIC + Opcodes.ACC_ABSTRACT
|
||||
&& m.access != Opcodes.ACC_PROTECTED
|
||||
+ Opcodes.ACC_FINAL + Opcodes.ACC_STATIC
|
||||
+ Opcodes.ACC_ABSTRACT) {
|
||||
boolean inject = true;
|
||||
if(m.instructions.size() >= 2 && m.instructions.get(1) instanceof MethodInsnNode) {
|
||||
MethodInsnNode mn = (MethodInsnNode)m.instructions.get(1);
|
||||
if(mn.owner.equals("the/bytecode/club/bytecodeviewer/plugins/EZInjection")) //already been injected
|
||||
if (m.instructions.size() >= 2
|
||||
&& m.instructions.get(1) instanceof MethodInsnNode) {
|
||||
MethodInsnNode mn = (MethodInsnNode) m.instructions
|
||||
.get(1);
|
||||
if (mn.owner
|
||||
.equals("the/bytecode/club/bytecodeviewer/plugins/EZInjection")) // already
|
||||
// been
|
||||
// injected
|
||||
inject = false;
|
||||
}
|
||||
if (inject) {
|
||||
// make this function grab parameters eventually
|
||||
m.instructions.insert(new MethodInsnNode(Opcodes.INVOKESTATIC,
|
||||
m.instructions
|
||||
.insert(new MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"the/bytecode/club/bytecodeviewer/plugins/EZInjection",
|
||||
"hook",
|
||||
"(Ljava/lang/String;)V"));
|
||||
m.instructions.insert(new LdcInsnNode(classNode.name+"."+m.name+m.desc));
|
||||
"hook", "(Ljava/lang/String;)V"));
|
||||
m.instructions.insert(new LdcInsnNode(classNode.name
|
||||
+ "." + m.name + m.desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sandboxRuntime) {
|
||||
ASMUtil_OLD.renameClassNode("java/lang/Runtime", "the/bytecode/club/bytecodeviewer/RuntimeOverride");
|
||||
ASMUtil_OLD.renameClassNode("java/lang/Runtime",
|
||||
"the/bytecode/club/bytecodeviewer/RuntimeOverride");
|
||||
}
|
||||
|
||||
if (sandboxSystem) {
|
||||
ASMUtil_OLD.renameMethodNode("java/lang/System", "exit", "(Ljava/lang/String;)V", "the/bytecode/club/bytecodeviewer/plugins/EZInjection", null, null);
|
||||
ASMUtil_OLD.renameMethodNode("java/lang/System", "exit",
|
||||
"(Ljava/lang/String;)V",
|
||||
"the/bytecode/club/bytecodeviewer/plugins/EZInjection",
|
||||
null, null);
|
||||
}
|
||||
|
||||
if (useProxy) {
|
||||
|
@ -245,22 +284,31 @@ public class EZInjection extends Plugin {
|
|||
setFinished();
|
||||
|
||||
if (invokeMethod) {
|
||||
for(ClassNode cn : BytecodeViewer.getLoadedClasses()) //load all the classnodes into the classloader
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().addClass(cn);
|
||||
for (ClassNode cn : BytecodeViewer.getLoadedClasses())
|
||||
// load all the classnodes into the classloader
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer
|
||||
.getClassNodeLoader().addClass(cn);
|
||||
|
||||
print("Invoking " + invokeMethodInformation+":"+BytecodeViewer.nl+BytecodeViewer.nl);
|
||||
print("Invoking " + invokeMethodInformation + ":"
|
||||
+ BytecodeViewer.nl + BytecodeViewer.nl);
|
||||
|
||||
for (ClassNode classNode : classNodeList) {
|
||||
for (Object o : classNode.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
String methodInformation = classNode.name+"."+m.name+m.desc;
|
||||
String methodInformation = classNode.name + "." + m.name
|
||||
+ m.desc;
|
||||
if (invokeMethodInformation.equals(methodInformation)) {
|
||||
for(Method m2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().nodeToClass(classNode).getMethods()) {
|
||||
for (Method m2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer
|
||||
.getClassNodeLoader().nodeToClass(classNode)
|
||||
.getMethods()) {
|
||||
if (m2.getName().equals(m.name)) {
|
||||
try {
|
||||
m2.invoke(classNode.getClass().newInstance(), (Object[])new String[1]);
|
||||
m2.invoke(classNode.getClass()
|
||||
.newInstance(),
|
||||
(Object[]) new String[1]);
|
||||
if (launchKit)
|
||||
new GraphicialReflectionKit().setVisible(true);
|
||||
new GraphicialReflectionKit()
|
||||
.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
|
|
|
@ -15,8 +15,8 @@ import the.bytecode.club.bytecodeviewer.api.Plugin;
|
|||
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
||||
|
||||
/**
|
||||
* The idea/core was based off of J-RET's Malicious Code Searcher
|
||||
* I improved it, and added more stuff to search for.
|
||||
* The idea/core was based off of J-RET's Malicious Code Searcher I improved it,
|
||||
* and added more stuff to search for.
|
||||
*
|
||||
* @author Konloch
|
||||
* @author WaterWolf
|
||||
|
@ -25,18 +25,10 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
|||
|
||||
public class MaliciousCodeScanner extends Plugin {
|
||||
|
||||
public boolean
|
||||
ORE,
|
||||
ONE,
|
||||
ORU,
|
||||
OIO,
|
||||
LWW,
|
||||
LHT,
|
||||
LHS,
|
||||
LIP;
|
||||
public boolean ORE, ONE, ORU, OIO, LWW, LHT, LHS, LIP;
|
||||
|
||||
public MaliciousCodeScanner(boolean reflect, boolean runtime, boolean net, boolean io,
|
||||
boolean www, boolean http, boolean https, boolean ip) {
|
||||
public MaliciousCodeScanner(boolean reflect, boolean runtime, boolean net,
|
||||
boolean io, boolean www, boolean http, boolean https, boolean ip) {
|
||||
ORE = reflect;
|
||||
ONE = net;
|
||||
ORU = runtime;
|
||||
|
@ -57,24 +49,30 @@ public class MaliciousCodeScanner extends Plugin {
|
|||
Object v = f.value;
|
||||
if (v instanceof String) {
|
||||
String s = (String) v;
|
||||
if ((LWW && s.contains("www.")) ||
|
||||
(LHT && s.contains("http://")) ||
|
||||
(LHS && s.contains("https://")) ||
|
||||
(ORE && s.contains("java/lang/Runtime")) ||
|
||||
(ORE && s.contains("java.lang.Runtime")) ||
|
||||
(LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b")))
|
||||
sb.append("Found LDC \"" + s + "\" at field " + classNode.name + "." +f.name+"("+f.desc+")"+BytecodeViewer.nl);
|
||||
if ((LWW && s.contains("www."))
|
||||
|| (LHT && s.contains("http://"))
|
||||
|| (LHS && s.contains("https://"))
|
||||
|| (ORE && s.contains("java/lang/Runtime"))
|
||||
|| (ORE && s.contains("java.lang.Runtime"))
|
||||
|| (LIP && s
|
||||
.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b")))
|
||||
sb.append("Found LDC \"" + s + "\" at field "
|
||||
+ classNode.name + "." + f.name + "(" + f.desc
|
||||
+ ")" + BytecodeViewer.nl);
|
||||
}
|
||||
if (v instanceof String[]) {
|
||||
for (int i = 0; i < ((String[]) v).length; i++) {
|
||||
String s = ((String[]) v)[i];
|
||||
if ((LWW && s.contains("www.")) ||
|
||||
(LHT && s.contains("http://")) ||
|
||||
(LHS && s.contains("https://")) ||
|
||||
(ORE && s.contains("java/lang/Runtime")) ||
|
||||
(ORE && s.contains("java.lang.Runtime")) ||
|
||||
(LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b")))
|
||||
sb.append("Found LDC \"" + s + "\" at field " + classNode.name + "." +f.name+"("+f.desc+")"+BytecodeViewer.nl);
|
||||
if ((LWW && s.contains("www."))
|
||||
|| (LHT && s.contains("http://"))
|
||||
|| (LHS && s.contains("https://"))
|
||||
|| (ORE && s.contains("java/lang/Runtime"))
|
||||
|| (ORE && s.contains("java.lang.Runtime"))
|
||||
|| (LIP && s
|
||||
.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b")))
|
||||
sb.append("Found LDC \"" + s + "\" at field "
|
||||
+ classNode.name + "." + f.name + "("
|
||||
+ f.desc + ")" + BytecodeViewer.nl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,25 +84,30 @@ public class MaliciousCodeScanner extends Plugin {
|
|||
for (AbstractInsnNode a : iList.toArray()) {
|
||||
if (a instanceof MethodInsnNode) {
|
||||
final MethodInsnNode min = (MethodInsnNode) a;
|
||||
if ((ORE && min.owner.startsWith("java/lang/reflect")) ||
|
||||
(ONE && min.owner.startsWith("java/net")) ||
|
||||
(ORU && min.owner.equals("java/lang/Runtime")) ||
|
||||
(OIO && min.owner.startsWith("java/io")))
|
||||
{
|
||||
sb.append("Found Method call to " + min.owner + "." + min.name + "(" + min.desc + ") at " + classNode.name + "." +m.name+"("+m.desc+")"+BytecodeViewer.nl);
|
||||
if ((ORE && min.owner.startsWith("java/lang/reflect"))
|
||||
|| (ONE && min.owner.startsWith("java/net"))
|
||||
|| (ORU && min.owner
|
||||
.equals("java/lang/Runtime"))
|
||||
|| (OIO && min.owner.startsWith("java/io"))) {
|
||||
sb.append("Found Method call to " + min.owner + "."
|
||||
+ min.name + "(" + min.desc + ") at "
|
||||
+ classNode.name + "." + m.name + "("
|
||||
+ m.desc + ")" + BytecodeViewer.nl);
|
||||
}
|
||||
}
|
||||
if (a instanceof LdcInsnNode) {
|
||||
if (((LdcInsnNode) a).cst instanceof String) {
|
||||
final String s = (String) ((LdcInsnNode) a).cst;
|
||||
if ((LWW && s.contains("www.")) ||
|
||||
(LHT && s.contains("http://")) ||
|
||||
(LHS && s.contains("https://")) ||
|
||||
(ORE && s.contains("java/lang/Runtime")) ||
|
||||
(ORE && s.contains("java.lang.Runtime")) ||
|
||||
(LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b")))
|
||||
{
|
||||
sb.append("Found LDC \"" + s + "\" at method " + classNode.name + "." +m.name+"("+m.desc+")"+BytecodeViewer.nl);
|
||||
if ((LWW && s.contains("www."))
|
||||
|| (LHT && s.contains("http://"))
|
||||
|| (LHS && s.contains("https://"))
|
||||
|| (ORE && s.contains("java/lang/Runtime"))
|
||||
|| (ORE && s.contains("java.lang.Runtime"))
|
||||
|| (LIP && s
|
||||
.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) {
|
||||
sb.append("Found LDC \"" + s + "\" at method "
|
||||
+ classNode.name + "." + m.name + "("
|
||||
+ m.desc + ")" + BytecodeViewer.nl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ public class PluginManager {
|
|||
pluginInstance = newPluginInstance;
|
||||
pluginInstance.start(); // start the thread
|
||||
} else if (!pluginInstance.isFinished()) {
|
||||
BytecodeViewer.showMessage("There is currently another plugin running right now, please wait for that to finish executing.");
|
||||
BytecodeViewer
|
||||
.showMessage("There is currently another plugin running right now, please wait for that to finish executing.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +51,7 @@ public class PluginManager {
|
|||
|
||||
/**
|
||||
* Loads a groovy file as a Script
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
@ -59,16 +61,20 @@ public class PluginManager {
|
|||
ScriptEngine engine = manager.getEngineByName("groovy");
|
||||
|
||||
if (engine == null)
|
||||
throw new Exception("Cannot find Groovy script engine! Please contact Konloch.");
|
||||
throw new Exception(
|
||||
"Cannot find Groovy script engine! Please contact Konloch.");
|
||||
|
||||
Reader reader = new FileReader(file);
|
||||
engine.eval(reader);
|
||||
|
||||
return (Plugin)engine.eval("new " + file.getName().replace(".gy", "").replace(".groovy", "") + "();");
|
||||
return (Plugin) engine.eval("new "
|
||||
+ file.getName().replace(".gy", "").replace(".groovy", "")
|
||||
+ "();");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a python file as a Script
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
@ -78,16 +84,20 @@ public class PluginManager {
|
|||
ScriptEngine engine = manager.getEngineByName("python");
|
||||
|
||||
if (engine == null)
|
||||
throw new Exception("Cannot find Jython script engine! Please contact Konloch.");
|
||||
throw new Exception(
|
||||
"Cannot find Jython script engine! Please contact Konloch.");
|
||||
|
||||
Reader reader = new FileReader(file);
|
||||
engine.eval(reader);
|
||||
|
||||
return (Plugin)engine.eval(file.getName().replace(".py", "").replace(".python", "") + "()");
|
||||
return (Plugin) engine.eval(file.getName().replace(".py", "")
|
||||
.replace(".python", "")
|
||||
+ "()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a ruby file as a Script
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
@ -97,11 +107,14 @@ public class PluginManager {
|
|||
ScriptEngine engine = manager.getEngineByName("jruby");
|
||||
|
||||
if (engine == null)
|
||||
throw new Exception("Cannot find jRuby script engine! Please contact Konloch.");
|
||||
throw new Exception(
|
||||
"Cannot find jRuby script engine! Please contact Konloch.");
|
||||
|
||||
Reader reader = new FileReader(file);
|
||||
engine.eval(reader);
|
||||
|
||||
return (Plugin)engine.eval(file.getName().replace(".rb", "").replace(".ruby", "") + ".new");
|
||||
return (Plugin) engine.eval(file.getName().replace(".rb", "")
|
||||
.replace(".ruby", "")
|
||||
+ ".new");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ public class ReplaceStrings extends Plugin {
|
|||
String className;
|
||||
boolean contains;
|
||||
|
||||
public ReplaceStrings(String originalLDC, String newLDC, String className, boolean contains) {
|
||||
public ReplaceStrings(String originalLDC, String newLDC, String className,
|
||||
boolean contains) {
|
||||
this.originalLDC = originalLDC;
|
||||
this.newLDC = newLDC;
|
||||
this.className = className;
|
||||
|
@ -49,7 +50,6 @@ public class ReplaceStrings extends Plugin {
|
|||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
public void scanClassNode(ClassNode classNode) {
|
||||
for (Object o : classNode.fields.toArray()) {
|
||||
FieldNode f = (FieldNode) o;
|
||||
|
@ -58,7 +58,8 @@ public class ReplaceStrings extends Plugin {
|
|||
String s = (String) v;
|
||||
if (contains) {
|
||||
if (s.contains(originalLDC))
|
||||
f.value = ((String)f.value).replaceAll(originalLDC, newLDC);
|
||||
f.value = ((String) f.value).replaceAll(originalLDC,
|
||||
newLDC);
|
||||
} else {
|
||||
if (s.equals(originalLDC))
|
||||
f.value = newLDC;
|
||||
|
@ -69,15 +70,23 @@ public class ReplaceStrings extends Plugin {
|
|||
String s = ((String[]) v)[i];
|
||||
if (contains) {
|
||||
if (s.contains(originalLDC)) {
|
||||
f.value = ((String[])f.value)[i].replaceAll(originalLDC, newLDC);
|
||||
String ugh = s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." +f.name+""+f.desc+" -> \"" + ugh + "\" replaced with \"" + s.replaceAll(originalLDC, newLDC) + "\"");
|
||||
f.value = ((String[]) f.value)[i].replaceAll(
|
||||
originalLDC, newLDC);
|
||||
String ugh = s.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." + f.name + ""
|
||||
+ f.desc + " -> \"" + ugh
|
||||
+ "\" replaced with \""
|
||||
+ s.replaceAll(originalLDC, newLDC) + "\"");
|
||||
}
|
||||
} else {
|
||||
if (s.equals(originalLDC)) {
|
||||
((String[]) f.value)[i] = newLDC;
|
||||
String ugh = s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." +f.name+""+f.desc+" -> \"" + ugh + "\" replaced with \"" + newLDC + "\"");
|
||||
String ugh = s.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." + f.name + ""
|
||||
+ f.desc + " -> \"" + ugh
|
||||
+ "\" replaced with \"" + newLDC + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,15 +103,39 @@ public class ReplaceStrings extends Plugin {
|
|||
final String s = (String) ((LdcInsnNode) a).cst;
|
||||
if (contains) {
|
||||
if (s.contains(originalLDC)) {
|
||||
((LdcInsnNode)a).cst = ((String)((LdcInsnNode)a).cst).replaceAll(originalLDC, newLDC);
|
||||
String ugh = s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." +m.name+""+m.desc+" -> \"" + ugh + "\" replaced with \"" + s.replaceAll(originalLDC, newLDC).replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r") + "\"");
|
||||
((LdcInsnNode) a).cst = ((String) ((LdcInsnNode) a).cst)
|
||||
.replaceAll(originalLDC, newLDC);
|
||||
String ugh = s.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name
|
||||
+ "."
|
||||
+ m.name
|
||||
+ ""
|
||||
+ m.desc
|
||||
+ " -> \""
|
||||
+ ugh
|
||||
+ "\" replaced with \""
|
||||
+ s.replaceAll(originalLDC, newLDC)
|
||||
.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r")
|
||||
+ "\"");
|
||||
}
|
||||
} else {
|
||||
if (s.equals(originalLDC)) {
|
||||
((LdcInsnNode) a).cst = newLDC;
|
||||
String ugh = s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name + "." +m.name+""+m.desc+" -> \"" + ugh + "\" replaced with \"" + newLDC.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r") + "\"");
|
||||
String ugh = s.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r");
|
||||
frame.appendText(classNode.name
|
||||
+ "."
|
||||
+ m.name
|
||||
+ ""
|
||||
+ m.desc
|
||||
+ " -> \""
|
||||
+ ugh
|
||||
+ "\" replaced with \""
|
||||
+ newLDC.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r")
|
||||
+ "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,31 @@ public class ShowAllStrings extends Plugin {
|
|||
if (v instanceof String) {
|
||||
String s = (String) v;
|
||||
if (!s.isEmpty())
|
||||
sb.append(classNode.name + "." +f.name+""+f.desc+" -> \"" + s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r") + "\""+BytecodeViewer.nl);
|
||||
sb.append(classNode.name
|
||||
+ "."
|
||||
+ f.name
|
||||
+ ""
|
||||
+ f.desc
|
||||
+ " -> \""
|
||||
+ s.replaceAll("\\n", "\\\\n").replaceAll(
|
||||
"\\r", "\\\\r") + "\""
|
||||
+ BytecodeViewer.nl);
|
||||
}
|
||||
if (v instanceof String[]) {
|
||||
for (int i = 0; i < ((String[]) v).length; i++) {
|
||||
String s = ((String[]) v)[i];
|
||||
if (!s.isEmpty())
|
||||
sb.append(classNode.name + "." +f.name+""+f.desc+"["+i+"] -> \"" + s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r") + "\""+BytecodeViewer.nl);
|
||||
sb.append(classNode.name
|
||||
+ "."
|
||||
+ f.name
|
||||
+ ""
|
||||
+ f.desc
|
||||
+ "["
|
||||
+ i
|
||||
+ "] -> \""
|
||||
+ s.replaceAll("\\n", "\\\\n").replaceAll(
|
||||
"\\r", "\\\\r") + "\""
|
||||
+ BytecodeViewer.nl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +71,15 @@ public class ShowAllStrings extends Plugin {
|
|||
if (((LdcInsnNode) a).cst instanceof String) {
|
||||
final String s = (String) ((LdcInsnNode) a).cst;
|
||||
if (!s.isEmpty())
|
||||
sb.append(classNode.name + "." +m.name+""+m.desc+" -> \"" + s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r") + "\""+BytecodeViewer.nl);
|
||||
sb.append(classNode.name
|
||||
+ "."
|
||||
+ m.name
|
||||
+ ""
|
||||
+ m.desc
|
||||
+ " -> \""
|
||||
+ s.replaceAll("\\n", "\\\\n")
|
||||
.replaceAll("\\r", "\\\\r")
|
||||
+ "\"" + BytecodeViewer.nl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@ public class ShowMainMethods extends Plugin {
|
|||
for (Object o : classNode.methods.toArray()) {
|
||||
MethodNode m = (MethodNode) o;
|
||||
|
||||
if(m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V"))
|
||||
frame.appendText(classNode.name + "." +m.name+""+m.desc);
|
||||
if (m.name.equals("main")
|
||||
&& m.desc.equals("([Ljava/lang/String;)V"))
|
||||
frame.appendText(classNode.name + "." + m.name + ""
|
||||
+ m.desc);
|
||||
}
|
||||
}
|
||||
frame.setVisible(true);
|
||||
|
|
|
@ -27,7 +27,8 @@ import eu.bibl.banalysis.asm.desc.OpcodeInfo;
|
|||
|
||||
public class FieldCallSearch implements SearchTypeDetails {
|
||||
|
||||
JTextField mOwner = new JTextField(""), mName = new JTextField(""), mDesc = new JTextField("");
|
||||
JTextField mOwner = new JTextField(""), mName = new JTextField(""),
|
||||
mDesc = new JTextField("");
|
||||
JPanel myPanel = null;
|
||||
|
||||
@Override
|
||||
|
@ -44,8 +45,10 @@ public class FieldCallSearch implements SearchTypeDetails {
|
|||
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) {
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn,
|
||||
boolean exact) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||
String owner = mOwner.getText();
|
||||
|
@ -65,7 +68,8 @@ public class FieldCallSearch implements SearchTypeDetails {
|
|||
|
||||
final InsnList insnlist = method.instructions;
|
||||
@SuppressWarnings("unchecked")
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist.iterator();
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist
|
||||
.iterator();
|
||||
while (instructions.hasNext()) {
|
||||
final AbstractInsnNode insnNode = instructions.next();
|
||||
if (insnNode instanceof FieldInsnNode) {
|
||||
|
@ -82,7 +86,13 @@ public class FieldCallSearch implements SearchTypeDetails {
|
|||
if (desc != null && !desc.equals(min.desc)) {
|
||||
continue;
|
||||
}
|
||||
srn.notifyOfResult(node.name + "." + method.name + Type.getType(method.desc) + " > " + OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase());
|
||||
srn.notifyOfResult(node.name
|
||||
+ "."
|
||||
+ method.name
|
||||
+ Type.getType(method.desc)
|
||||
+ " > "
|
||||
+ OpcodeInfo.OPCODES.get(insnNode.getOpcode())
|
||||
.toLowerCase());
|
||||
} else {
|
||||
|
||||
if (name != null && !name.contains(min.name)) {
|
||||
|
@ -94,7 +104,13 @@ public class FieldCallSearch implements SearchTypeDetails {
|
|||
if (desc != null && !desc.contains(min.desc)) {
|
||||
continue;
|
||||
}
|
||||
srn.notifyOfResult(node.name + "." + method.name + Type.getType(method.desc) + " > " + OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase());
|
||||
srn.notifyOfResult(node.name
|
||||
+ "."
|
||||
+ method.name
|
||||
+ Type.getType(method.desc)
|
||||
+ " > "
|
||||
+ OpcodeInfo.OPCODES.get(insnNode.getOpcode())
|
||||
.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,11 @@ public class LDCSearch implements SearchTypeDetails {
|
|||
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) {
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn,
|
||||
boolean exact) {
|
||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||
final String srchText = searchText.getText();
|
||||
if (srchText.isEmpty())
|
||||
|
@ -51,16 +53,19 @@ public class LDCSearch implements SearchTypeDetails {
|
|||
final MethodNode method = methods.next();
|
||||
|
||||
final InsnList insnlist = method.instructions;
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist.iterator();
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist
|
||||
.iterator();
|
||||
while (instructions.hasNext()) {
|
||||
final AbstractInsnNode insnNode = instructions.next();
|
||||
if (insnNode instanceof LdcInsnNode) {
|
||||
final LdcInsnNode ldcObject = ((LdcInsnNode) insnNode);
|
||||
final String ldcString = ldcObject.cst.toString();
|
||||
if ((exact && ldcString.equals(srchText)) ||
|
||||
(!exact && ldcString.contains(srchText)))
|
||||
{
|
||||
srn.notifyOfResult(node.name + "." + method.name + Type.getType(method.desc).getInternalName() + " -> \""+ldcString + "\" > " + ldcObject.cst.getClass().getCanonicalName());
|
||||
if ((exact && ldcString.equals(srchText))
|
||||
|| (!exact && ldcString.contains(srchText))) {
|
||||
srn.notifyOfResult(node.name + "." + method.name
|
||||
+ Type.getType(method.desc).getInternalName()
|
||||
+ " -> \"" + ldcString + "\" > "
|
||||
+ ldcObject.cst.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +75,8 @@ public class LDCSearch implements SearchTypeDetails {
|
|||
while (methods.hasNext()) {
|
||||
final FieldNode field = fields.next();
|
||||
if (field.value instanceof String) {
|
||||
srn.notifyOfResult(node.name + "." + field.name + field.desc + " -> \"" + field.value + "\" > field");
|
||||
srn.notifyOfResult(node.name + "." + field.name + field.desc
|
||||
+ " -> \"" + field.value + "\" > field");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ import eu.bibl.banalysis.asm.desc.OpcodeInfo;
|
|||
|
||||
public class MethodCallSearch implements SearchTypeDetails {
|
||||
|
||||
JTextField mOwner = new JTextField(""), mName = new JTextField(""), mDesc = new JTextField("");
|
||||
JTextField mOwner = new JTextField(""), mName = new JTextField(""),
|
||||
mDesc = new JTextField("");
|
||||
JPanel myPanel = null;
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +48,8 @@ public class MethodCallSearch implements SearchTypeDetails {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) {
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn,
|
||||
boolean exact) {
|
||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||
String owner = mOwner.getText();
|
||||
if (owner.isEmpty()) {
|
||||
|
@ -66,7 +68,8 @@ public class MethodCallSearch implements SearchTypeDetails {
|
|||
final MethodNode method = methods.next();
|
||||
|
||||
final InsnList insnlist = method.instructions;
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist.iterator();
|
||||
final ListIterator<AbstractInsnNode> instructions = insnlist
|
||||
.iterator();
|
||||
while (instructions.hasNext()) {
|
||||
final AbstractInsnNode insnNode = instructions.next();
|
||||
if (insnNode instanceof MethodInsnNode) {
|
||||
|
@ -83,7 +86,13 @@ public class MethodCallSearch implements SearchTypeDetails {
|
|||
if (desc != null && !desc.equals(min.desc)) {
|
||||
continue;
|
||||
}
|
||||
srn.notifyOfResult(node.name + "." + method.name + Type.getType(method.desc) + " > " + OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase());
|
||||
srn.notifyOfResult(node.name
|
||||
+ "."
|
||||
+ method.name
|
||||
+ Type.getType(method.desc)
|
||||
+ " > "
|
||||
+ OpcodeInfo.OPCODES.get(insnNode.getOpcode())
|
||||
.toLowerCase());
|
||||
} else {
|
||||
if (name != null && !name.contains(min.name)) {
|
||||
continue;
|
||||
|
@ -94,7 +103,13 @@ public class MethodCallSearch implements SearchTypeDetails {
|
|||
if (desc != null && !desc.contains(min.desc)) {
|
||||
continue;
|
||||
}
|
||||
srn.notifyOfResult(node.name + "." + method.name + Type.getType(method.desc) + " > " + OpcodeInfo.OPCODES.get(insnNode.getOpcode()).toLowerCase());
|
||||
srn.notifyOfResult(node.name
|
||||
+ "."
|
||||
+ method.name
|
||||
+ Type.getType(method.desc)
|
||||
+ " > "
|
||||
+ OpcodeInfo.OPCODES.get(insnNode.getOpcode())
|
||||
.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,12 +118,15 @@ public class RegexInsnFinder {
|
|||
"INVOKEDYNAMIC", "NEW", "NEWARRAY", "ANEWARRAY", "ARRAYLENGTH",
|
||||
"ATHROW", "CHECKCAST", "INSTANCEOF", "MONITORENTER", "MONITOREXIT",
|
||||
"MULTIANEWARRAY", "IFNULL", "IFNONNULL" };
|
||||
private static String opcodesAnys = buildRegexItems(opcodesAny, false, false);
|
||||
private static String opcodesAnys = buildRegexItems(opcodesAny, false,
|
||||
false);
|
||||
|
||||
private static String buildRegexItems(final String[] items, final boolean capture, final boolean stdRepl) {
|
||||
private static String buildRegexItems(final String[] items,
|
||||
final boolean capture, final boolean stdRepl) {
|
||||
if (items.length == 0)
|
||||
return "()";
|
||||
String result = (stdRepl ? "\\b" : "") + "(" + (capture ? "" : "?:") + items[0];
|
||||
String result = (stdRepl ? "\\b" : "") + "(" + (capture ? "" : "?:")
|
||||
+ items[0];
|
||||
for (int i = 1; i < items.length; i++) {
|
||||
result += "|" + items[i];
|
||||
}
|
||||
|
@ -138,21 +141,24 @@ public class RegexInsnFinder {
|
|||
private static String processRegex(final String regex) {
|
||||
String result = regex.trim();
|
||||
result = result.replaceAll("\\bANYINSN *", opcodesAnys);
|
||||
result = result.replaceAll(opcodesInts + "\\\\\\{\\s*(\\d+)\\s*\\\\\\} *",
|
||||
"$1\\\\{$2\\\\} ");
|
||||
result = result.replaceAll(opcodesInts
|
||||
+ "\\\\\\{\\s*(\\d+)\\s*\\\\\\} *", "$1\\\\{$2\\\\} ");
|
||||
result = result.replaceAll(opcodesInts + " *", "$1\\\\{\\\\d+\\\\} ");
|
||||
result = result.replaceAll("\\bLDC\\\\\\{(.*?)\\\\\\}(?<!\\\\\\\\\\}) *",
|
||||
result = result.replaceAll(
|
||||
"\\bLDC\\\\\\{(.*?)\\\\\\}(?<!\\\\\\\\\\}) *",
|
||||
"LDC\\\\{$1\\\\}(?<!\\\\\\\\\\\\}) ");
|
||||
result = result.replaceAll("\\bLDC *", "LDC\\\\{.*?\\\\}(?<!\\\\\\\\\\\\}) ");
|
||||
result = result.replaceAll("\\bLDC *",
|
||||
"LDC\\\\{.*?\\\\}(?<!\\\\\\\\\\\\}) ");
|
||||
result = result.replaceAll(opcodeVars + "(_\\d+) *", "$1$2 ");
|
||||
result = result.replaceAll(opcodeVars + "(?!_) *", "$1_\\\\d+ ");
|
||||
result = result.replaceAll("\\bIINC\\\\\\{\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\\\\\} *",
|
||||
result = result.replaceAll(
|
||||
"\\bIINC\\\\\\{\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\\\\\} *",
|
||||
"IINC\\\\{$1,$2\\\\} ");
|
||||
result = result.replaceAll("\\bIINC\\\\\\{\\s*(\\d+)\\s*\\\\\\} *",
|
||||
"IINC\\\\{\\d+,$1\\\\} ");
|
||||
result = result.replaceAll("\\bIINC *", "IINC\\\\{\\d+,\\d+\\\\} ");
|
||||
result = result.replaceAll(opcodesFields +
|
||||
"\\\\\\{\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*\\\\\\} *",
|
||||
result = result.replaceAll(opcodesFields
|
||||
+ "\\\\\\{\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*\\\\\\} *",
|
||||
"$1\\\\{$2,$3,$4\\\\} ");
|
||||
result = result.replaceAll(opcodesFields
|
||||
+ "\\\\\\{((?:.(?!,))*)\\\\\\} *", "$1\\\\{$2,.*?,.*?\\\\} ");
|
||||
|
@ -164,14 +170,18 @@ public class RegexInsnFinder {
|
|||
+ "\\\\\\{((?:.(?!,))*)\\\\\\} *", "$1\\\\{$2,.*?,.*?\\\\} ");
|
||||
result = result.replaceAll(opcodesMethods + " *",
|
||||
"$1\\\\{.*?,.*?,.*?\\\\} ");
|
||||
result = result.replaceAll(opcodesTypes + "\\\\\\{\\s*(.*?)\\s*\\\\\\} +",
|
||||
"$1\\\\{$2\\\\} ");
|
||||
result = result.replaceAll(opcodesTypes
|
||||
+ "\\\\\\{\\s*(.*?)\\s*\\\\\\} +", "$1\\\\{$2\\\\} ");
|
||||
result = result.replaceAll(opcodesTypes + " +", "$1\\\\{\\\\.*?\\\\} ");
|
||||
result = result.replaceAll("\\bMULTIANEWARRAY\\\\\\{\\s*(\\d+)\\s*,\\s*(.*?)\\s*\\\\\\} *",
|
||||
result = result
|
||||
.replaceAll(
|
||||
"\\bMULTIANEWARRAY\\\\\\{\\s*(\\d+)\\s*,\\s*(.*?)\\s*\\\\\\} *",
|
||||
"MULTIANEWARRAY\\\\{$1,$2\\\\} ");
|
||||
result = result.replaceAll("\\bMULTIANEWARRAY\\\\\\{\\s*(.*?)\\s*\\\\\\} *",
|
||||
result = result.replaceAll(
|
||||
"\\bMULTIANEWARRAY\\\\\\{\\s*(.*?)\\s*\\\\\\} *",
|
||||
"MULTIANEWARRAY\\\\{\\d+,$1\\\\} ");
|
||||
result = result.replaceAll("\\bMULTIANEWARRAY *", "MULTIANEWARRAY\\\\{\\\\\\d+,.*?\\\\} ");
|
||||
result = result.replaceAll("\\bMULTIANEWARRAY *",
|
||||
"MULTIANEWARRAY\\\\{\\\\\\d+,.*?\\\\} ");
|
||||
result = result.replaceAll("\\bIFINSN *", opcodesIfs + " ");
|
||||
return result;
|
||||
}
|
||||
|
@ -201,7 +211,8 @@ public class RegexInsnFinder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Refreshes the internal instruction list when you have made changes to the method.
|
||||
* Refreshes the internal instruction list when you have made changes to the
|
||||
* method.
|
||||
*/
|
||||
public void refresh() {
|
||||
origInstructions = cleanInsn(mn.instructions);
|
||||
|
@ -299,7 +310,9 @@ public class RegexInsnFinder {
|
|||
|
||||
/**
|
||||
* Searches for a regex in the instruction list and returns the first match.
|
||||
* @param regex the regular expression
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression
|
||||
* @return the matching instructions
|
||||
*/
|
||||
public AbstractInsnNode[] find(final String regex) {
|
||||
|
@ -316,7 +329,9 @@ public class RegexInsnFinder {
|
|||
|
||||
/**
|
||||
* Searches a regex in an instruction list and returns all matches.
|
||||
* @param regex the regular expression
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression
|
||||
* @return a list with all sets of matching instructions
|
||||
*/
|
||||
public List<AbstractInsnNode[]> findAll(final String regex) {
|
||||
|
@ -334,8 +349,11 @@ public class RegexInsnFinder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Searches for a regex in the instruction list and returns all groups for the first match.
|
||||
* @param regex the regular expression
|
||||
* Searches for a regex in the instruction list and returns all groups for
|
||||
* the first match.
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression
|
||||
* @return the groups with matching instructions
|
||||
*/
|
||||
public AbstractInsnNode[][] findGroups(final String regex) {
|
||||
|
@ -343,9 +361,11 @@ public class RegexInsnFinder {
|
|||
final Matcher regexMatcher = Pattern.compile(processRegex(regex),
|
||||
Pattern.MULTILINE).matcher(insnString);
|
||||
if (regexMatcher.find()) {
|
||||
final AbstractInsnNode[][] result = new AbstractInsnNode[regexMatcher.groupCount() + 1][0];
|
||||
final AbstractInsnNode[][] result = new AbstractInsnNode[regexMatcher
|
||||
.groupCount() + 1][0];
|
||||
for (int i = 0; i <= regexMatcher.groupCount(); i++) {
|
||||
result[i] = makeResult(regexMatcher.start(i), regexMatcher.end(i));
|
||||
result[i] = makeResult(regexMatcher.start(i),
|
||||
regexMatcher.end(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -356,8 +376,11 @@ public class RegexInsnFinder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Searches for a regex in the instruction list and returns all groups for all matches.
|
||||
* @param regex the regular expression
|
||||
* Searches for a regex in the instruction list and returns all groups for
|
||||
* all matches.
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression
|
||||
* @return a list with all sets of groups with matching instructions
|
||||
*/
|
||||
public List<AbstractInsnNode[][]> findAllGroups(final String regex) {
|
||||
|
@ -366,9 +389,11 @@ public class RegexInsnFinder {
|
|||
final Matcher regexMatcher = Pattern.compile(processRegex(regex),
|
||||
Pattern.MULTILINE).matcher(insnString);
|
||||
if (regexMatcher.find()) {
|
||||
final AbstractInsnNode[][] result = new AbstractInsnNode[regexMatcher.groupCount() + 1][0];
|
||||
final AbstractInsnNode[][] result = new AbstractInsnNode[regexMatcher
|
||||
.groupCount() + 1][0];
|
||||
for (int i = 0; i <= regexMatcher.groupCount(); i++) {
|
||||
result[i] = makeResult(regexMatcher.start(i), regexMatcher.end(i));
|
||||
result[i] = makeResult(regexMatcher.start(i),
|
||||
regexMatcher.end(i));
|
||||
}
|
||||
results.add(result);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ public class RegexSearch implements SearchTypeDetails {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn, boolean exact) {
|
||||
public void search(final ClassNode node, final SearchResultNotifier srn,
|
||||
boolean exact) {
|
||||
final Iterator<MethodNode> methods = node.methods.iterator();
|
||||
final String srchText = searchText.getText();
|
||||
if (srchText.isEmpty())
|
||||
|
@ -48,8 +49,7 @@ public class RegexSearch implements SearchTypeDetails {
|
|||
|
||||
if (regexFinder == null) {
|
||||
regexFinder = new RegexInsnFinder(node, method);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
regexFinder.setMethod(node, method);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue