bug fixes for v2.9.16

This commit is contained in:
Konloch 2019-04-13 21:45:40 -06:00
parent 93f38a27d0
commit e092c3bba8
15 changed files with 269 additions and 115 deletions

View file

@ -885,23 +885,28 @@ public class BytecodeViewer
} else if (fn.endsWith(".apk")) { } else if (fn.endsWith(".apk")) {
try { try {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
FileContainer container = new FileContainer(f);
File tempCopy = new File(tempDirectory+fs+MiscUtils.randomString(32)+".apk");
FileUtils.copyFile(f, tempCopy);
FileContainer container = new FileContainer(tempCopy, f.getName());
if (viewer.decodeAPKResources.isSelected()) { if (viewer.decodeAPKResources.isSelected()) {
File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
APKTool.decodeResources(f, decodedResources); APKTool.decodeResources(tempCopy, decodedResources);
container.files = JarUtils.loadResources(decodedResources); container.files = JarUtils.loadResources(decodedResources);
} }
container.files.putAll(JarUtils.loadResources(f)); container.files.putAll(JarUtils.loadResources(tempCopy)); //copy and rename to prevent unicode filenames
String name = getRandomizedName() + ".jar"; String name = getRandomizedName() + ".jar";
File output = new File(tempDirectory + fs + name); File output = new File(tempDirectory + fs + name);
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
Dex2Jar.dex2Jar(f, output); Dex2Jar.dex2Jar(tempCopy, output);
else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
Enjarify.apk2Jar(f, output); Enjarify.apk2Jar(tempCopy, output);
container.classes = JarUtils.loadClasses(output); container.classes = JarUtils.loadClasses(output);
@ -914,15 +919,20 @@ public class BytecodeViewer
} else if (fn.endsWith(".dex")) { } else if (fn.endsWith(".dex")) {
try { try {
BytecodeViewer.viewer.setIcon(true); BytecodeViewer.viewer.setIcon(true);
FileContainer container = new FileContainer(f);
File tempCopy = new File(tempDirectory+fs+MiscUtils.randomString(32)+".dex");
FileUtils.copyFile(f, tempCopy); //copy and rename to prevent unicode filenames
FileContainer container = new FileContainer(tempCopy, f.getName());
String name = getRandomizedName() + ".jar"; String name = getRandomizedName() + ".jar";
File output = new File(tempDirectory + fs + name); File output = new File(tempDirectory + fs + name);
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel())) if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
Dex2Jar.dex2Jar(f, output); Dex2Jar.dex2Jar(tempCopy, output);
else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel())) else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
Enjarify.apk2Jar(f, output); Enjarify.apk2Jar(tempCopy, output);
container.classes = JarUtils.loadClasses(output); container.classes = JarUtils.loadClasses(output);

View file

@ -182,6 +182,12 @@ public class CommandLineInput {
//if its zip/jar/apk/dex attempt unzip as whole zip //if its zip/jar/apk/dex attempt unzip as whole zip
//if its just class allow any //if its just class allow any
File tempZip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp_"+BytecodeViewer.getRandomizedName()+".jar");
if (tempZip.exists())
tempZip.delete();
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
if (decompiler.equalsIgnoreCase("procyon")) { if (decompiler.equalsIgnoreCase("procyon")) {
System.out.println("Decompiling " + input.getAbsolutePath() + " with Procyon"); System.out.println("Decompiling " + input.getAbsolutePath() + " with Procyon");
BytecodeViewer.openFiles(new File[]{input}, false); BytecodeViewer.openFiles(new File[]{input}, false);
@ -189,7 +195,7 @@ public class CommandLineInput {
Thread.sleep(5 * 1000); Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) { if (target.equalsIgnoreCase("all")) {
Decompiler.procyon.decompileToZip(output.getAbsolutePath()); Decompiler.procyon.decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else { } else {
try { try {
ClassNode cn = BytecodeViewer.getClassNode(target); ClassNode cn = BytecodeViewer.getClassNode(target);
@ -207,7 +213,7 @@ public class CommandLineInput {
Thread.sleep(5 * 1000); Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) { if (target.equalsIgnoreCase("all")) {
Decompiler.cfr.decompileToZip(output.getAbsolutePath()); Decompiler.cfr.decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else { } else {
try { try {
ClassNode cn = BytecodeViewer.getClassNode(target); ClassNode cn = BytecodeViewer.getClassNode(target);
@ -225,7 +231,7 @@ public class CommandLineInput {
Thread.sleep(5 * 1000); Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) { if (target.equalsIgnoreCase("all")) {
Decompiler.fernflower.decompileToZip(output.getAbsolutePath()); Decompiler.fernflower.decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else { } else {
try { try {
ClassNode cn = BytecodeViewer.getClassNode(target); ClassNode cn = BytecodeViewer.getClassNode(target);
@ -243,7 +249,7 @@ public class CommandLineInput {
Thread.sleep(5 * 1000); Thread.sleep(5 * 1000);
if (target.equalsIgnoreCase("all")) { if (target.equalsIgnoreCase("all")) {
Decompiler.krakatau.decompileToZip(output.getAbsolutePath()); Decompiler.krakatau.decompileToZip(tempZip.getAbsolutePath(), output.getAbsolutePath());
} else { } else {
try { try {
ClassNode cn = BytecodeViewer.getClassNode(target); ClassNode cn = BytecodeViewer.getClassNode(target);

View file

@ -37,6 +37,11 @@ public class FileContainer {
this.name = f.getName(); this.name = f.getName();
} }
public FileContainer(File f, String name) {
this.file = f;
this.name = name;
}
public File file; public File file;
public String name; public String name;

View file

@ -216,6 +216,7 @@ public class Settings {
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.java, false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.java, false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileSmali.isSelected()), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileSmali.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false); DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false);
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.warnForEditing), false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }
@ -376,6 +377,8 @@ public class Settings {
BytecodeViewer.viewer.setExtendedState(JFrame.MAXIMIZED_BOTH); BytecodeViewer.viewer.setExtendedState(JFrame.MAXIMIZED_BOTH);
BytecodeViewer.viewer.isMaximized = true; BytecodeViewer.viewer.isMaximized = true;
} }
//86 is deprecated
//87 is deprecated
BytecodeViewer.lastDirectory = DiskReader.loadString(BytecodeViewer.settingsName, 88, false); BytecodeViewer.lastDirectory = DiskReader.loadString(BytecodeViewer.settingsName, 88, false);
BytecodeViewer.python = DiskReader.loadString(BytecodeViewer.settingsName, 89, false); BytecodeViewer.python = DiskReader.loadString(BytecodeViewer.settingsName, 89, false);
BytecodeViewer.rt = DiskReader.loadString(BytecodeViewer.settingsName, 90, false); BytecodeViewer.rt = DiskReader.loadString(BytecodeViewer.settingsName, 90, false);
@ -412,6 +415,7 @@ public class Settings {
BytecodeViewer.java = DiskReader.loadString(BytecodeViewer.settingsName, 117, false); BytecodeViewer.java = DiskReader.loadString(BytecodeViewer.settingsName, 117, false);
BytecodeViewer.viewer.autoCompileSmali.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 118, false))); BytecodeViewer.viewer.autoCompileSmali.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 118, false)));
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 119, false))); BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 119, false)));
BytecodeViewer.warnForEditing = (Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 119, false)));
} catch (Exception e) { } catch (Exception e) {
//ignore because errors are expected, first start up and outdated settings. //ignore because errors are expected, first start up and outdated settings.
//e.printStackTrace(); //e.printStackTrace();

View file

@ -247,23 +247,15 @@ public class CFRDecompiler extends Decompiler {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName)
File tempZip = new File(BytecodeViewer.tempDirectory {
+ BytecodeViewer.fs + "temp.jar"); File tempZip = new File(sourceJar);
if (tempZip.exists())
tempZip.delete();
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
tempZip.getAbsolutePath());
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs; String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs;
String fuckery = fuckery(fileStart); String fuckery = fuckery(fileStart);
org.benf.cfr.reader.Main.main(generateMainMethod( org.benf.cfr.reader.Main.main(generateMainMethod(tempZip.getAbsolutePath(), fuckery));
tempZip.getAbsolutePath(), fuckery));
tempZip.delete();
File fuck = new File(fuckery); File fuck = new File(fuckery);
try { try {

View file

@ -41,5 +41,5 @@ public abstract class Decompiler {
public abstract String decompileClassNode(ClassNode cn, byte[] b); public abstract String decompileClassNode(ClassNode cn, byte[] b);
public abstract void decompileToZip(String zipName); public abstract void decompileToZip(String sourceJar, String zipName);
} }

View file

@ -44,29 +44,19 @@ import the.bytecode.club.bytecodeviewer.Resources;
public class FernFlowerDecompiler extends Decompiler { public class FernFlowerDecompiler extends Decompiler {
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
File tempZip = new File(BytecodeViewer.tempDirectory + "temp.zip"); File tempZip = new File(sourceJar);
if (tempZip.exists())
tempZip.delete();
File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs);
+ "temp" + BytecodeViewer.fs);
f.mkdir(); f.mkdir();
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
tempZip.getAbsolutePath());
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/")); org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/"));
File tempZip2 = new File(BytecodeViewer.tempDirectory File tempZip2 = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs + tempZip.getName());
+ BytecodeViewer.fs + "temp" + BytecodeViewer.fs
+ tempZip.getName());
if (tempZip2.exists()) if (tempZip2.exists())
tempZip2.renameTo(new File(zipName)); tempZip2.renameTo(new File(zipName));
tempZip.delete(); f.delete();
new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp")
.delete();
} }
@Override @Override
@ -121,8 +111,6 @@ public class FernFlowerDecompiler extends Decompiler {
tempClass.delete(); tempClass.delete();
System.out.println(start + ".java");
final File outputJava = new File(start + ".java"); final File outputJava = new File(start + ".java");
if (outputJava.exists()) { if (outputJava.exists()) {
String s; String s;

View file

@ -118,6 +118,6 @@ public class JDGUIDecompiler extends Decompiler {
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
} }
} }

