Simple Web 0x23(Lab - XXE)
tags: NTUSTWS
CTF
Web
Challenge: http://h4ck3r.quest:8604/
Background
XML Tree XML Parser AJAX - Server Response XML DTD
php://input可以读取没有处理过的POST数据。
php://input 取得所有的 input 通常來源於 HTTP body,值得注意的是,由這個 Stream 取得的內容是 Raw Body,所以需要自行解析。
來自外部的威脅-XXE漏洞攻擊成因
:::spoiler XXE course lecture
:::
:::spoiler exploit type
:::
Source code
<?php
$xmlfile = urldecode(file_get_contents('php://input'));
if (!$xmlfile) die(show_source(__FILE__));
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
$creds = simplexml_import_dom($dom);
$user = $creds->user;
echo "You have logged in as user $user";
?>
Exploit - XXE
- Normal Usage in this webpage