-2

I have made a simple auth using html and java script with a button to submit the password

  function verify() {
checkpass = document.getElementById("pass").value;
if (md5(checkpass) == "03318769a5ee1354f7479acc69755e7c") {
  alert("Correct!");
  document.location="./aebe515f7c62b96ad7de047c11aa3228.html";
}
else {
  alert("Incorrect password");
}

}


and have already imported the md5.js you can view the page here http://okabdo.16mb.com/

The prob is when I press Log int it refresh the page and it doesn't show any message in alert !!

aouakki
  • 310
  • 5
  • 16

1 Answers1

1

You are getting a javascript error in the MD5 javascript file.

It fails to provide a utf8_encoding method.

I grabbed the one from here: http://blog.shiguenori.com/2009/04/13/utf8_encode-em-javascript/

I also changed the password to "testing" As i had no idea what yours was pre-encoding.

 window.verify = function() {       
     checkpass = document.getElementById("pass").value;
     if (md5(checkpass) == "ae2b1fca515949e5d54fb22b8ed95575") {
         alert("Correct!");
         document.location = "./aebe515f7c62b96ad7de047c11aa3228.html";
     } else {
         alert("Incorrect password");
     }
     return false;
 }
 
 window.utf8_encode = function( string ) {
 
    string = (string+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0;
 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);
        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if((c1 > 127) && (c1 < 2048)) {
            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc != null) {
            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;
        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);
    }
 
    return utftext;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://okabdo.16mb.com/md5.js"></script>
<div style="position:relative; padding:5px;top:50px; left:38%; width:350px; height:140px; background-color:red">
<div style="text-align:center">
    <p>Welcome to the Secure Login Server.</p>
    <p>Please enter your credentials to proceed</p>
    <form action="index.html" method="post">
        <input type="password" id="pass" size="8" />
        <br/>
        <input type="submit" value="Log in" onclick="verify();return false;" />
    </form>
</div>
</div>
  • Still have the same problem it's not about encoding – aouakki Oct 29 '14 at 16:39
  • The md5 plugin you are using has a note at the top of it. // depends on: utf8_encode. It is throwing a javascript error which means your return false never gets called. If you include the above encoding, the md5 script wont error and the page will not submit. Does the snippet not work for you? what browser are you using? – Anthony Roberts Oct 30 '14 at 02:24
  • It doesn't work and it throw on the console " Uncaught TypeError: undefined is not a function md5.js:126md5 md5.js:126verify (index):13onclick (index):32 " I test on chrome & FireFox – aouakki Oct 31 '14 at 22:03