javassist 报错 ; is missing
在通过javassist 编写的时候,主要代码如下:
String code = "for (String aa : tt){....}";
启动后报
Exception in thread "main" javassist.CannotCompileException: [source error] ; is missing at javassist.CtNewMethod.make(CtNewMethod.java:84) at javassist.CtNewMethod.make(CtNewMethod.java:50) at javassist.CtMethod.make(CtMethod.java:140) at com.summersec.attack.deser.echo.AllEcho.genPayload(AllEcho.java:25) at com.summersec.attack.deser.util.Gadgets.createTemplatesImpl(Gadgets.java:65) at com.summersec.attack.deser.util.Gadgets.createTemplatesImpl(Gadgets.java:57) at com.summersec.attack.deser.echo.AllEcho.main(AllEcho.java:36) Caused by: compile error: ; is missing at javassist.compiler.Parser.parseDeclarators(Parser.java:643) at javassist.compiler.Parser.parseDeclarationOrExpression(Parser.java:600) at javassist.compiler.Parser.parseFor(Parser.java:380) at javassist.compiler.Parser.parseStatement(Parser.java:279) at javassist.compiler.Parser.parseBlock(Parser.java:307) at javassist.compiler.Parser.parseStatement(Parser.java:261) at javassist.compiler.Parser.parseDo(Parser.java:351) at javassist.compiler.Parser.parseStatement(Parser.java:277) at javassist.compiler.Parser.parseBlock(Parser.java:307) at javassist.compiler.Parser.parseMethod2(Parser.java:172) at javassist.compiler.Javac.compileMethod(Javac.java:156) at javassist.compiler.Javac.compile(Javac.java:102) at javassist.CtNewMethod.make(CtNewMethod.java:79) ... 6 more
多方搜索也没找到原因,最后在 github 上找到结果,原来javassit不支持 for 循环,使用while后不在报错
参考:github.com