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 7039cf8c..5beb3f29 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 @@ -5,6 +5,7 @@ import me.konloch.kontainer.io.DiskWriter; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.util.Textifier; import org.objectweb.asm.util.TraceClassVisitor; +import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; @@ -65,7 +66,7 @@ public class JavapDisassembler extends InternalDecompiler DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false); - JFrameConsolePrintStream sysOut = null; + JFrameConsolePrintStream sysOutBuffer = null; try { URLClassLoader child = new URLClassLoader( @@ -78,7 +79,10 @@ public class JavapDisassembler extends InternalDecompiler Object cl = javap.newInstance(); //pipe sys out - sysOut = new JFrameConsolePrintStream("", false); + sysOutBuffer = new JFrameConsolePrintStream("", false); + + //silence security manager debugging + BytecodeViewer.sm.silenceExec(true); //invoke Javap main.invoke(cl, (Object) new String[]{"-c", "-l", "-constants", tempClass.getAbsolutePath()}); @@ -89,13 +93,14 @@ public class JavapDisassembler extends InternalDecompiler } finally { + BytecodeViewer.sm.silenceExec(false); tempClass.delete(); } - if(sysOut != null) + if(sysOutBuffer != null) { - sysOut.finished(); - return sysOut.getTextAreaOutputStreamOut().getBuffer().toString(); + sysOutBuffer.finished(); + return sysOutBuffer.getTextAreaOutputStreamOut().getBuffer().toString(); } return SEND_STACKTRACE_TO; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java index 968e42d1..4b182a08 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java @@ -32,10 +32,15 @@ import java.security.Permission; public class SecurityMan extends SecurityManager { - private int blocking = 1; //might be insecure due to assholes targeting BCV + private int blocking = 1; //TODO replace with a more secure system + private int silentExec = 1; private boolean printing = false; private boolean printingPackage = false; + public void silenceExec(boolean b) { + silentExec += (b ? 1 : -1); + } + public void resumeBlocking() { blocking++; } @@ -89,7 +94,10 @@ public class SecurityMan extends SecurityManager } if (allow && blocking == 0) - System.out.println("Allowing exec: " + cmd); + { + if(silentExec == 1) + System.out.println("Allowing exec: " + cmd); + } else throw new SecurityException("BCV is awesome, blocking(" + blocking + ") exec " + cmd); }