Community discussions

MikroTik App
 
User avatar
hecklertm
Member Candidate
Member Candidate
Topic Author
Posts: 165
Joined: Fri Jun 24, 2005 5:12 am
Location: US

Password Encryption using md5.js

Wed Jul 20, 2005 4:51 am

Hi,

I uploaded md5.js to my webserver and copied an example hotspot config from a post in the archives. I am not poficient with Javascipt, so I played around with the syntax for a few hours, and I am still getting the error that the "router will not accept unencrypted passwords".

If I did set the router to accept unencrypted passwords, my test html file look like:

<html>
<title>After questions - login page</title>
<body>

This is a page that would include the hidden username and/or password which would be fed to the router after questions were answered
<form name="sendin" action="http://10.10.10.1/login" method="post">
<input type="hidden" name="user" value="Ex">
<input type="hidden" name="password" value="Ex">
<input type="hidden" name="domain" value="">
<input type="hidden" name="dst" value="http://www.misgroupinc.com/">
<br>
<input type="submit" name="login" value="Go to the Internet">
</form>

</body>
</html>


Since I want to use the md5 hashing, could anyone who has done this before, please post an example of what html I would use to accomplish the example above, but with the MD5 hashed password?

Much thanks in advance.
 
User avatar
hecklertm
Member Candidate
Member Candidate
Topic Author
Posts: 165
Joined: Fri Jun 24, 2005 5:12 am
Location: US

Fri Jul 22, 2005 8:46 am

The example posted in the archived post called "Hotspot Javascript Encyption Example" did in fact work correctly once I first tried to use it without modifying it. Then I just put my test user "Ex" and password in and it was fine. I suppose when I tried it the first time I changed too much info and inadvertantly missed something..

Thanks to ADAVIS who was nice enough to post this the first time...

Here is the actual test script I used on my webserver. Change "YOURIP" to the IP address of your MT router. The <username> and <password> is the test user I entered in my MT, and the <dst> (not required) is the destination that the user is sent to after they login instead of the MT status screen. There is also a submit button which proves it works. If you embed this code in a dynamic webpage served by a database then the submit button would not be needed since the code would execute upon an action in the application.
[color=green]
<script language="JavaScript" src="/md5.js">
</script>

<form name="sendin" action="http://YOURIP/login" method="post">
<input type="hidden" name="user" value="Ex">
<input type="hidden" name="password" value="Ex">
<input type="hidden" name="popup">
<input type="hidden" name="popup-present" value="true">
<input type="hidden" name="domain" value="">
<input type="hidden" name="dst" value="http://www.google.com/">
<input type="submit" name="login" value="Login">
</form>

<script language="JavaScript">

  function doLogin() {
    if (document.login.popup.value == 'true' || document.login.popup.value == 'false') {
      document.sendin.popup.value = document.login.popup.value;
    }
    else {
      document.sendin.popup.value = document.login.popup.checked;
    }
    document.sendin.user.value = document.login.user.value;
    var frmXXX = document.login.elements['domain'];
    if (frmXXX) {
      document.sendin.domain.value = document.login.domain.value;
    }
    document.sendin.password.value = hexMD5('\130' + document.login.password.value + '\142\004\003\132\264\003\100\344\226\202\355\325\136\304\070\355');
    document.sendin.submit();
  }

</script>[/color]
Thanks again to ADAVIS for the old post of the js example...

Who is online

Users browsing this forum: Bing [Bot], rizkirinaldisyamsuri and 28 guests