Saving username/password - TP-Link Routers

Talk about code development, features, specific bugzilla bugs, enhancements, patches, and other highly technical things.

Moderator: satrow

Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific referenced Bugzilla bugs, mercurial, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Most "bug reports" do not belong in this board and should initially be posted in Community Support or other relevant support boards.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
dr_st
Apollo supporter
Apollo supporter
Posts: 43
Joined: Wed, 15 Oct 2014, 18:18

Saving username/password - TP-Link Routers

Unread postby dr_st » Sat, 13 Jan 2018, 10:57

Edit:Sorry, realized this probably should go in forum 13 (feature requests).

Someone with experience using TP-Link wireless router products may have noticed that in recent years they changed the login prompt to their routers' web interface. Previously it used to pop-up a standard "Enter username/password" dialog window, and Pale Moon would offer to save these credentials. In recent firmware versions they changed to a non-standard login/password page, which does not seem to be a proper "form", hence the browser does not ask to save credentials (and does not use them if saved credentials exist).

I've checked the previous threads were similar issues were discussed - viewtopic.php?f=3&t=15825 and viewtopic.php?f=57&t=15784, but the workaround suggested there (using Saved Password Editor extension) did not work for me, as the extension also failed to detect the non-standard login fields. However, the AutoFill addon works.

When I first encountered this TP-Link login issue, about a year ago, no browser I tried could save the credentials. It still does not work on Chrome 49, or Firefox 43. However, Chrome 63 and Firefox 52 do succeed in detecting the login fields and save the username/password. So I hope it can somehow be added in Pale Moon as well.

Following is the full code of the TP-Link login page for the router I have. I hope it is useful in figuring out why credentials storage does not work, and, hopefully, what can be done to make it work natively in the browser (without extensions). It would seem like too specific an issue to bother, if it was just the router web interface, but it's probably relevant to other websites as well (otherwise Mozilla/Google would not have bothered to implement it).

Code: Select all

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>TL-WR1043ND</title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="wed, 26 Feb 1997 08:21:57 GMT">
<script language="javascript" type="text/javascript"><!--
//--></script>
<script language="javascript" type="text/javascript">
var httpAutErrorArray = new Array(
4,
0,0 );
</script>
<script language="javascript" type="text/javascript">
var fileParaFS = new Array(
"", "CIBVCFPCJKBQEPHB*?4CIBVCFPCJKBQEPHB*?4",
0,0 );
</script>
<script type="text/javascript">var gCmp=fileParaFS[0];var gSession=fileParaFS[1];</script>

