使用MD5密码加密的C#登录网站

Logging in to website with C# with MD5 password encryption

我搜索了这个站点并找到了如何使用 C# 以编程方式登录网站。但是,这个特定站点在发送表单之前以某种方式加密了密码。

我使用 Firefox 的 Live HTTP Headers 窥探了几个 POSTs 并发现:

Account=[REDACTED]&pw=a0c41f57ef14e43642269bb1e452ae40
Account=[REDACTED]&pw=17fd04959cdf6f44b799221fb9a2e0e3

每次发送的密码都不同。

As I press login, I can see the password change in the form.

我看了一下页面源码,可能用的是"MD5 encryption",但是不知道怎么调用加密的函数,研究了也不知道为什么每次都变MD5.

函数如下:

function doLogin(form)
{
   var originalpw = form.pw.value;
   var b64pw = b64_md5(originalpw);
   var hmac_md5pw = hex_hmac_md5(pskey, b64pw)
   form.pw.value = hmac_md5pw;
   form.dbpw.value = hex_hmac_md5(pskey, originalpw.toLowerCase())
   if (form.ldappassword!=null) {
       // LDAP is enabled, so send the clear-text password
       // Customers should have SSL enabled if they are using LDAP
       form.ldappassword.value = originalpw; // Send the unmangled password
   }

return true;
}

编辑:

好的,现在我是 运行 javascript 使用 Noesis.Javascript。它工作得很好,但最后一件事是 "pskey" 变量。每次加载登录页面时它都会改变,我找到了它的位置,所以我可以从页面源代码对其进行正则表达式。

但是:

页面如何知道为 pskey 下载 html 代码的 Web 客户端与发送 POST 登录并获取登录页面的客户端相同?

我有这些要求:

如何为每个使用相同的 WebClient?

Javascript 可以在 C# 中使用 Javascript.Net.

运行
using Noesis.Javascript;

//...

string runJavascript(string str){
    using (JavascriptContext context = new JavascriptContext())
    {
        //Set external variables:
        context.SetParameter("var", str);
        context.Run("function jsFunc(s) { //encode in here } str2 = jsFunc(var)");
        Console.WriteLine(context.GetParameter("str2"));
        return context.GetParameter("str2").ToString();
    }
}