Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
12/09/2014 - Added a text search function to the plugin console.
12/09/2014 - When you press enter in the text search bar, it will now
search.
12/13/2014 - The Bytecode Decompiler now shows the method's description
in a comment.
12/13/2014 - Fixed an issue with the text search function.
12/13/2014 - Search results are now clickable.
  • Loading branch information
Konloch committed Dec 13, 2014
1 parent 6b4a119 commit 0a81d69
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 35 deletions.
Binary file not shown.
8 changes: 7 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,10 @@ Changelog:
11/19/2014 - Added annotatitons/local variables to the methodnode decompiler (Thanks Bibl).
11/21/2014 - Decided to release it with the obfuscator/reflection kit unfinished, they're currently disabled for future use.
--- 2.1.1 ---:
12/09/2014 - Upated CFR to cfr_0_91.
12/09/2014 - Upated CFR to cfr_0_91.
--- 2.2.0 ---:
12/09/2014 - Added a text search function to the plugin console.
12/09/2014 - When you press enter in the text search bar, it will now search.
12/13/2014 - The Bytecode Decompiler now shows the method's description in a comment.
12/13/2014 - Fixed an issue with the text search function.
12/13/2014 - Search results are now clickable.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.2.0
3 changes: 1 addition & 2 deletions src/me/konloch/kontainer/io/DiskWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import java.io.PrintWriter;

