diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java index 368fdd8f..221c30b4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/ExceptionUI.java @@ -42,6 +42,7 @@ public class ExceptionUI extends JFrame { public static final String KONLOCH = "https://github.com/Konloch/bytecode-viewer/issues or Konloch at https://the.bytcode.club or konloch@gmail.com"; public static final String SEND_STACKTRACE_TO = buildErrorLogHeader(KONLOCH); + public static final String SEND_STACKTRACE_TO_NL = SEND_STACKTRACE_TO + nl + nl; /** * @param e The exception to be shown diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java index f9ae7aab..d4ebc398 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java @@ -131,12 +131,10 @@ public class CFRDecompiler extends InternalDecompiler try { org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery)); } catch (StackOverflowError | Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - - exception = - "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = exceptionWriter.toString(); } tempClass.delete(); @@ -170,15 +168,13 @@ public class CFRDecompiler extends InternalDecompiler try { s = DiskReader.loadAsString(f.getAbsolutePath()); } catch (Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - - String exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; return CFR + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + - nl + nl + exception; + nl + nl + exceptionWriter; } return s; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index de851754..e9fc8746 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -45,7 +45,6 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.*; */ public class FernFlowerDecompiler extends InternalDecompiler { - @Override public void decompileToZip(String sourceJar, String zipName) { @@ -78,10 +77,10 @@ public class FernFlowerDecompiler extends InternalDecompiler fos.write(b); fos.close(); } catch (final IOException e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = exceptionWriter.toString(); } @@ -110,10 +109,10 @@ public class FernFlowerDecompiler extends InternalDecompiler org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main( generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath())); } catch (Throwable e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = exceptionWriter.toString(); } } @@ -129,11 +128,11 @@ public class FernFlowerDecompiler extends InternalDecompiler return s; } catch (Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - exception += nl + nl + sw; + exception += nl + nl + exceptionWriter; } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java index a89406d4..6221c9bc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JADXDecompiler.java @@ -45,6 +45,9 @@ import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.*; */ public class JADXDecompiler extends InternalDecompiler { + private Random r = new Random(); + private File f; + @Override public String decompileClassNode(ClassNode cn, byte[] b) { String fileStart = tempDirectory + fs; @@ -74,10 +77,10 @@ public class JADXDecompiler extends InternalDecompiler jadx.saveSources(); //jadx.close(); } catch (StackOverflowError | Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + StringWriter exceptionWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(exceptionWriter)); e.printStackTrace(); - exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = exceptionWriter.toString(); } tempClass.delete(); @@ -93,15 +96,18 @@ public class JADXDecompiler extends InternalDecompiler nl + nl + exception; } - Random r = new Random(); - File f; - - public String fuckery(String start) { - while (true) { + //TODO remove + public String fuckery(String start) + { + int failSafe = 0; + while (failSafe++ <= 42069) + { f = new File(start + r.nextInt(Integer.MAX_VALUE)); if (!f.exists()) return f.toString(); } + + return null; } public String findFile(File[] fA) { @@ -116,7 +122,7 @@ public class JADXDecompiler extends InternalDecompiler StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - String exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + String exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + @@ -131,7 +137,5 @@ public class JADXDecompiler extends InternalDecompiler } @Override - public void decompileToZip(String sourceJar, String zipName) { - } - + public void decompileToZip(String sourceJar, String zipName) { } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JDGUIDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JDGUIDecompiler.java index d5215fa0..1f9716ba 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JDGUIDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JDGUIDecompiler.java @@ -116,8 +116,7 @@ public class JDGUIDecompiler extends InternalDecompiler e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception = - "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } return JDGUI + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java index b8721088..6df21bc6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/JavapDisassembler.java @@ -21,6 +21,7 @@ import java.net.URLClassLoader; import static the.bytecode.club.bytecodeviewer.Constants.fs; import static the.bytecode.club.bytecodeviewer.api.ExceptionUI.KONLOCH; +import static the.bytecode.club.bytecodeviewer.api.ExceptionUI.SEND_STACKTRACE_TO; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -96,7 +97,7 @@ public class JavapDisassembler extends InternalDecompiler return sysOut.getTextAreaOutputStreamOut().getBuffer().toString(); } - return KONLOCH; + return SEND_STACKTRACE_TO; } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java index 269ae7ef..e26055d3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java @@ -14,6 +14,7 @@ import the.bytecode.club.bootloader.resource.ExternalResource; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Constants; +import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.util.JarUtils; @@ -88,8 +89,7 @@ public class KrakatauDecompiler extends InternalDecompiler return "Set your paths"; } - String s = "Bytecode Viewer Version: " + VERSION + nl + nl + - "Please send this to konloch@gmail.com. " + nl + nl; + String s = ExceptionUI.SEND_STACKTRACE_TO_NL; BytecodeViewer.sm.pauseBlocking(); try { @@ -139,7 +139,7 @@ public class KrakatauDecompiler extends InternalDecompiler StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } finally { BytecodeViewer.sm.resumeBlocking(); } @@ -163,8 +163,7 @@ public class KrakatauDecompiler extends InternalDecompiler return "Set your paths"; } - String s = "Bytecode Viewer Version: " + VERSION + nl + nl + - "Please send this to konloch@gmail.com. " + nl + nl; + String s = ExceptionUI.SEND_STACKTRACE_TO_NL; final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); @@ -224,7 +223,7 @@ public class KrakatauDecompiler extends InternalDecompiler StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } finally { BytecodeViewer.sm.resumeBlocking(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java index 7fc67bc5..2cea60b5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java @@ -11,6 +11,7 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Constants; +import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.util.JarUtils; @@ -50,8 +51,7 @@ public class KrakatauDisassembler extends InternalDecompiler if(!ExternalResources.getSingleton().hasSetPythonCommand()) return "You need to set your Python 2.7 path!"; - String s = "Bytecode Viewer Version: " + VERSION + nl + nl + - "Please send this to konloch@gmail.com. " + nl + nl; + String s = ExceptionUI.SEND_STACKTRACE_TO_NL; final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); @@ -104,7 +104,7 @@ public class KrakatauDisassembler extends InternalDecompiler StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } finally { BytecodeViewer.sm.resumeBlocking(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java index cc7e7bd7..d5a55aae 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java @@ -129,7 +129,7 @@ public class ProcyonDecompiler extends InternalDecompiler e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception = "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java index 50eadb71..f55c1f1b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/SmaliDisassembler.java @@ -78,7 +78,7 @@ public class SmaliDisassembler extends InternalDecompiler e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } File rename = new File(tempDex.getName().replaceFirst("\\.dex", "-out")); @@ -90,7 +90,7 @@ public class SmaliDisassembler extends InternalDecompiler e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } File outputSmali = null; @@ -114,7 +114,7 @@ public class SmaliDisassembler extends InternalDecompiler e.printStackTrace(new PrintWriter(sw)); e.printStackTrace(); - exception += "Bytecode Viewer Version: " + VERSION + nl + nl + sw; + exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } return SMALI + " " + DISASSEMBLER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO +