Improved Javap
This commit is contained in:
parent
600b88e05e
commit
f349e6a8f1
2 changed files with 20 additions and 7 deletions
|
@ -5,6 +5,7 @@ import me.konloch.kontainer.io.DiskWriter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.util.Textifier;
|
import org.objectweb.asm.util.Textifier;
|
||||||
import org.objectweb.asm.util.TraceClassVisitor;
|
import org.objectweb.asm.util.TraceClassVisitor;
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||||
import the.bytecode.club.bytecodeviewer.Constants;
|
import the.bytecode.club.bytecodeviewer.Constants;
|
||||||
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
|
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
|
||||||
|
@ -65,7 +66,7 @@ public class JavapDisassembler extends InternalDecompiler
|
||||||
|
|
||||||
DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false);
|
DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false);
|
||||||
|
|
||||||
JFrameConsolePrintStream sysOut = null;
|
JFrameConsolePrintStream sysOutBuffer = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
URLClassLoader child = new URLClassLoader(
|
URLClassLoader child = new URLClassLoader(
|
||||||
|
@ -78,7 +79,10 @@ public class JavapDisassembler extends InternalDecompiler
|
||||||
Object cl = javap.newInstance();
|
Object cl = javap.newInstance();
|
||||||
|
|
||||||
//pipe sys out
|
//pipe sys out
|
||||||
sysOut = new JFrameConsolePrintStream("", false);
|
sysOutBuffer = new JFrameConsolePrintStream("", false);
|
||||||
|
|
||||||
|
//silence security manager debugging
|
||||||
|
BytecodeViewer.sm.silenceExec(true);
|
||||||
|
|
||||||
//invoke Javap
|
//invoke Javap
|
||||||
main.invoke(cl, (Object) new String[]{"-c", "-l", "-constants", tempClass.getAbsolutePath()});
|
main.invoke(cl, (Object) new String[]{"-c", "-l", "-constants", tempClass.getAbsolutePath()});
|
||||||
|
@ -89,13 +93,14 @@ public class JavapDisassembler extends InternalDecompiler
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
BytecodeViewer.sm.silenceExec(false);
|
||||||
tempClass.delete();
|
tempClass.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sysOut != null)
|
if(sysOutBuffer != null)
|
||||||
{
|
{
|
||||||
sysOut.finished();
|
sysOutBuffer.finished();
|
||||||
return sysOut.getTextAreaOutputStreamOut().getBuffer().toString();
|
return sysOutBuffer.getTextAreaOutputStreamOut().getBuffer().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return SEND_STACKTRACE_TO;
|
return SEND_STACKTRACE_TO;
|
||||||
|
|
|
@ -32,10 +32,15 @@ import java.security.Permission;
|
||||||
|
|
||||||
public class SecurityMan extends SecurityManager
|
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 printing = false;
|
||||||
private boolean printingPackage = false;
|
private boolean printingPackage = false;
|
||||||
|
|
||||||
|
public void silenceExec(boolean b) {
|
||||||
|
silentExec += (b ? 1 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
public void resumeBlocking() {
|
public void resumeBlocking() {
|
||||||
blocking++;
|
blocking++;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +94,10 @@ public class SecurityMan extends SecurityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow && blocking == 0)
|
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);
|
else throw new SecurityException("BCV is awesome, blocking(" + blocking + ") exec " + cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue