'Code for mikrotik router hotspot auto login page

Guys can any one help me to make an auto login script for my local mikrotik router hotspot login page ?? I had tried in vbscript but it only post values in username and password fields,it was not loging me in.. code in VBscript:

             On Error Resume Next

             Const PAGE_LOADED = 4

            Set objIE = CreateObject("InternetExplorer.Application")

              Call objIE.Navigate("http://172.168.1.1")

        objIE.Visible = True

        Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop

         objIE.Document.login.username.Value = "myusername"

        objIE.Document.login.Password.Value = "mypassword"

             If Err.Number <> 0 Then

               msgbox "Error: " & err.Description

                  End If

                   Call objIE.Document.login.page1.submit

                     Set objIE = Nothing

-thanks in advance..

The form code is as follow:

       <body id="page1">

      <form action="./-BCM AIRWAY'S-Login-_files/-BCM AIRWAY'S-Login-.htm" method="post" name="sendin" class="style12">
        <input type="hidden" name="username">
        <input type="hidden" name="password">
        <input type="hidden" name="oip" value="172.16.122.60">
        <input type="hidden" name="dst" value="">
        <input type="hidden" name="popup" value="true">
      </form>
      <p class="style12">
        <script language="JavaScript" src="./-BCM AIRWAY'S-Login-_files/md5.js">
        </script>
        <script language="JavaScript">
<!--
    function doLogin() {
    document.sendin.username.value = document.login.username.value;
    document.sendin.password.value = hexMD5('\357' + document.login.password.value + '\341\163\162\346\336\173\167\142\250\161\200\257\201\316\345\055');
    document.sendin.oip.value=document.login.oip.value;
    document.sendin.submit();
    return false;
    }
//-->
        </script>
      <span class="style16"> </span></p>
      <p class="style12">&nbsp;</p>
    </div>
    <p class="style16">        </p>
    <p class="style9">&nbsp;</p>
    <p class="style9">&nbsp;</p>
    <p class="style10">Enter User Name and Password </p>
    <form name="login" action="./-BCM AIRWAY'S-Login-_files/-BCM AIRWAY'S-Login-.htm" method="post" onsubmit="return doLogin()">
      <input type="hidden" name="dst2" value="">
      <input type="hidden" name="popup2" value="true">
       <input type="hidden" name="oip" value="172.16.122.60">
      <p> 
        <label><span class="style11">UserName:</span></label>
        <input name="username" value="" type="text" size="34">
        <label> <br>
         <span class="style11">Password </span>: </label>
        <input name="password" value="" type="password" size="34">
        &nbsp;<span class="align-center"> 
        <input name="submit" type="submit" class="button" value="Enter">
        </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
      <p>             <span class="style11">Always type user name in lowercase</span></p>

      <p><strong><a id="forgotLnk" href="http://172.16.120.1/contact.html">I cannot access my account.</a>&nbsp;<br>
      </strong></p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
    </form>
  </div>


    </body></html>


Solution 1:[1]


You can use TemperMonkey in Chrome or GreaseMonkey in Firefox. Then use jQuery libraby for DOM manipulation.

$("input[type=text]").val('myusername');
$("input[type=password]").val('mypassword');
$("form").submit();

Remember, this script block must be present after the HTML block.

Comment if you have any doubt.

Thank You...

Solution 2:[2]

I have found the error in my code finally and this is the working VBscript Code for mikrotik router hotspot auto login...

            On Error Resume Next

            Const PAGE_LOADED = 4

            Set objIE = CreateObject("InternetExplorer.Application")

            Call objIE.Navigate("http://172.168.120.1")

            objIE.Visible = True

            Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop

            objIE.Document.login.username.Value = "myusername"

            objIE.Document.login.Password.Value = "mypassword"

            If Err.Number <> 0 Then

            msgbox "Error: " & err.Description

            End If

            Call objIE.Document.login.onsubmit("return doLogin()")

            Set objIE = Nothing

I thing it may help many users who have same issue...... -thankQ

Solution 3:[3]

if you want to use javascript then here is my simple answer Mikrotik Hotspot / Captive Portal Auto-Login after X seconds

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bhupendra Pandey
Solution 2 Ram
Solution 3 Waqas Shakeel