小编Cli*_*ker的帖子

使用Python对ASP.NET角色/成员资格创建的DB中的原始用户名,哈希,salt进行身份验证

我们有一个当前的应用程序,其中用户登录凭据存储在SQL Server数据库中.它们基本上存储为纯文本用户名,密码哈希以及此哈希的关联盐.

这些都是由ASP.NET的成员资格/角色系统中的内置函数创建的.以下是名为"joe"的用户和"password"密码的行:

乔,kDP0Py2QwEdJYtUX9cJABg ==,OJF6H4KdxFLgLu + oTDNFodCEfMA =

我已将这些内容转储到CSV文件中,我试图将其转换为Django的可用格式,它以这种格式存储密码:

[ALGO] $ [盐] $ [散列]

salt是普通字符串,哈希是SHA1哈希的十六进制摘要.

到目前为止,我已经能够确定ASP以base64格式存储这些哈希值和盐.上面的那些值解码成二进制字符串.

我们使用了反射器来收集ASP如何对这些值进行身份验证:

internal string EncodePassword(string pass, int passwordFormat, string salt)
{
    if (passwordFormat == 0)
    {
        return pass;
    }
    byte[] bytes = Encoding.Unicode.GetBytes(pass);
    byte[] src = Convert.FromBase64String(salt);
    byte[] dst = new byte[src.Length + bytes.Length];
    byte[] inArray = null;
    Buffer.BlockCopy(src, 0, dst, 0, src.Length);
    Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
    if (passwordFormat == 1)
    {
        HashAlgorithm algorithm = HashAlgorithm.Create(Membership.HashAlgorithmType);
        if ((algorithm == null) && Membership.IsHashAlgorithmFromMembershipConfig)
        {
            RuntimeConfig.GetAppConfig().Membership.ThrowHashAlgorithmException(); …
Run Code Online (Sandbox Code Playgroud)

python asp.net passwords hash

6
推荐指数
1
解决办法
4333
查看次数

标签 统计

asp.net ×1

hash ×1

passwords ×1

python ×1