/**
* This method will save to disk, if it failed it will keep trying until
* it's saved to disk
* This method will save to disk
*
* @author Konloch
*
Expand Down
34 changes: 19 additions & 15 deletions src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@
*
* TODO:
* The import jar method eats up a lot of memory, look into some how reducing this.
* Make the search results clickable
* Add a tool to build a flowchart of all the classes, and what methods execute what classes, and those method, read chatlog
* 2.1:
* Add obfuscation
* Add progress bars on saving all zips/java decompile jar
* Add the jump/save mark system Ida Pro has.
* Add a search function to the plugin console?
* Add integer boxing and other obfuscation methods contra thought of
* Add integer boxing and other obfuscation methods contra implemented
* Insert unadded/debug opcodes to try to fuck up decompilers
* ClassAnylyzterAdapter
*
* ----Beta 1.0-----:
* ----Beta 1.0.0-----:
* 10/4/2014 - Designed a POC GUI, still needs a lot of work.
* 10/4/2014 - Started importing J-RET's backend.
* 10/5/2014 - Finished importing J-RET's backend.
Expand Down Expand Up @@ -129,12 +127,12 @@
* 10/16/2014 - Now if you try search with an empty string, it won't search.
* 10/16/2014 - Added Replace Strings plugin.
* 10/16/2014 - Added a loading icon that displays whenever a background task is being executed.
* ----Beta 1.1-----:
* ----Beta 1.1.0-----:
* 10/19/2014 - Fixed harcoded \\.
* ----Beta 1.2-----:
* ----Beta 1.2.0-----:
* 10/19/2014 - Started importing Procyon and CFR decompilers.
* 10/19/2014 - Partially finished importing Procyon and CFR, just need to finish export java files as zip.
* ----Beta 1.3-----:
* ----Beta 1.3.0-----:
* 10/22/2014 - Imported Bibl's Bytecode Decompiler from CFIDE.
* 10/22/2014 - Did some changes to the Bytecode Decompiler.
* 10/23/2014 - Added CFR settings.
Expand All @@ -150,13 +148,13 @@
* 10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon. (This also fixes the JRE 1.8 issue)
* 10/29/2014 - Added a new decompiler option to append brackets to labels.
* 10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled.
* ----Beta 1.4-----:
* ----Beta 1.4.0-----:
* 11/1/2014 - Fixed FernFlower save Java files on Unix.
* 11/1/2014 - FernFlower now uses the settings for save Java files.
* 11/1/2014 - Added Procyon save Java files (It uses the settings).
* 11/1/2014 - Updated CFR to cfr_0_89.
* 11/1/2014 - Added CFR save Java files (It uses the settings), however it relies on the file system, because of this if there is heavy name obfuscation, it could mess up for windows.
* -----Beta 1.5-----:
* -----Beta 1.5.0-----:
* 11/1/2014 - Updated and improved the search function, it now prints out more useful information.
* 11/1/2014 - Fixed a UI issue with the Replace All Strings plugin.
* 11/2/2014 - Added search function to the Class Viewer.
Expand All @@ -171,7 +169,7 @@
* 11/3/2014 - Removed the option to disable syntax highlighting (since it's lightweight now).
* 11/3/2014 - About window now contains the version number and the BCV directory.
* 11/3/2014 - Added an option to toggle to outdated status.
* -----2.0-----:
* -----2.0.0-----:
* 11/4/2014 - Officially been 1 month of development.
* 11/4/2014 - Replaced ""+ with String.valueOf (cheers bibl).
* 11/4/2014 - Changed how the temp directory was created.
Expand All @@ -185,9 +183,9 @@
* 11/5/2014 - Improved the Malicious Code Scanner, also made it instant.
* 11/5/2014 - Added icons to the program (cheers Fluke).
* -----2.0.1-----:
* 11/7/2014 - Fixed the search function.
* 11/7/2014 - Fixed the text search function.
* 11/7/2014 - Removed an unused package containing some unused classes.
* -----2.1-----:
* -----2.1.0-----:
* 11/5/2014 - Started working on the EZ-Inject plugin.
* 11/6/2014 - Fixed the ClassNodeDecompiler creating unnessessary objects. (thanks bibl).
* 11/6/2014 - Finished an alpha version of EZ-Inject.
Expand All @@ -202,8 +200,14 @@
* 11/17/2014 - Fixed an issue with the out of date checking UI still activating when not selected.
* 11/19/2014 - Added annotatitons/local variables to the methodnode decompiler (Thanks Bibl).
* 11/21/2014 - Decided to release it with the obfuscator/reflection kit unfinished, they're currently disabled for future use.
* -----2.1-----:
* Updated CFR to cfr_0_91.
* -----2.1.1-----:
* 12/09/2014 - Updated CFR to cfr_0_91.
* -----2.2.0-----:
* 12/09/2014 - Added a text search function to the plugin console.
* 12/09/2014 - When you press enter in the text search bar, it will now search.
* 12/13/2014 - The Bytecode Decompiler now shows the method's description in a comment.
* 12/13/2014 - Fixed an issue with the text search function.
* 12/13/2014 - Search results are now clickable.
*
* @author Konloch
*
Expand All @@ -225,7 +229,7 @@ public class BytecodeViewer {
private static ArrayList<String> recentPlugins = DiskReader.loadArrayList(pluginsName, false);
public static boolean runningObfuscation = false;

public static String version = "2.1.1";
public static String version = "2.2.0";

public static void main(String[] args) {
iconList = new ArrayList<BufferedImage>();
Expand Down
181 changes: 180 additions & 1 deletion src/the/bytecode/club/bytecodeviewer/api/PluginConsole.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
package the.bytecode.club.bytecodeviewer.api;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JTextField;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JScrollPane;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JTextArea;

import the.bytecode.club.bytecodeviewer.BytecodeViewer;

import javax.swing.JPanel;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;

/**
* A simple console GUI.
*
Expand All @@ -22,18 +36,183 @@
public class PluginConsole extends JFrame {

JTextArea textArea = new JTextArea();
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);
setSize(new Dimension(542, 316));

JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);

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==")));
panel.add(buttonPane, BorderLayout.WEST);
final JTextField field = new JTextField();
panel.add(field, BorderLayout.CENTER);
panel.add(check, BorderLayout.EAST);
searchNext.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
search(field.getText(), true);
}
});
searchPrev.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
search(field.getText(), false);
}
});
field.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_ENTER)
search(field.getText(), true);
}

@Override
public void keyPressed(KeyEvent arg0) {}
@Override
public void keyTyped(KeyEvent arg0) {}
});

scrollPane.setColumnHeaderView(panel);
this.setLocationRelativeTo(null);
}


/**
* This was really interesting to write.
*
* @author Konloch
*
*/
public void search(String search, boolean next) {
try {
JTextArea area = textArea;
if(search.isEmpty()) {
highlight(area, "");
return;
}

int startLine = area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1;
int currentLine = 1;
boolean canSearch = false;
String[] test = null;
if(area.getText().split("\n").length >= 2)
test = area.getText().split("\n");
else
test = area.getText().split("\r");
int lastGoodLine = -1;
int firstPos = -1;
boolean found = false;

if(next) {
for(String s : test) {
if(!check.isSelected())
{
s = s.toLowerCase();
search = search.toLowerCase();
}

if(currentLine == startLine) {
canSearch = true;
} else if(s.contains(search)) {
if(canSearch) {
area.setCaretPosition(area.getDocument()
.getDefaultRootElement().getElement(currentLine-1)
.getStartOffset());
canSearch = false;
found = true;
}

if(firstPos == -1)
firstPos = currentLine;
}

currentLine++;
}

if(!found && firstPos != -1) {
area.setCaretPosition(area.getDocument()
.getDefaultRootElement().getElement(firstPos-1)
.getStartOffset());
}
} else {
canSearch = true;
for(String s : test) {
if(!check.isSelected())
{
s = s.toLowerCase();
search = search.toLowerCase();
}

if(s.contains(search)) {
if(lastGoodLine != -1 && canSearch)
area.setCaretPosition(area.getDocument()
.getDefaultRootElement().getElement(lastGoodLine-1)
.getStartOffset());

lastGoodLine = currentLine;

if(currentLine >= startLine)
canSearch = false;
}
currentLine++;
}

if(lastGoodLine != -1 && area.getDocument().getDefaultRootElement().getElementIndex(area.getCaretPosition())+1 == startLine) {
area.setCaretPosition(area.getDocument()
.getDefaultRootElement().getElement(lastGoodLine-1)
.getStartOffset());
}
}
highlight(area, search);
} catch(Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}

private DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,62,150));

