Search code examples
c#user-interfacewebformshttpwebrequesthttpwebresponse

Trying to find how a specific 32 hex character webform is generated from Netgear Managed Switch local UI webpage


I am trying to simulate navigating Netgear Managed Switch (GC108PP) local UI webpage in C#. When sending HttpWebRequest using a Chrome browser, I've learned using Fiddler - there are 3 WebForms that are generated when hitting this URL:

http://192.168.50.101

ends up being:

http://192.168.50.101/cgi/get.cgi?cmd=home_login&dummy=1582137153063&bj4=3f104a21e12a9584d36372142f16e35b

WebForms:

  1. cmd=home_login

  2. dummy=1582137153063 (time since epoch, this one was easy to figure out)

  3. bj4=3f104a21e12a9584d36372142f16e35b (trying to figure out how to generate this one)

There is no HTTP API to reference from Netgear. I have tried just generating a 32 char string with:

private static Random random = new Random();
public static string randomString(int length)
{
    const string chars = "abcdef0123456789";
    return new string(Enumerable.Repeat(chars, length).Select(s =>s[random.Next(s.Length)]).ToArray());
}

However, I get ERROR 400 Bad Request.If I use a bj4 key/ID that gets generated by my browser statically in my code it works, but I want to be generating this webform properly.

Any ideas on how this WebForm might be be generated?


Solution

  • Found it in the JS...

    function gotoLogin()
    {
      document.cookie = \"testcookie\";
      cookieEnabled = (document.cookie.indexOf(\"testcookie\") != -1) ? true : false;
      if (cookieEnabled == false)
      {
        alert(\"Browser does not accept cookies. Please configure your browser to accept cookies in order to access the Web Interface.\");
      }
    
      var fileVer = (new Date().getTime());
      var url = \"login.html?aj4=\"+fileVer;
      url = url + '&bj4=' + md5(url.split('?')[1]); //here!!!
      window.location.href=url;
    }