Mikrotik Hotspot / Captive Portal Auto-Login after X seconds

BrownChiLD picture BrownChiLD · Feb 8, 2015 · Viewed 16k times · Source

Thinking about getting a mikrotik router for a small project ..

but I wanted to know if the following in any way possible w/ Mikrotik Hotspot feature?

  1. Users connecto to wifi w/o pass

  2. sees the captive portal w/ ads (basically a website remotely hosted) for x seconds

  3. then user is allowed internet access (redirected to google.com)

So basically what i need to do is:

  1. Make microtik allow internet traffic to, and load, a remote webpage as its captive portal (mypage.com/captivePortal.php)
  2. Disallow internet traffic to anything else until x number of seconds, or better yet, when my page triggers the approval
  3. User is then allowed internet access

Going thru the docs I can't find anything about "wait time" for the hotspot feature... But I was thinking it would be nice if I could simply code the captive portal website w/ javascript timeout that would call a function that triggers the Mikrotik router to allow access..

Now since I don't think there's any exposed/public methods i could call that would tell the router to "OK allow access now" on the specific user viewing the Portal, perhaps i could set 1 user/pass for all guests of the router, then have a hidden form of user/pass pre-filled in.. and then have javascript trigger "submit form" when I'm ready?

How am I doing so far? Would love to be guided....

Answer

Waqas Shakeel picture Waqas Shakeel · Feb 8, 2015

You have to create(or you can download from internet) hotspot folder in MikroTik, and in login.html

	<form action="http://10.5.50.1/login" method="post">  //http://10.5.50.1 your server ip
		<input type="hidden" name="username" value="admin" />
		<input type="hidden" name="password" />
		<input type="hidden" name="dst" value="www.yourwebsite.com" />
		<input type="hidden" name="popup" value="false" />
		<button type="submit">Continue</button>
	</form>

<script type="text/javascript">
function doLogin() 
{
 document.sendin.username.value = document.login.username.value;
 document.sendin.password.value = 
 hexMD5('\011\373\054\364\002\233\266\263\270\373\173\323\234\313\365\337\356');
 document.sendin.submit();
}
</script>

run this function on document load it will automatically logged in and will redirect you to this given address in form on this page you can show advertisment for 5 seconds and after 5 second redirect to google.com