<style type="text/css">
body{
   font-family:Arial, sans-serief;
   background-color:#E5E5E5;
   margin:0px;
   padding:0px;
}
div.loginBox
{
   display: block;
   position:relative;
   margin-top:10%;   
   text-align:center;
}
.noteDiv{
   color:gray;
   font-family:Arial;
   width:395px;
   text-align:left;
   margin:0px auto;
   font-size:14px;
}
#note{
   display:inline-block;
   vertical-align:top;
   _display:inline;
   _zoom:1;
   width:50px;
   font-weight:bold;
}
#tip{
   display:inline-block;
   vertical-align:top;
   _display:inline;
   _zoom:1;
   width:340px;
   font-weight:regular;
}
div.panelThre{
   margin-top:10px;
}
div.picDiv{
   width:395px;
   height:276px;
   background:url(../login/loginbg.png);
   position:relative;
}
input.pcPassword{
   width:300px;
   height:50px;
   line-height:50px;
   padding-left:20px;
}
div.PCBtnDiv{
   position:relative;
   margin-top:20px;
}
img.logoPic{
   width:100%;
}
#copyright{
   -webkit-text-size-adjust:none;
   font-size:8px;
   color:#6a6969;
   font-family:"Verdana";
   font-weight:regular;
   margin-top:40px;
   display:inline-block;
}
.topLogo{
   background:url(../login/top_bg.jpg);
   height:90px;
}
.style1 {
   font-family: "Arial";
   color: #FFFFFF;
   font-size: 16px;
   padding-right: 50;
   text-align: right;
   font-weight: bold;
   white-space: nowrap;
}
.style2 {
   font-size: 12px;
   font-family: "Arial";
   font-weight: bold;
   padding-right: 50;
   text-align: right;
   white-space: nowrap;
   color: #FFFFFF;
}
ul{
   padding:60px 0px 0px 0px;
   margin:0px;
   list-style:none;
}
ul li{
   height:34px;
   width:222px;
}
li.unLi{
   background:url(../login/loginUserH.png);
}
li.pwLi{
   background:url(../login/loginPwd.png);
}
li.blank{
   height:15px;
}
input.text{
   border:0px;
   height:26px;
   line-height:26px;
   width:175px;
   padding:0px;
   margin:4px 0px 0px 40px;
   font-size:14px;
   color:#6a6969;
   font-family:"Verdana","Arial";
   font-weight:regular;
}
label.loginBtn{
   height:34px;
   display:inline-block;
   width:113px;
   margin-top:30px;
   background:url(../login/loginBtn.png);
   cursor:pointer
}
</style>
<script type="text/javascript">
function Base64Encoding(input)
{
   var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
   var output = "";
   var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
   var i = 0;

   input = utf8_encode(input);

   while (i < input.length)
   {

      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output +
      keyStr.charAt(enc1) + keyStr.charAt(enc2) +
      keyStr.charAt(enc3) + keyStr.charAt(enc4);

   }
 
   return output;
}

function utf8_encode (string)
{
   string = string.replace(/\r\n/g,"\n");
   var utftext = "";

   for (var n = 0; n < string.length; n++) {

      var c = string.charCodeAt(n);

      if (c < 128) {
         utftext += String.fromCharCode(c);
      }
      else if((c > 127) && (c < 2048)) {
         utftext += String.fromCharCode((c >> 6) | 192);
         utftext += String.fromCharCode((c & 63) | 128);
      }
      else {
         utftext += String.fromCharCode((c >> 12) | 224);
         utftext += String.fromCharCode(((c >> 6) & 63) | 128);
         utftext += String.fromCharCode((c & 63) | 128);
      }

   }

   return utftext;
}

function CheckUserPsw(szElementName)
{
   var obj = $(szElementName);
   var szValue = $(szElementName).value;
   
   if(szValue.length == 0)
   {
      return false;
   }

   var c;
   var ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";

   for (var i = 0; i < szValue.length; i++)
   {
      c = szValue.charAt(i);
      if (ch.indexOf(c) == -1)
      {
         return false;
      }
   }
   return true;
}

function PCWin(event)
{   
   if (event.keyCode == 13)
   {
      PCSubWin();
   }
}
function ResetUserPsw(elementName)
{
   $(elementName).value = "";
   $(elementName).focus();
}
function PCSubWin()
{

   if(isLocked == true)
   {
      return;
   }
      
   if(!CheckUserPsw("userName"))
   {
      $("note").innerHTML = "NOTE:";
      $("tip").innerHTML = "The username should only consist of letters, numbers or quotation marks.";
      $("userName").value = "";
      $("userName").focus();
      return;
   }
   
   if(!CheckUserPsw("pcPassword"))
   {
      $("note").innerHTML = "NOTE:";
      $("tip").innerHTML = "The password should only consist of letters, numbers or quotation marks.";
      $("pcPassword").value = "";
      $("pcPassword").focus();
      return;
   }

    var auth;
   var password = $("pcPassword").value;
   var userName = $("userName").value;

   auth = "Basic "+Base64Encoding(userName+":"+password);

   document.cookie = "Authorization="+escape(auth)+";path=/";

   location.href = "/";
}

var isLocked = false;
function w(str)
{
   document.write(str);
}

function $(id)
{
   return document.getElementById(id);
}

