JSB '19 - P2
View as PDF
Submit solution
Points:
7
Time limit:
2.5s
Memory limit:
64M
Author:
Problem type
Allowed languages
Java
Please call the method flag() in the class Secret.
Download the Java agent here.
Download the source code of the agent here.
You can test locally using the command java -javaagent:p2_agent.jar YourClass.
Source Code
File: Agent.java
import java.lang.instrument.*;
import java.lang.reflect.ReflectPermission;
import java.security.ProtectionDomain;
import java.security.*;
class Secret {
private void flag() {
System.out.println("CTF-00000000000000000000000000000000");
}
};
public class Agent {
public static void premain(final String agentArgs, final Instrumentation inst) {
System.setSecurityManager(new SecurityManager() {
public void checkPermission(Permission perm) {
if (perm instanceof ReflectPermission) {
Class[] ctx = getClassContext();
// allow non-submitted classes to use reflection
if (ctx[ctx.length - 1].getPackage() == null) {
System.exit(7);
}
}
}
});
}
}
Comments