use of the.bytecode.club.bytecodeviewer.api.ExceptionUI in project bytecode-viewer by Konloch.
the class BytecodeViewer method main.
/**
* Main startup
*
* @param args files you want to open or CLI
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
new ExceptionUI(e);
}
try {
System.setSecurityManager(sm);
System.out.println("https://the.bytecode.club - Created by @Konloch and @samczsun - Bytecode Viewer " + version);
CommandLineInput input = new CommandLineInput(args);
if (previewCopy && !input.containsCommand())
showMessage("WARNING: This is a preview/dev copy, you WON'T be alerted when " + version + " is actually out if you use this." + nl + "Make sure to watch the repo: https://github.com/Konloch/bytecode-viewer for " + version + "'s release");
if (!filesFile.exists() && !filesFile.createNewFile()) {
throw new RuntimeException("Could not create recent files file");
}
if (!pluginsFile.exists() && !pluginsFile.createNewFile()) {
throw new RuntimeException("Could not create recent plugins file");
}
recentFiles.addAll(FileUtils.readLines(filesFile, "UTF-8"));
recentPlugins.addAll(FileUtils.readLines(pluginsFile, "UTF-8"));
int CLI = input.parseCommandLine();
if (CLI == CommandLineInput.STOP)
return;
if (CLI == CommandLineInput.OPEN_FILE) {
viewer = new MainViewerGUI();
Settings.loadGUI();
Boot.boot();
BytecodeViewer.BOOT(args, false);
} else {
BytecodeViewer.BOOT(args, true);
input.executeCommandLine();
}
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
use of the.bytecode.club.bytecodeviewer.api.ExceptionUI in project bytecode-viewer by Konloch.
the class CommandLineInput method executeCommandLine.
public void executeCommandLine() {
try {
File input = new File(parsed.getOptionValue("i"));
File output = new File(parsed.getOptionValue("o"));
String target = parsed.getOptionValue("t");
Decompiler use = null;
if (parsed.getOptionValue("decompiler") == null) {
System.out.println("You can define another decompiler by appending -decompiler \"name\", by default procyon has been set.");
use = Decompiler.PROCYON;
} else if ((use = Decompiler.getByName(parsed.getOptionValue("decompiler"))) == null) {
System.out.println("Decompiler not found. By default Procyon has been set.");
use = Decompiler.PROCYON;
}
System.out.println("Decompiling " + input.getAbsolutePath() + " with " + use.getName());
BytecodeViewer.openFiles(new File[] { input }, false);
String containerName = BytecodeViewer.files.get(0).name;
Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) {
use.decompileToZip(output.getAbsolutePath());
} else {
try {
ClassNode cn = BytecodeViewer.getClassNode(containerName, target);
byte[] bytes = BytecodeViewer.getClassBytes(containerName, target);
String contents = use.decompileClassNode(cn, bytes);
FileUtils.write(output, contents, "UTF-8", false);
} catch (Exception e) {
new ExceptionUI(e);
}
}
System.out.println("Finished.");
System.out.println("Bytecode Viewer CLI v" + BytecodeViewer.version + " by @Konloch - http://bytecodeviewer.com");
System.exit(0);
} catch (Exception e) {
new ExceptionUI(e);
}
}
use of the.bytecode.club.bytecodeviewer.api.ExceptionUI in project bytecode-viewer by Konloch.
the class PaneUpdaterThread method run.
public void run() {
try {
final byte[] b = BytecodeViewer.getClassBytes(viewer.container, viewer.cn.name + ".class");
if (decompiler != Decompiler.HEXCODE) {
RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
final RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(decompiler.decompileClassNode(viewer.cn, b));
panelArea.setCaretPosition(0);
panelArea.setEditable(viewer.isPaneEditable(paneId));
panelArea.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
viewer.requestFocus(paneId);
}
BytecodeViewer.checkHotKey(e);
}
@Override
public void keyReleased(KeyEvent arg0) {
}
@Override
public void keyTyped(KeyEvent arg0) {
}
});
scrollPane.setColumnHeaderView(new JLabel(decompiler.getName() + " Decompiler - Editable: " + panelArea.isEditable()));
panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
target.add(scrollPane);
}
});
viewer.updatePane(paneId, panelArea, decompiler);
} else {
final JHexEditor hex = new JHexEditor(b);
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
target.add(hex);
}
});
}
} catch (Exception e) {
new ExceptionUI(e);
} finally {
viewer.resetDivider();
BytecodeViewer.viewer.setIcon(false);
if (button != null)
button.setEnabled(true);
}
}
use of the.bytecode.club.bytecodeviewer.api.ExceptionUI in project bytecode-viewer by Konloch.
the class AllatoriStringDecrypter method execute.
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
JOptionPane pane = new JOptionPane("WARNING: This will load the classes into the JVM and execute allatori decrypter function" + BytecodeViewer.nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.");
Object[] options = new String[] { "Continue", "Cancel" };
pane.setOptions(options);
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - WARNING");
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) {
try {
if (!className.equals("*")) {
for (ClassNode classNode : classNodeList) {
if (classNode.name.equals(className))
scanClassNode(classNode);
}
} else {
for (ClassNode classNode : classNodeList) {
scanClassNode(classNode);
}
}
} catch (Exception e) {
new ExceptionUI(e, "github.com/Szperak");
} finally {
frame.appendText(out.toString());
frame.setVisible(true);
}
}
}
use of the.bytecode.club.bytecodeviewer.api.ExceptionUI in project bytecode-viewer by Konloch.
the class ShowAllStrings method execute.
@Override
public void execute(final ArrayList<ClassNode> classNodeList) {
final PluginConsole frame = new PluginConsole("Show All Strings");
final AtomicBoolean complete = new AtomicBoolean(false);
final Thread backgroundThread = new Thread() {
public void run() {
try {
for (ClassNode classNode : classNodeList) {
for (Object o : classNode.fields.toArray()) {
FieldNode f = (FieldNode) o;
Object v = f.value;
if (v instanceof String) {
String s = (String) v;
if (!s.isEmpty()) {
frame.appendText(String.format("%s.%s%s -> \"%s\"", classNode.name, f.name, f.desc, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
}
}
if (v instanceof String[]) {
for (int i = 0; i < ((String[]) v).length; i++) {
String s = ((String[]) v)[i];
if (!s.isEmpty()) {
frame.appendText(String.format("%s.%s%s[%s] -> \"%s\"", classNode.name, f.name, f.desc, i, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
}
}
}
}
for (Object o : classNode.methods.toArray()) {
MethodNode m = (MethodNode) o;
InsnList iList = m.instructions;
for (AbstractInsnNode a : iList.toArray()) {
if (a instanceof LdcInsnNode) {
if (((LdcInsnNode) a).cst instanceof String) {
final String s = (String) ((LdcInsnNode) a).cst;
if (!s.isEmpty()) {
frame.appendText(String.format("%s.%s%s -> \"%s\"", classNode.name, m.name, m.desc, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
}
}
}
}
}
}
} catch (Exception e) {
new ExceptionUI(e, "konloch@gmail.com");
} finally {
complete.set(true);
}
}
};
frame.setVisible(true);
frame.addWindowListener(new WindowListener() {
@Override
public void windowClosing(WindowEvent e) {
backgroundThread.stop();
complete.set(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
});
backgroundThread.start();
while (!complete.get()) ;
}
Aggregations