解密“加密”的文件ASP.NET 2.0 会员密码

发布于 2024-11-13 10:58:13 字数 754 浏览 2 评论 0原文

我需要解密位于我的 aspnet_Membership 表中的加密(非哈希)密码。在该数据库中,我看到了“密码(已加密)”和“PasswordSalt”字段,并且我可以查看我的 web.config 以找到 machinekey >解密密钥(验证=“SHA1”解密=“AES”)。

注意:我很想使用哈希密码,但出于商业原因,我需要能够使用会员的密码,以便 SSO 进出其他远程系统,因此使用加密(绝对不使用清除 - yukky! )

考虑到所有这些,肯定有一种方法可以将密码检索为清晰、纯文本和可读文本,即解密,但我在找到任何网站或在 stackoverflow 上回答时遇到了真正的麻烦(我正在寻找此处的所有“类似问题”和“具有类似标题的问题”)解释了如何做到这一点。

我找到了 MembershipProvider.DecryptPassword Method 页面,但我仍然无法弄清楚如何在我的代码中实际使用它。我还通过 Google 找到了其他页面,但大多数密码解密示例似乎都没有考虑 salt 和 decryptionKey。

有没有人有从各自位置选择密码、密码盐和解密密钥并使用它们解密 ASP.NET 2.0 会员加密密码的直接示例?

I have a requirement to decrypt the Encrypted (not Hashed) passwords located in my aspnet_Membership table. In that database I see the Password (Encrypted) and PasswordSalt fields, and I can look at my web.config to find the machinekey > decryptionKey (validation="SHA1" decryption="AES").

note: I would love to use Hashed password, but for business reasons I need to be able to use the password for a Member, for SSO into and from other remote systems, hence using Encrypted (definitely NOT using Clear - yukky!)

Given all that, surely there is a way to retrieve the password as Clear, plain and readable text, i.e. decrypted, but I'm having real trouble finding any website, or answer on stackoverflow (and I'm looking at all the "similar questions" and "question with similar titles" here) that explains how this can be done.

I've found the MembershipProvider.DecryptPassword Method page, but I still cannot work out how to actually use this in my code. I've also found other pages, via Google, but most example of password decryption don't appear to take the salt and decrytionKey's into account.

Does anyone have a straight forward example of selecting the password, passwordsalt and decryptionkey from their respective locations, and using them to decypt an ASP.NET 2.0 Membership Encrypted password?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や三分注定 2024-11-20 10:58:13

创建一个继承自 SqlMembershipProvider 的类,并在其中调用解密。

您需要的所有代码都可以在 中找到纳文·科利 (Naveen Kohli) 的这篇文章

在查看reflector中的代码后,我发现微软
提供者分两步解密。加密后的密码实际上是一个
加密数据的Base64转换。所以首先它将它从
Base64然后调用DecryptPassword方法。我只做了最简单的
事物。复制了微软实现的代码,删除了所有
检查它正在做什么然后使用它。下面的课程是一个例子
从 SqlMembershipProvider 派生的类,其方法仅
返回给定加密密码的明文密码。

命名空间 MembershipPasswordRecover
{
    公共类 NetFourMembershipProvider :SqlMembershipProvider
    {
        公共字符串GetClearTextPassword(字符串加密密码)
        {
            byte[]encodedPassword = Convert.FromBase64String(encryptedPwd);
            byte[] bytes = this.DecryptPassword(encodedPassword);
            如果(字节==空)
            {
                返回空值;
            }
            返回 Encoding.Unicode.GetString(bytes, 0x10, bytes.Length - 0x10);

        }
    }
}

静态无效主(字符串[]参数)
{
    var 密码管理器 = new NetFourMembershipProvider();
    varclearPWd=passwordManager.GetClearTextPassword(“此处加密密码”);
    Console.WriteLine(clearPWd);
}

Create a class that inherits from SqlMembershipProvider and in it you can call the decrypt.

All the code you need for this can be found in this article by Naveen Kohli:

After looking through the code in reflector, I saw that Microsoft
providers decrypts in two steps. The encrypted password is actually a
Base64 conversion of encrypted data. So first it converts it back from
Base64 and then calls DecryptPassword method. I just did the easiest
thing. Copied the code from Microsoft implementation, removed all the
checks it was doing and then used it. Following class is an example of
a class derived form SqlMembershipProvider with a method that just
returns me password in clear text for a given encrypted password.

namespace MembershipPasswordRecover
{
    public class NetFourMembershipProvider : SqlMembershipProvider
    {
        public string GetClearTextPassword(string encryptedPwd)
        {
            byte[] encodedPassword = Convert.FromBase64String(encryptedPwd);
            byte[] bytes = this.DecryptPassword(encodedPassword);
            if (bytes == null)
            {
                return null;
            }
            return Encoding.Unicode.GetString(bytes, 0x10, bytes.Length - 0x10);

        }
    }
}

static void Main(string[] args)
{
    var passwordManager = new NetFourMembershipProvider();
    var clearPWd = passwordManager.GetClearTextPassword("encryptedpasswordhere");
    Console.WriteLine(clearPWd);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文