2.9.8
This commit is contained in:
parent
25df7fa362
commit
89bad45283
14 changed files with 200 additions and 343 deletions
BIN
BytecodeViewer 2.9.8-preview-1.jar
Normal file
BIN
BytecodeViewer 2.9.8-preview-1.jar
Normal file
Binary file not shown.
|
@ -10,11 +10,17 @@ import java.util.List;
|
|||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import me.konloch.kontainer.io.HTTPRequest;
|
||||
import the.bytecode.club.bootloader.resource.EmptyExternalResource;
|
||||
import the.bytecode.club.bootloader.resource.ExternalResource;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.CommandLineInput;
|
||||
import the.bytecode.club.bytecodeviewer.ZipUtils;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @author Bibl (don't ban me pls)
|
||||
* @created 19 Jul 2015 03:22:37
|
||||
*/
|
||||
|
@ -22,28 +28,44 @@ public class Boot {
|
|||
|
||||
private static InitialBootScreen screen;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void boot(String[] args, int CLI) throws Exception {
|
||||
if(CLI == CommandLineInput.STOP)
|
||||
return;
|
||||
|
||||
bootstrap();
|
||||
ILoader<?> loader = findLoader();
|
||||
|
||||
screen = new InitialBootScreen();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
screen.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
if(CLI == CommandLineInput.OPEN_FILE)
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
screen.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
create(loader, args.length > 0 ? Boolean.valueOf(args[0]) : true);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
screen.setVisible(false);
|
||||
}
|
||||
});
|
||||
Class<?> klass = loader.loadClass("the.bytecode.club.bytecodeviewer.BytecodeViewer");
|
||||
klass.getDeclaredMethod("main", new Class<?>[] { String[].class }).invoke(null, new Object[] { args });
|
||||
|
||||
/*Class<?> klass = loader.loadClass("the.bytecode.club.bytecodeviewer.BytecodeViewer");
|
||||
klass.getDeclaredMethod("BOOT", new Class<?>[] { String[].class }).invoke(null, new Object[] { args });*/
|
||||
|
||||
if(CLI == CommandLineInput.OPEN_FILE)
|
||||
BytecodeViewer.BOOT(args, false);
|
||||
else {
|
||||
BytecodeViewer.BOOT(args, true);
|
||||
CommandLineInput.executeCommandLine(args);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static void create(ILoader<?> loader, boolean clean) throws Exception {
|
||||
setState("Bytecode Viewer Boot Screen - Checking Libraries...");
|
||||
|
||||
|
@ -177,6 +199,88 @@ public class Boot {
|
|||
screen.getProgressBar().setValue(completedCheck);
|
||||
}
|
||||
}
|
||||
|
||||
setState("Bytecode Viewer Boot Screen - Checking Krakatau...");
|
||||
System.out.println("Checking krakatau");
|
||||
|
||||
File krakatauZip = null;
|
||||
for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("krakatau-")) {
|
||||
BytecodeViewer.krakatauVersion = f.getName().split("-")[1].split("\\.")[0];
|
||||
krakatauZip = f;
|
||||
}
|
||||
}
|
||||
|
||||
for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("krakatau_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.krakatauVersion)) {
|
||||
setState("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "...");
|
||||
System.out.println("Removing oudated " + f.getName());
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.krakatauWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion + BytecodeViewer.fs + "Krakatau-master";
|
||||
File krakatauDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion);
|
||||
if(!krakatauDirectory.exists()) {
|
||||
try {
|
||||
setState("Bytecode Viewer Boot Screen - Updating to "+krakatauDirectory.getName()+"...");
|
||||
ZipUtils.unzipFilesToPath(krakatauZip.getAbsolutePath(), krakatauDirectory.getAbsolutePath());
|
||||
System.out.println("Updated to krakatau v" + BytecodeViewer.krakatauVersion);
|
||||
} catch(Exception e) {
|
||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly corrupt). Restart BCV."+BytecodeViewer.nl+
|
||||
"If the error persists contact @Konloch.");
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
krakatauZip.delete();
|
||||
}
|
||||
}
|
||||
|
||||
completedCheck++;
|
||||
screen.getProgressBar().setValue(completedCheck);
|
||||
|
||||
|
||||
setState("Bytecode Viewer Boot Screen - Checking Enjarify...");
|
||||
System.out.println("Checking enjarify");
|
||||
|
||||
File enjarifyZip = null;
|
||||
for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("enjarify-")) {
|
||||
BytecodeViewer.enjarifyVersion = f.getName().split("-")[1].split("\\.")[0];
|
||||
enjarifyZip = f;
|
||||
}
|
||||
}
|
||||
|
||||
for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("enjarify_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.enjarifyVersion)) {
|
||||
setState("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "...");
|
||||
System.out.println("Removing oudated " + f.getName());
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.enjarifyWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion + BytecodeViewer.fs + "enjarify-master";
|
||||
File enjarifyDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion);
|
||||
if(!enjarifyDirectory.exists()) {
|
||||
try {
|
||||
setState("Bytecode Viewer Boot Screen - Updating to "+enjarifyDirectory.getName()+"...");
|
||||
ZipUtils.unzipFilesToPath(enjarifyZip.getAbsolutePath(), enjarifyDirectory.getAbsolutePath());
|
||||
System.out.println("Updated to enjarify v" + BytecodeViewer.enjarifyVersion);
|
||||
} catch(Exception e) {
|
||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart BCV."+BytecodeViewer.nl+
|
||||
"If the error persists contact @Konloch.");
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
enjarifyZip.delete();
|
||||
}
|
||||
}
|
||||
completedCheck++;
|
||||
screen.getProgressBar().setValue(completedCheck);
|
||||
|
||||
setState("Bytecode Viewer Boot Screen - Booting!");
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.swing.text.html.HTMLEditorKit;
|
|||
import the.bytecode.club.bytecodeviewer.Resources;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @author Bibl (don't ban me pls)
|
||||
* @created 19 Jul 2015 04:12:21
|
||||
*/
|
||||
|
|
|
@ -79,7 +79,6 @@ public class LibraryClassLoader extends ClassLoader implements ILoader<JarConten
|
|||
return super.loadClass(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Class<?> define(ClassNode cn) {
|
||||
ClassWriter writer = new ResolvingClassWriter(tree);
|
||||
cn.accept(cn);
|
||||
|
|
|
@ -1,212 +0,0 @@
|
|||
package the.bytecode.club.bytecodeviewer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
/**
|
||||
* Automatic updater for BCV libraries
|
||||
*
|
||||
* @author Konloch
|
||||
*
|
||||
*/
|
||||
|
||||
public class BootScreen extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = -1098467609722393444L;
|
||||
|
||||
private static boolean FIRST_BOOT = false;
|
||||
|
||||
private JProgressBar progressBar = new JProgressBar();
|
||||
|
||||
public BootScreen() throws IOException {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setIconImages(Resources.iconList);
|
||||
|
||||
int i = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
|
||||
if(i >= 840)
|
||||
setSize(new Dimension(600, 800));
|
||||
else if(i >= 640)
|
||||
setSize(new Dimension(500, 600));
|
||||
else if(i >= 440)
|
||||
setSize(new Dimension(400, 400));
|
||||
else
|
||||
setSize(Toolkit.getDefaultToolkit().getScreenSize());
|
||||
|
||||
setTitle("Bytecode Viewer Boot Screen - Starting Up");
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
gridBagLayout.columnWidths = new int[]{0, 0};
|
||||
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||
gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||
getContentPane().setLayout(gridBagLayout);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||
gbc_scrollPane.gridheight = 24;
|
||||
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||
gbc_scrollPane.gridx = 0;
|
||||
gbc_scrollPane.gridy = 0;
|
||||
getContentPane().add(scrollPane, gbc_scrollPane);
|
||||
|
||||
JEditorPane editorPane = new JEditorPane();
|
||||
editorPane.setEditorKit(new HTMLEditorKit());
|
||||
|
||||
editorPane.setText(convertStreamToString(BytecodeViewer.class.getClassLoader().getResourceAsStream("resources/intro.html")));
|
||||
|
||||
scrollPane.setViewportView(editorPane);
|
||||
|
||||
GridBagConstraints gbc_progressBar = new GridBagConstraints();
|
||||
gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_progressBar.gridx = 0;
|
||||
gbc_progressBar.gridy = 24;
|
||||
getContentPane().add(progressBar, gbc_progressBar);
|
||||
this.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
static String convertStreamToString(java.io.InputStream is) throws IOException {
|
||||
@SuppressWarnings("resource")
|
||||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
||||
String string = s.hasNext() ? s.next() : "";
|
||||
is.close();
|
||||
s.close();
|
||||
return string;
|
||||
}
|
||||
|
||||
public void DO_FIRST_BOOT(String args[], int CLI) {
|
||||
if(CLI == -1)
|
||||
return;
|
||||
|
||||
if(CLI == 1)
|
||||
this.setVisible(true);
|
||||
|
||||
if(FIRST_BOOT)
|
||||
return;
|
||||
|
||||
FIRST_BOOT = true;
|
||||
|
||||
setTitle("Bytecode Viewer Boot Screen - Checking Libraries...");
|
||||
System.out.println("Checking Libraries...");
|
||||
|
||||
try {
|
||||
int completedCheck = 0;
|
||||
setTitle("Bytecode Viewer Boot Screen - Checking Krakatau...");
|
||||
System.out.println("Checking krakatau");
|
||||
|
||||
File krakatauZip = null;
|
||||
for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("krakatau-")) {
|
||||
BytecodeViewer.krakatauVersion = f.getName().split("-")[1].split("\\.")[0];
|
||||
krakatauZip = f;
|
||||
}
|
||||
}
|
||||
|
||||
for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("krakatau_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.krakatauVersion)) {
|
||||
setTitle("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "...");
|
||||
System.out.println("Removing oudated " + f.getName());
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.krakatauWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion + BytecodeViewer.fs + "Krakatau-master";
|
||||
File krakatauDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "krakatau_" + BytecodeViewer.krakatauVersion);
|
||||
if(!krakatauDirectory.exists()) {
|
||||
try {
|
||||
setTitle("Bytecode Viewer Boot Screen - Updating to "+krakatauDirectory.getName()+"...");
|
||||
ZipUtils.unzipFilesToPath(krakatauZip.getAbsolutePath(), krakatauDirectory.getAbsolutePath());
|
||||
System.out.println("Updated to krakatau v" + BytecodeViewer.krakatauVersion);
|
||||
} catch(Exception e) {
|
||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly corrupt). Restart BCV."+BytecodeViewer.nl+
|
||||
"If the error persists contact @Konloch.");
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
krakatauZip.delete();
|
||||
}
|
||||
}
|
||||
|
||||
completedCheck++;
|
||||
progressBar.setValue(completedCheck);
|
||||
|
||||
|
||||
setTitle("Bytecode Viewer Boot Screen - Checking Enjarify...");
|
||||
System.out.println("Checking enjarify");
|
||||
|
||||
File enjarifyZip = null;
|
||||
for(File f : new File(BytecodeViewer.libsDirectory).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("enjarify-")) {
|
||||
BytecodeViewer.enjarifyVersion = f.getName().split("-")[1].split("\\.")[0];
|
||||
enjarifyZip = f;
|
||||
}
|
||||
}
|
||||
|
||||
for(File f : new File(BytecodeViewer.getBCVDirectory()).listFiles()) {
|
||||
if(f.getName().toLowerCase().startsWith("enjarify_") && !f.getName().split("_")[1].split("\\.")[0].equals(BytecodeViewer.enjarifyVersion)) {
|
||||
setTitle("Bytecode Viewer Boot Screen - Removing Outdated " + f.getName() + "...");
|
||||
System.out.println("Removing oudated " + f.getName());
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.enjarifyWorkingDirectory = BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion + BytecodeViewer.fs + "enjarify-master";
|
||||
File enjarifyDirectory = new File(BytecodeViewer.getBCVDirectory() + BytecodeViewer.fs + "enjarify_" + BytecodeViewer.enjarifyVersion);
|
||||
if(!enjarifyDirectory.exists()) {
|
||||
try {
|
||||
setTitle("Bytecode Viewer Boot Screen - Updating to "+enjarifyDirectory.getName()+"...");
|
||||
ZipUtils.unzipFilesToPath(enjarifyZip.getAbsolutePath(), enjarifyDirectory.getAbsolutePath());
|
||||
System.out.println("Updated to enjarify v" + BytecodeViewer.enjarifyVersion);
|
||||
} catch(Exception e) {
|
||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart BCV."+BytecodeViewer.nl+
|
||||
"If the error persists contact @Konloch.");
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
enjarifyZip.delete();
|
||||
}
|
||||
}
|
||||
completedCheck++;
|
||||
progressBar.setValue(completedCheck);
|
||||
|
||||
setTitle("Bytecode Viewer Boot Screen - Booting!");
|
||||
|
||||
} catch(Exception e) {
|
||||
Settings.saveGUI();
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
e.printStackTrace();
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI("Bytecode Viewer ran into an error while booting, trying to force it anyways."+ BytecodeViewer.nl+ BytecodeViewer.nl+
|
||||
"Please ensure you have an active internet connection and restart BCV. If this presists please visit http://github.com/Konloch/Bytecode-Viewer or http://bytecodeviewer.com"+ BytecodeViewer.nl + BytecodeViewer.nl + sw.toString());
|
||||
}
|
||||
|
||||
setTitle("Bytecode Viewer Boot Screen - Finished");
|
||||
|
||||
if(CLI == 1)
|
||||
BytecodeViewer.BOOT(args, false);
|
||||
else {
|
||||
BytecodeViewer.BOOT(args, true);
|
||||
CommandLineInput.executeCommandLine(args);
|
||||
}
|
||||
|
||||
this.setVisible(false);
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import me.konloch.kontainer.io.HTTPRequest;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import the.bytecode.club.bootloader.Boot;
|
||||
import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader;
|
||||
import the.bytecode.club.bytecodeviewer.gui.ClassViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.FileNavigationPane;
|
||||
|
@ -90,23 +91,11 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
|
|||
* fix hook inject for EZ-Injection
|
||||
* fix classfile searcher
|
||||
*
|
||||
* -----2.9.7-----:
|
||||
* 07/02/2015 - Added ajustable font size.
|
||||
* 07/05/2015 - Started working on the new Boot Screen.
|
||||
* 07/06/2015 - Moved the font size to be under the view menu.
|
||||
* 07/06/2015 - Fixed a bug with plugins not being able to grab the currently viewed class.
|
||||
* 07/07/2015 - Started adding enjarify as an optional APK converter instead of Dex2Jar.
|
||||
* 07/07/2015 - Finished the new Boot Screen
|
||||
* 07/09/2015 - Fixed a process leak with krakatau decompiler.
|
||||
* 07/09/2015 - Finished adding enjarify.
|
||||
* 07/09/2015 - Supressed syntax exceptions due to JD-GUI.
|
||||
* 07/09/2015 - Fixed refresh on non-refreshable resources.
|
||||
* 07/09/2015 - Fixed opening a class and the name is so big, you cannot close because the [X] does not appear.
|
||||
* 07/09/2015 - Added support for smaller screens for the boot screen.
|
||||
* 07/16/2015 - Removed the FileFilter classes.
|
||||
* 07/16/2015 - Updated the decompiler class to make more sense.
|
||||
* 07/16/2015 - Started working on BCV CLI.
|
||||
* 07/16/2015 - Finished BCV CLI.
|
||||
* -----2.9.8-----:
|
||||
* 07/19/2015 - Fixed enjarify.
|
||||
* 07/20/2015 - Bibl sexified the boot loading time.
|
||||
* 07/20/2015 - Decode APK Resources is selected by default.
|
||||
* 07/20/2015 - Made the security manager slightly safer, can still be targeted but not as obvious now.
|
||||
*
|
||||
* @author Konloch
|
||||
*
|
||||
|
@ -115,8 +104,8 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
|
|||
public class BytecodeViewer {
|
||||
|
||||
/*per version*/
|
||||
public static String version = "2.9.7";
|
||||
public static boolean previewCopy = false;
|
||||
public static String version = "2.9.8";
|
||||
public static boolean previewCopy = true;
|
||||
/*the rest*/
|
||||
public static MainViewerGUI viewer = null;
|
||||
public static ClassNodeLoader loader = new ClassNodeLoader(); //might be insecure due to assholes targeting BCV, however that's highly unlikely.
|
||||
|
@ -388,7 +377,9 @@ public class BytecodeViewer {
|
|||
viewer = new MainViewerGUI();
|
||||
Settings.loadGUI();
|
||||
|
||||
new BootScreen().DO_FIRST_BOOT(args, CommandLineInput.parseCommandLine(args));
|
||||
|
||||
Boot.boot(args, CommandLineInput.parseCommandLine(args));
|
||||
//new BootScreen().DO_FIRST_BOOT(args, CommandLineInput.parseCommandLine(args));
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
@ -926,14 +917,14 @@ public class BytecodeViewer {
|
|||
* @param f file you want hidden
|
||||
*/
|
||||
private static void hideFile(File f) {
|
||||
sm.blocking = false;
|
||||
sm.stopBlocking();
|
||||
try {
|
||||
// Hide file by running attrib system command (on Windows)
|
||||
Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
sm.blocking = true;
|
||||
sm.setBlocking();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,11 @@ public class CommandLineInput {
|
|||
private static final Options options = new Options();
|
||||
private static final CommandLineParser parser = new DefaultParser();
|
||||
|
||||
/*BECAUSE WHO DOESN'T LOVE MAGIC NUMBERS*/
|
||||
public static int STOP = -1;
|
||||
public static int OPEN_FILE = 0;
|
||||
public static int CLI = 1;
|
||||
|
||||
static {
|
||||
options.addOption("help", false, "prints the help menu.");
|
||||
options.addOption("list", false, "lists all the available decompilers for BCV " + BytecodeViewer.version+".");
|
||||
|
@ -63,7 +68,7 @@ public class CommandLineInput {
|
|||
|
||||
public static int parseCommandLine(String[] args) {
|
||||
if(!containsCommand(args))
|
||||
return 1;
|
||||
return OPEN_FILE;
|
||||
try {
|
||||
CommandLine cmd = parser.parse(options, args);
|
||||
if(cmd.hasOption("list")) {
|
||||
|
@ -74,7 +79,7 @@ public class CommandLineInput {
|
|||
System.out.println("Krakatau-Bytecode");
|
||||
System.out.println("JD-GUI");
|
||||
System.out.println("Smali");
|
||||
return -1;
|
||||
return STOP;
|
||||
} else if(cmd.hasOption("help")) {
|
||||
for(String s : new String[] {
|
||||
"-help Displays the help menu",
|
||||
|
@ -86,17 +91,17 @@ public class CommandLineInput {
|
|||
"-nowait Doesn't wait for the user to read the CLI messages"
|
||||
})
|
||||
System.out.println(s);
|
||||
return -1;
|
||||
return STOP;
|
||||
} else {
|
||||
if(cmd.getOptionValue("i") == null) {
|
||||
System.err.println("Set the input with -i");
|
||||
return -1;
|
||||
return STOP;
|
||||
} if(cmd.getOptionValue("o") == null) {
|
||||
System.err.println("Set the output with -o");
|
||||
return -1;
|
||||
return STOP;
|
||||
} if(cmd.getOptionValue("t") == null) {
|
||||
System.err.println("Set the target with -t");
|
||||
return -1;
|
||||
return STOP;
|
||||
}
|
||||
|
||||
File input = new File(cmd.getOptionValue("i"));
|
||||
|
@ -105,7 +110,7 @@ public class CommandLineInput {
|
|||
|
||||
if(!input.exists()) {
|
||||
System.err.println(input.getAbsolutePath() + " does not exist.");
|
||||
return -1;
|
||||
return STOP;
|
||||
}
|
||||
|
||||
if(output.exists()) {
|
||||
|
@ -134,13 +139,13 @@ public class CommandLineInput {
|
|||
if(!cmd.hasOption("nowait"))
|
||||
Thread.sleep(5 * 1000);
|
||||
|
||||
return 0;
|
||||
return CLI;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return OPEN_FILE;
|
||||
}
|
||||
|
||||
public static void executeCommandLine(String[] args) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Enjarify {
|
|||
BytecodeViewer.viewer.pythonC3();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python3,
|
||||
|
@ -67,62 +67,6 @@ public class Enjarify {
|
|||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a .jar to .dex
|
||||
* @param input the input .jar file
|
||||
* @param output the output .dex file
|
||||
*/
|
||||
public static synchronized void saveAsAPK(File input, File output) {
|
||||
if(BytecodeViewer.python3.equals("")) {
|
||||
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
|
||||
BytecodeViewer.viewer.pythonC3();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python3,
|
||||
"-O",
|
||||
"-m",
|
||||
"enjarify.main",
|
||||
input.getAbsolutePath(),
|
||||
"-o",
|
||||
output.getAbsolutePath()
|
||||
);
|
||||
pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory));
|
||||
|
||||
|
||||
Process process = pb.start();
|
||||
BytecodeViewer.createdProcesses.add(process);
|
||||
|
||||
//Read out dir output
|
||||
InputStream is = process.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
br.close();
|
||||
|
||||
is = process.getErrorStream();
|
||||
isr = new InputStreamReader(is);
|
||||
br = new BufferedReader(isr);
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
br.close();
|
||||
|
||||
int exitValue = process.waitFor();
|
||||
System.out.println("Exit Value is " + exitValue);
|
||||
|
||||
} catch(Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,16 +13,46 @@ import java.security.Permission;
|
|||
|
||||
public class SecurityMan extends SecurityManager {
|
||||
|
||||
public boolean blocking = true; //might be insecure due to assholes targeting BCV, however that's highly unlikely.
|
||||
public void setBlocking() {
|
||||
blocking = true;
|
||||
}
|
||||
|
||||
public void stopBlocking() { //slightly safer security system than just a public static boolean being toggled
|
||||
String executedClass = Thread.currentThread().getStackTrace()[2].getClassName();
|
||||
if( executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.KrakatauDecompiler") ||
|
||||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.KrakatauDisassambler") ||
|
||||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.KrakatauAssembler") ||
|
||||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer"))
|
||||
{
|
||||
blocking = false;
|
||||
} else for(StackTraceElement stackTraceElements : Thread.currentThread().getStackTrace()) {
|
||||
System.out.println(stackTraceElements.getClassName());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean blocking = true; //might be insecure due to assholes targeting BCV, however that's highly unlikely.
|
||||
|
||||
@Override
|
||||
public void checkExec(String cmd) {
|
||||
if(blocking)
|
||||
throw new SecurityException("BCV is awesome.");
|
||||
String[] whitelist = {
|
||||
"attrib",
|
||||
"python",
|
||||
"pypy"
|
||||
};
|
||||
boolean allow = false;
|
||||
|
||||
for(String s : whitelist) {
|
||||
if(cmd.contains(s))
|
||||
allow = true;
|
||||
}
|
||||
|
||||
if(allow && !blocking) {
|
||||
System.out.println("Allowing exec:" + cmd);
|
||||
} else throw new SecurityException("BCV is awesome.");
|
||||
}
|
||||
@Override
|
||||
public void checkListen(int port) {
|
||||
if(blocking)
|
||||
throw new SecurityException("BCV is awesome.");
|
||||
throw new SecurityException("BCV is awesome.");
|
||||
}
|
||||
@Override
|
||||
public void checkPermission(Permission perm) { //expand eventually
|
||||
|
|
|
@ -41,7 +41,7 @@ public class KrakatauAssembler extends Compiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp"+MiscUtils.randomString(32)+".jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
String log = "";
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
|
@ -86,10 +86,10 @@ public class KrakatauAssembler extends Compiler {
|
|||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(log);
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp"+MiscUtils.randomString(32)+".jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python,
|
||||
|
@ -100,10 +100,10 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
e.printStackTrace(new PrintWriter(sw));
|
||||
e.printStackTrace();
|
||||
s += BytecodeViewer.nl+"Bytecode Viewer Version: " + BytecodeViewer.version + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString();
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python,
|
||||
|
@ -168,9 +168,9 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
tempJar.delete();
|
||||
} catch(Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
}
|
||||
|
||||
public void decompileToClass(String className, String classNameSaved) {
|
||||
|
@ -188,7 +188,7 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python,
|
||||
|
@ -231,6 +231,8 @@ public class KrakatauDecompiler extends Decompiler {
|
|||
tempJar.delete();
|
||||
} catch(Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class KrakatauDisassembler extends Decompiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp"+MiscUtils.randomString(32)+".jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python,
|
||||
|
@ -86,10 +86,9 @@ public class KrakatauDisassembler extends Decompiler {
|
|||
e.printStackTrace(new PrintWriter(sw));
|
||||
e.printStackTrace();
|
||||
s += BytecodeViewer.nl+"Bytecode Viewer Version: " + BytecodeViewer.version + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString();
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -105,7 +104,7 @@ public class KrakatauDisassembler extends Decompiler {
|
|||
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||
|
||||
BytecodeViewer.sm.blocking = false;
|
||||
BytecodeViewer.sm.stopBlocking();
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
BytecodeViewer.python,
|
||||
|
@ -149,8 +148,8 @@ public class KrakatauDisassembler extends Decompiler {
|
|||
tempJar.delete();
|
||||
} catch(Exception e) {
|
||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
} finally {
|
||||
BytecodeViewer.sm.setBlocking();
|
||||
}
|
||||
|
||||
BytecodeViewer.sm.blocking = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Dex2Jar;
|
||||
import the.bytecode.club.bytecodeviewer.Enjarify;
|
||||
import the.bytecode.club.bytecodeviewer.MiscUtils;
|
||||
import the.bytecode.club.bytecodeviewer.ZipUtils;
|
||||
|
||||
|
@ -46,10 +45,7 @@ public class SmaliDisassembler extends Decompiler {
|
|||
|
||||
ZipUtils.zipFile(tempClass, tempZip);
|
||||
|
||||
if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||
Dex2Jar.saveAsDex(tempZip, tempDex);
|
||||
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
|
||||
Enjarify.saveAsAPK(tempZip, tempDex);
|
||||
Dex2Jar.saveAsDex(tempZip, tempDex);
|
||||
|
||||
try {
|
||||
org.jf.baksmali.main.main(new String[]{"-o", tempSmali.getAbsolutePath(), "-x", tempDex.getAbsolutePath()});
|
||||
|
|
|
@ -892,10 +892,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||
Dex2Jar.saveAsDex(new File(input), file2);
|
||||
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
|
||||
Enjarify.saveAsAPK(new File(input), file2);
|
||||
Dex2Jar.saveAsDex(new File(input), file2);
|
||||
|
||||
BytecodeViewer.viewer.setIcon(false);
|
||||
}
|
||||
|
@ -1484,6 +1481,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
mnSettings.add(refreshOnChange);
|
||||
|
||||
mnSettings.add(separator_38);
|
||||
decodeAPKResources.setSelected(true);
|
||||
|
||||
mnSettings.add(decodeAPKResources);
|
||||
|
||||
|
|
Loading…
Reference in a new issue