public void highlight(JTextComponent textComp, String pattern) {
if(pattern.isEmpty()) {
textComp.getHighlighter().removeAllHighlights();
return;
}

try {
Highlighter hilite = textComp.getHighlighter();
hilite.removeAllHighlights();
javax.swing.text.Document doc = textComp.getDocument();
String text = doc.getText(0, doc.getLength());
int pos = 0;

if(!check.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
hilite.addHighlight(pos, pos + pattern.length(), painter);
pos += pattern.length();
}
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}

/**
* Appends \r\n to the end of your string, then it puts it on the top.
* @param t the string you want to append
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, MethodNo
}

if (s.contains("abstract")) {
sb.append(" {}"+BytecodeViewer.nl);
sb.append(" {}");
sb.append(" //");
sb.append(m.desc);
sb.append(BytecodeViewer.nl);
} else {

sb.append(" {");
Expand All @@ -96,6 +99,9 @@ public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, MethodNo
else if(m.name.equals("<init>"))
sb.append(" // <init>");
}

sb.append(" //");
sb.append(m.desc);

sb.append(BytecodeViewer.nl);

Expand All @@ -113,7 +119,6 @@ else if(m.name.equals("<init>"))
addAttrList(m.visibleAnnotations, "visAnno", sb, insnPrinter);
addAttrList(m.visibleLocalVariableAnnotations, "visLocalVarAnno", sb, insnPrinter);
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb, insnPrinter);


for (Object o : m.tryCatchBlocks) {
TryCatchBlockNode tcbn = (TryCatchBlockNode) o;
Expand Down

0 comments on commit 0a81d69

Please sign in to comment.