Azure CloudService解码RDP用户的密码

Ale*_*rov 0 rdp credentials azure

我在Azure中丢失了RDP密码.但我有cscfg文件和加密密码的证书.我如何从cscfg文件中获取密码?

Ale*_*rov 6

function DecodePassword([string] $encodedPassword)
{
    $encodedMessage = [Convert]::FromBase64String($encodedPassword);
    $cms = New-Object System.Security.Cryptography.Pkcs.EnvelopedCms;
    $cms.Decode($encodedMessage);

    $store = $null;
    try
    {
        $store = New-Object System.Security.Cryptography.X509Certificates.X509Store('My', 'CurrentUser');
        $cms.Decrypt($store.Certificates);
    }
    finally
    {
        $store.Close();
    }

    return [Text.Encoding]::UTF8.GetString($cms.ContentInfo.Content);
}
Run Code Online (Sandbox Code Playgroud)