View file

@ -130,7 +130,7 @@ public class KrakatauDecompiler extends Decompiler {
return s; return s;
} }
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
if (BytecodeViewer.python.equals("")) { if (BytecodeViewer.python.equals("")) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path."); BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.pythonC(); BytecodeViewer.viewer.pythonC();
@ -144,10 +144,12 @@ public class KrakatauDecompiler extends Decompiler {
String ran = MiscUtils.randomString(32); String ran = MiscUtils.randomString(32);
final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs); final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs);
tempDirectory.mkdir(); tempDirectory.mkdir();
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
final File tempJar = new File(sourceJar);
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
BytecodeViewer.python, BytecodeViewer.python,
@ -167,11 +169,7 @@ public class KrakatauDecompiler extends Decompiler {
process.waitFor(); process.waitFor();
MiscUtils.printProcess(process); MiscUtils.printProcess(process);
// ZipUtils.zipDirectory(tempDirectory, new File(zipName));
ZipUtils.zipFolder(tempDirectory.getAbsolutePath(), zipName, ran); ZipUtils.zipFolder(tempDirectory.getAbsolutePath(), zipName, ran);
//tempDirectory.delete();
tempJar.delete();
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally { } finally {

View file

@ -109,7 +109,7 @@ public class KrakatauDisassembler extends Decompiler {
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
if (BytecodeViewer.python.equals("")) { if (BytecodeViewer.python.equals("")) {
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path."); BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
BytecodeViewer.viewer.pythonC(); BytecodeViewer.viewer.pythonC();
@ -118,8 +118,8 @@ public class KrakatauDisassembler extends Decompiler {
String ran = MiscUtils.randomString(32); String ran = MiscUtils.randomString(32);
final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs); final File tempDirectory = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + ran + BytecodeViewer.fs);
tempDirectory.mkdir(); tempDirectory.mkdir();
final File tempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); final File tempJar = new File(sourceJar);
BytecodeViewer.sm.stopBlocking(); BytecodeViewer.sm.stopBlocking();
try { try {
@ -138,11 +138,7 @@ public class KrakatauDisassembler extends Decompiler {
BytecodeViewer.createdProcesses.add(process); BytecodeViewer.createdProcesses.add(process);
process.waitFor(); process.waitFor();
// ZipUtils.zipDirectory(tempDirectory, new File(zipName));
ZipUtils.zipFolder(tempDirectory.getAbsolutePath(), zipName, ran); ZipUtils.zipFolder(tempDirectory.getAbsolutePath(), zipName, ran);
//tempDirectory.delete();
tempJar.delete();
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} finally { } finally {

View file

@ -150,17 +150,9 @@ public class ProcyonDecompiler extends Decompiler {
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
File tempZip = new File(BytecodeViewer.tempDirectory
+ BytecodeViewer.fs + "temp.jar");
if (tempZip.exists())
tempZip.delete();
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
tempZip.getAbsolutePath());
try { try {
doSaveJarDecompiled(tempZip, new File(zipName)); doSaveJarDecompiled(new File(sourceJar), new File(zipName));
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }

View file

@ -94,7 +94,7 @@ public class SmaliDisassembler extends Decompiler {
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
} }
} }

View file

@ -182,6 +182,6 @@ public class ClassNodeDecompiler extends Decompiler {
} }
@Override @Override
public void decompileToZip(String zipName) { public void decompileToZip(String sourceJar, String zipName) {
} }
} }

View file

@ -13,23 +13,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.*;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.IincInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.LookupSwitchInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TableSwitchInsnNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.analysis.Frame; import org.objectweb.asm.tree.analysis.Frame;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -150,6 +134,8 @@ public class InstructionPrinter {
line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain); line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain);
} else if (ain instanceof InvokeDynamicInsnNode) { } else if (ain instanceof InvokeDynamicInsnNode) {
line = printInvokeDynamicInsNode((InvokeDynamicInsnNode) ain); line = printInvokeDynamicInsNode((InvokeDynamicInsnNode) ain);
} else if (ain instanceof MultiANewArrayInsnNode) {
line = printMultiANewArrayInsNode((MultiANewArrayInsnNode) ain);
} else { } else {
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " " line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
+ ain.toString(); + ain.toString();
@ -317,6 +303,14 @@ public class InstructionPrinter {
return sb.toString(); return sb.toString();
} }
protected String printMultiANewArrayInsNode(MultiANewArrayInsnNode mana)
{
StringBuilder sb = new StringBuilder();
sb.append(nameOpcode(mana.getOpcode()) + " " + mana.dims + " : " + mana.desc);
return sb.toString();
}
private String printFrameNode(FrameNode frame) { private String printFrameNode(FrameNode frame) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(nameOpcode(frame.getOpcode()) + " "); sb.append(nameOpcode(frame.getOpcode()) + " ");

View file

@ -296,7 +296,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
"Replace Strings"); "Replace Strings");
public final JMenuItem mntmStackFramesRemover = new JMenuItem( public final JMenuItem mntmStackFramesRemover = new JMenuItem(
"StackFrames Remover"); "StackFrames Remover");
public final JMenuItem mntmNewMenuItem_4 = new JMenuItem(""); public final JMenuItem[] waitIcons;
public final JMenu mnNewMenu_3 = new JMenu("CFR"); public final JMenu mnNewMenu_3 = new JMenu("CFR");
public final JMenu mnNewMenu_4 = new JMenu("Procyon"); public final JMenu mnNewMenu_4 = new JMenu("Procyon");
public final JCheckBoxMenuItem decodeenumswitch = new JCheckBoxMenuItem( public final JCheckBoxMenuItem decodeenumswitch = new JCheckBoxMenuItem(
@ -586,19 +586,38 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public final JRadioButtonMenuItem panel3Bytecode = new JRadioButtonMenuItem("Bytecode"); public final JRadioButtonMenuItem panel3Bytecode = new JRadioButtonMenuItem("Bytecode");
public final JRadioButtonMenuItem panel3Hexcode = new JRadioButtonMenuItem("Hexcode"); public final JRadioButtonMenuItem panel3Hexcode = new JRadioButtonMenuItem("Hexcode");
public void setIcon(final boolean busy) { public synchronized void setIcon(final boolean busy) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (busy) { if (busy) {
try { for(int i = 0; i < 10; i++)
mntmNewMenuItem_4.setIcon(Resources.busyIcon); {
} catch (NullPointerException e) { if(waitIcons[i].getIcon() == null)
mntmNewMenuItem_4.setIcon(Resources.busyB64Icon); {
try {
waitIcons[i].setIcon(Resources.busyIcon);
} catch (NullPointerException e) {
waitIcons[i].setIcon(Resources.busyB64Icon);
}
waitIcons[i].updateUI();
break;
}
} }
} else }
mntmNewMenuItem_4.setIcon(null); else
mntmNewMenuItem_4.updateUI(); {
for(int i = 0; i < 10; i++)
{
if(waitIcons[i].getIcon() != null)
{
waitIcons[i].setIcon(null);
waitIcons[i].updateUI();
break;
}
}
}
} }
}); });
} }
@ -841,10 +860,20 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (result == 0) { if (result == 0) {
ArrayList<File> reopen = new ArrayList<File>(); ArrayList<File> reopen = new ArrayList<File>();
for (FileContainer container : BytecodeViewer.files) for (FileContainer container : BytecodeViewer.files)
{
File newFile = new File(container.file.getParent() + BytecodeViewer.fs + container.name);
if(!container.file.getAbsolutePath().equals(newFile.getAbsolutePath())) //APKs & dex get renamed
{
container.file.renameTo(newFile);
container.file = newFile;
}
reopen.add(container.file); reopen.add(container.file);
}
BytecodeViewer.files.clear(); BytecodeViewer.files.clear();
BytecodeViewer.openFiles(reopen.toArray(new File[reopen.size()]), false); BytecodeViewer.openFiles(reopen.toArray(new File[reopen.size()]), false);
//refresh panes //refresh panes
@ -1081,13 +1110,14 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} }
} }
BytecodeViewer.viewer.setIcon(true); final File javaSucks = file;
final String path = MiscUtils.append(file, ".zip"); // cheap hax cause final String path = MiscUtils.append(file, ".zip"); // cheap hax cause
// string is final // string is final
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(
"What decompiler will you use?"); "What decompiler will you use?");
Object[] options = new String[]{"Procyon", "CFR", Object[] options = new String[]{"All", "Procyon", "CFR",
"Fernflower", "Krakatau", "Cancel"}; "Fernflower", "Krakatau", "Cancel"};
pane.setOptions(options); pane.setOptions(options);
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
@ -1099,12 +1129,21 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
if (options[k].equals(obj)) if (options[k].equals(obj))
result = k; result = k;
if (result == 0) { BytecodeViewer.viewer.setIcon(true);
File tempZip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp_"+BytecodeViewer.getRandomizedName()+".jar");
if (tempZip.exists())
tempZip.delete();
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
if (result == 0)
{
Thread t = new Thread() { Thread t = new Thread() {
@Override @Override
public void run() { public void run() {
try { try {
Decompiler.procyon.decompileToZip(path); Decompiler.procyon.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-proycon.zip"));
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -1112,13 +1151,52 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} }
}; };
t.start(); t.start();
Thread t2 = new Thread() {
@Override
public void run() {
try {
BytecodeViewer.viewer.setIcon(true);
Decompiler.cfr.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-CFR.zip"));
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
};
t2.start();
Thread t3 = new Thread() {
@Override
public void run() {
try {
BytecodeViewer.viewer.setIcon(true);
Decompiler.fernflower.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-fernflower.zip"));
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
};
t3.start();
Thread t4 = new Thread() {
@Override
public void run() {
try {
BytecodeViewer.viewer.setIcon(true);
Decompiler.krakatau.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-kraktau.zip"));
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
};
t4.start();
} }
if (result == 1) { if (result == 1) {
Thread t = new Thread() { Thread t = new Thread() {
@Override @Override
public void run() { public void run() {
try { try {
Decompiler.cfr.decompileToZip(path); Decompiler.procyon.decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -1132,7 +1210,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
Decompiler.fernflower.decompileToZip(path); Decompiler.cfr.decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -1141,13 +1219,12 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
}; };
t.start(); t.start();
} }
if (result == 3) { if (result == 3) {
Thread t = new Thread() { Thread t = new Thread() {
@Override @Override
public void run() { public void run() {
try { try {
Decompiler.krakatau.decompileToZip(path); Decompiler.fernflower.decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
@ -1158,6 +1235,21 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} }
if (result == 4) { if (result == 4) {
Thread t = new Thread() {
@Override
public void run() {
try {
Decompiler.krakatau.decompileToZip(tempZip.getAbsolutePath(), path);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
}
};
t.start();
}
if (result == 5) {
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} }
} }
@ -1178,7 +1270,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
public void run() { public void run() {
if (autoCompileSmali.isSelected() && !BytecodeViewer.compile(false)) if (autoCompileSmali.isSelected() && !BytecodeViewer.compile(false))
return; return;
final String s = workPane.getCurrentViewer().name;
final String s = workPane.getCurrentViewer().cn.name;
if(s == null)
return;
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileFilter() { fc.setFileFilter(new FileFilter() {
@ -1225,7 +1321,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
JOptionPane pane = new JOptionPane( JOptionPane pane = new JOptionPane(
"What decompiler will you use?"); "What decompiler will you use?");
Object[] options = new String[]{"Procyon", "CFR", Object[] options = new String[]{"All", "Procyon", "CFR",
"Fernflower", "Krakatau", "Cancel"}; "Fernflower", "Krakatau", "Cancel"};
pane.setOptions(options); pane.setOptions(options);
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
@ -1254,12 +1350,47 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
} }
} }
String contents = Decompiler.procyon.decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false); try
{
DiskWriter.replaceFile(MiscUtils.append(file, "-proycon.java"), Decompiler.procyon.decompileClassNode(cn, cw.toByteArray()), false);
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
DiskWriter.replaceFile(MiscUtils.append(file, "-CFR.java"), Decompiler.cfr.decompileClassNode(cn, cw.toByteArray()), false);
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
DiskWriter.replaceFile(MiscUtils.append(file, "-fernflower.java"), Decompiler.fernflower.decompileClassNode(cn, cw.toByteArray()), false);
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
DiskWriter.replaceFile(MiscUtils.append(file, "-kraktau.java"), Decompiler.krakatau.decompileClassNode(cn, cw.toByteArray()), false);
}
catch(Exception e)
{
e.printStackTrace();
}
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( BytecodeViewer.viewer.setIcon(false);
e); new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
} }
} }
}; };
@ -1282,10 +1413,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
} }
} }
String contents = Decompiler.cfr.decompileClassNode(cn, cw.toByteArray()); String contents = Decompiler.procyon.decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false); DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
BytecodeViewer.viewer.setIcon(false);
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
e); e);
} }
@ -1298,7 +1430,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
@Override @Override
public void run() { public void run() {
try { try {
ClassNode cn = BytecodeViewer.getClassNode(s); ClassNode cn = BytecodeViewer.getClassNode(s);
final ClassWriter cw = new ClassWriter(0); final ClassWriter cw = new ClassWriter(0);
try { try {
@ -1311,10 +1442,11 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
} }
} }
String contents = Decompiler.fernflower.decompileClassNode(cn, cw.toByteArray()); String contents = Decompiler.cfr.decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false); DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
BytecodeViewer.viewer.setIcon(false);
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
e); e);
} }
@ -1335,14 +1467,16 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
e.printStackTrace(); e.printStackTrace();
try { try {
Thread.sleep(200); Thread.sleep(200);
cn.accept(cw); if(cn != null)
cn.accept(cw);
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
} }
} }
String contents = Decompiler.krakatau.decompileClassNode(cn, cw.toByteArray()); String contents = Decompiler.fernflower.decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false); DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) { } catch (Exception e) {
BytecodeViewer.viewer.setIcon(false);
new the.bytecode.club.bytecodeviewer.api.ExceptionUI( new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
e); e);
} }
@ -1351,6 +1485,35 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
t.start(); t.start();
} }
if (result == 4) { if (result == 4) {
Thread t = new Thread() {
@Override
public void run() {
try {
ClassNode cn = BytecodeViewer.getClassNode(s);
final ClassWriter cw = new ClassWriter(0);
try {
cn.accept(cw);
} catch (Exception e) {
e.printStackTrace();
try {
Thread.sleep(200);
cn.accept(cw);
} catch (InterruptedException e1) {
}
}
String contents = Decompiler.krakatau.decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(path, contents, false);
BytecodeViewer.viewer.setIcon(false);
} catch (Exception e) {
BytecodeViewer.viewer.setIcon(false);
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(
e);
}
}
};
t.start();
}
if (result == 5) {
BytecodeViewer.viewer.setIcon(false); BytecodeViewer.viewer.setIcon(false);
} }
} }
@ -2002,7 +2165,13 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
mnNewMenu_1.add(mntmZstringarrayDecrypter); mnNewMenu_1.add(mntmZstringarrayDecrypter);
mnNewMenu_1.add(mntmStackFramesRemover); mnNewMenu_1.add(mntmStackFramesRemover);
menuBar.add(mntmNewMenuItem_4); waitIcons = new JMenuItem[10];
for(int i = 0; i < 10; i++)
{
waitIcons[i] = new JMenuItem("");
waitIcons[i].setMaximumSize(new Dimension(20, 50));
menuBar.add(waitIcons[i]);
}
mntmStartExternalPlugin.addActionListener(new ActionListener() { mntmStartExternalPlugin.addActionListener(new ActionListener() {
@Override @Override