function pageLoad()
{
   var count = 14, tip = $("tip"), tipStr="", note = $("note");
   
   var min = 0, sec = 0;
   var unLi = $("unLi");
   var pwLi = $("pwLi");
   var userName = $("userName");
   var pcPassword = $("pcPassword");
   
   pcPassword.onfocus = function(){
      pwLi.style.background = "url(../login/loginPwdH.png)";
   };
   pcPassword.onblur = function(){
      pwLi.style.background = "url(../login/loginPwd.png)";
   };
   userName.onfocus = function(){
      unLi.style.background = "url(../login/loginUserH.png)";
   };
   userName.onblur = function(){
      unLi.style.background = "url(../login/loginUser.png)";
   };
   
   userName.focus();
   /* set tip */

   var ErrNum = httpAutErrorArray[0];
   switch(ErrNum)
   {
      case 0:/* deny */
         note.innerHTML = "NOTE:";
         tip.innerHTML = "The router allows only one administrator to login at the same time, please try again later.";   
      break;
      case 2:/* lock */
         isLocked = true;
         
         count = 180;
         note.innerHTML = "NOTE:";
         tipStr = "You have exceeded three attempts, please try again in ";      
         tip.innerHTML = tipStr + "180s.";
         
         /* set timeout func */
         window.setTimeout(function(){      
            if (count <= 1)
            {
               isLocked = false;
               tip.innerHTML = "";
               note.innerHTML = "";
               return;
            }      
            count--;
            tip.innerHTML = tipStr + count + "s.";   
            window.setTimeout(arguments.callee, 1000);
         }, 1000);      
      break;
      case 3:/* auth error */
         note.innerHTML = "NOTE:";
         tip.innerHTML = "The username or password is incorrect, please input again.";
      break;
      case 4:/* no error */
      case 1:/* timeout */
      default:
         tip.innerHTML = "";
         note.innerHTML = "";
      break;
   }
}
</script>
</head>
<body _adv_already_used="true" onkeypress="PCWin(event)" onload="pageLoad()">
   <div class="topLogo">
      <table cellpadding="0" cellspacing="0" width="100%">
         <tbody><tr><td><table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tbody><tr><td><a href="http://www.tp-link.com" target="blank"><img src="../login/top1_1.jpg" style="cursor:pointer" border="0"></a></td>
            <td style="padding-top:23" align="right" background="../login/top1_2.jpg" width="490">
               <table>
                  <tbody><tr><td class="style1">300M Wireless N Gigabit Router</td></tr>
                  <tr><td class="style2"> Model No. TL-WR1043ND </td></tr>
               </tbody></table>
            </td>
         </tr>
         </tbody></table></td></tr>
      <tr><td><img src="../login/top2.jpg" align="top" border="0" height="3" width="100%"></td></tr>
      </tbody></table>
   </div>
   <div class="loginBox">   
      <div class="noteDiv">
         <span id="note"></span>
         <span id="tip"></span>
      </div>
      <div class="panelThre" align="center">
         <div class="picDiv" align="center">
            <ul>
               <li style="background: transparent url(&quot;../login/loginUser.png&quot;) repeat scroll 0% 0%;" id="unLi" class="unLi"><input class="text" id="userName" maxlength="14" type="input"></li>
               <li class="blank"></li>
               <li style="background: transparent url(&quot;../login/loginPwd.png&quot;) repeat scroll 0% 0%;" id="pwLi" class="pwLi"><input class="text" id="pcPassword" maxlength="14" type="password"></li>
            </ul>
            <label id="loginBtn" class="loginBtn" onclick="PCSubWin()"></label>
            <div>
            <label id="copyright">Copyright © 2013 TP-LINK Technologies Co., Ltd. All rights reserved. </label>         
            </div>
         </div>
      </div>
   </div>

</body></html>
Last edited by dr_st on Sat, 13 Jan 2018, 15:24, edited 1 time in total.

Return to “Development (discussion)”

Who is online

Users browsing this forum: No registered users and 3 guests