Page 1 of 1

Generating hotspot passwords and sending them via sms

Posted: Fri Feb 13, 2015 12:06 pm
by eagle1610
Hello to all

I have wireless network in my company where is guest network using Mikrotik hotspot. Now we try to build User friendly password generation
and we thought abaut sms sending passwords to our costumers.
Is there any chance to do it with user manager in mikrotik?


thank you

Re: Generating hotspot passwords and sending them via sms

Posted: Thu Feb 26, 2015 1:14 pm
by samir494
here is the sample of working code

/tool sms set receive-enabled=yes

:local smsPhone
:local smsMessage

delay 2;

:foreach i in=[/tool sms inbox find] do={

#Password generation
:local date [/system clock get time]

:local hour [:pick $date 0 2]
:local min [:pick $date 3 5]
:local sec [:pick $date 6 8]

:local pass 27394

:set pass ($hour * $min * $sec)

:if ($pass = 0) do {
:set pass 6524
}

:log info $pass
:log info $date
#End password generation

:set smsPhone [/tool sms inbox get $i phone];

:log info $smsPhone

#Create voucher
/tool user-manager user remove [/tool user-manager user find username=$smsPhone]

:log info "2"

/tool user-manager user add customer=admin disabled=no name=$smsPhone password=$pass shared-users=1 phone=$smsPhone

:log info "3"

#TODO set profile!!!!
/tool user-manager user create-and-activate-profile user=$smsPhone customer=admin profile=hour

:log info "4"

#End create voucher

:set smsMessage "Login: $smsPhone Password: $pass"

:log info $smsMessage

:if ([:len $smsPhone]>10) do {
/tool sms send usb3 $smsPhone message="$smsMessage"
}

:log info "5"

/tool sms inbox remove $i

:log info "6"

delay 10

}

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Mar 31, 2015 11:33 pm
by kpc
hi mr samir
can i have your email address?
my email is amirreza.keshvari@gmail.com.

i have hotspot on my network,i want guest insert mobile number in text box and click submit buttom and system auto send username and password to that mobile number,
please help me

Re: Generating hotspot passwords and sending them via sms

Posted: Mon Apr 20, 2015 12:12 am
by cardlinux
here is the sample of working code

/tool sms set receive-enabled=yes

:local smsPhone
:local smsMessage

delay 2;

:foreach i in=[/tool sms inbox find] do={

#Password generation
:local date [/system clock get time]

:local hour [:pick $date 0 2]
:local min [:pick $date 3 5]
:local sec [:pick $date 6 8]

:local pass 27394

:set pass ($hour * $min * $sec)

:if ($pass = 0) do {
:set pass 6524
}

:log info $pass
:log info $date
#End password generation

:set smsPhone [/tool sms inbox get $i phone];

:log info $smsPhone

#Create voucher
/tool user-manager user remove [/tool user-manager user find username=$smsPhone]

:log info "2"

/tool user-manager user add customer=admin disabled=no name=$smsPhone password=$pass shared-users=1 phone=$smsPhone

:log info "3"

#TODO set profile!!!!
/tool user-manager user create-and-activate-profile user=$smsPhone customer=admin profile=hour

:log info "4"

#End create voucher

:set smsMessage "Login: $smsPhone Password: $pass"

:log info $smsMessage

:if ([:len $smsPhone]>10) do {
/tool sms send usb3 $smsPhone message="$smsMessage"
}

:log info "5"

/tool sms inbox remove $i

:log info "6"

delay 10

}
Thats ok script. But ruter has SMS option only for one "allowed number". Does have some another option in this script for generate usernames?

Re: Generating hotspot passwords and sending them via sms

Posted: Wed Jun 17, 2015 11:31 am
by meateron
any ideas how to make:

1. HotSpot welcome page telling you to enter your phone number
2. You enter your phone number, press "submit"
3. You recieve sms and enter a password to a field "access code"?

Re: Generating hotspot passwords and sending them via sms

Posted: Wed Nov 25, 2015 8:36 pm
by videolab
To save the cost of SMS to the user, you may have corresponding phone number to login and the message text to be chosen as a password.
Auto activation!

Re: Generating hotspot passwords and sending them via sms

Posted: Wed Dec 02, 2015 3:59 am
by Nagobi
Have a nice day Samir!

I see your script and i think this what i want, can you help me? i want authorization via sms (generated and send voucher via usb modem).

1 - User connect to Hotspot
2 - See login page
3 - Write his number in to login page and press submit button
4 - Receive password via sms and login with him
5 - Phone number write in log to disk with date&time authorization

Sorry for my English, i study now)

my email: nagobi@icloud.com
my Skype: posians

Re: Generating hotspot passwords and sending them via sms

Posted: Fri Jan 29, 2016 5:22 pm
by rajeshrouthu
Recently We done the SMS Solutions for Mikrotik Hotspot using the radius

1. User Connected to FREE-WIFI AP
2. When he trying to browse automatically redirected to Login Page
3. He Registered himself entering their mobile Number and name
4. He will get OTP for Authorization after success
5. He will Get the SMS of Username and Password with 30 Min Free usage
6. After that he need to refill using Recharge Coupon or Payment Gateway.

Re: Generating hotspot passwords and sending them via sms

Posted: Fri Jan 29, 2016 7:18 pm
by Nagobi
Good news!

How you can do it? sms send via usb stick in mikrotik or another service? captive portal hosting on mikrotik or another place?

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Feb 02, 2016 11:40 am
by rajeshrouthu
Good news!

How you can do it? sms send via usb stick in mikrotik or another service? captive portal hosting on mikrotik or another place?

Developed using with freeradius Server, captive portal & SMS Every thing work from the same server

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Feb 02, 2016 1:39 pm
by bax
Good news!

How you can do it? sms send via usb stick in mikrotik or another service? captive portal hosting on mikrotik or another place?

Developed using with freeradius Server, captive portal & SMS Every thing work from the same server
It will be very nice if you make some tutorial ... maybe on wiki :D

Re: Generating hotspot passwords and sending them via sms

Posted: Fri Feb 05, 2016 1:52 pm
by sopcwmkt
How do you run the script? by the scheduler?
Thanks.

Re: Generating hotspot passwords and sending them via sms

Posted: Sun Feb 07, 2016 7:09 am
by imagica
Yes am also interested in this solution. For SMS sending i want to use SMS gateway api.

Re: Generating hotspot passwords and sending them via sms

Posted: Mon May 30, 2016 9:54 am
by mosesjohann
something new on this thing? Would be interested too

Re: Generating hotspot passwords and sending them via sms

Posted: Wed Jun 08, 2016 5:14 pm
by para2ox
could you please give me this script ?
i need the users enter their mobile No. and get their generated password through SMS,
i know that the GSM modem is needed.
how can i do that ?

Re: Generating hotspot passwords and sending them via sms

Posted: Fri Sep 16, 2016 3:53 am
by eevee147
Recently We done the SMS Solutions for Mikrotik Hotspot using the radius

1. User Connected to FREE-WIFI AP
2. When he trying to browse automatically redirected to Login Page
3. He Registered himself entering their mobile Number and name
4. He will get OTP for Authorization after success
5. He will Get the SMS of Username and Password with 30 Min Free usage
6. After that he need to refill using Recharge Coupon or Payment Gateway.
Hello, i´m interested, can you tell me more about it and cost please?.

Re: Generating hotspot passwords and sending them via sms

Posted: Sun Oct 09, 2016 7:59 pm
by Too001
Hi,
How can one get the code(cost). Can you also integrate other forms of payment to the system. Thanks

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Oct 11, 2016 9:20 pm
by czolo
We have something similiar. We are sending a link in SMS. User click on the link, and a web browser autheticate him into the system. Of course there is possibility to collect phone numbers and use it for operators data retention.

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Dec 13, 2016 11:47 am
by rajeev0047
It seems #rajeshrouthu just showing up to us what he did. didn't come for help. I am looking for this solution too. Any guys can help??

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Jan 31, 2017 4:53 pm
by elitebb
It seems #rajeshrouthu just showing up to us what he did. didn't come for help. I am looking for this solution too. Any guys can help??
Yes , I think he did great research for what he did or paid someone who know how to do that . You can find some solution on internet or find someone .

Re: Generating hotspot passwords and sending them via sms

Posted: Mon Feb 13, 2017 6:15 am
by dante
I started to solve this problem too. And I have an idea how to solve it without Radius.
1 the user enters a number and clicks a button (submit)
2 the system does not find that user. writes in the log error "login failed" to mention user not authenticated.
3 script parses the log file or memory for an error of this type, and as soon as sees it, generates a password and sends an sms and adds the user to the hotspot
4 at this time the user opens the field to enter your code and come sms. The following authorization is successful!

Now the question guru. as a means mikrotik script to extract a substring of specified length from the file or memory knowing the context?
If this is not possible, you can write syslog server to another. Then, analyze it and send commands to mikrotik

Re: Generating hotspot passwords and sending them via sms

Posted: Fri Mar 10, 2017 5:25 pm
by OKNET
Any progress in this topic ???

Very interested in self-authentication by SMS

Re: Generating hotspot passwords and sending them via sms

Posted: Tue Apr 25, 2017 12:56 pm
by dante
Oh sure. At the moment the script is working in test mode and is being finalized in accordance with the needs for a particular solution. At the moment the script has this view:
#Phone number detekt
:global marker "script started";
:global content [/file get [/file find name=loghotspot.0.txt] contents];
/file remove loghotspot;
:set marker "loghotspot deleted";
:global pos [:find $content "login failed" 0];
:set marker "search position finished";
:if ($pos != "") do={
#####################################
:global uname "";
:global phone "";
:if ([:pick $content ($pos-29)] = " ") do={
:set uname [:pick $content ($pos-28) ($pos-18)];
:set phone "8$uname";
}
:if ([:pick $content ($pos-29)] = "7") do={
:if ([:pick $content ($pos-30)] = "+") do={
:set uname [:pick $content ($pos-30) ($pos-18)];
:set phone "$uname";
} else={
:set uname [:pick $content ($pos-29) ($pos-18)];
:set phone "+$uname";
}
}
:if ([:pick $content ($pos-29)] = "8") do={
:set uname [:pick $content ($pos-29) ($pos-18)];
:set phone "$uname";
}
#####################################
:global ipaddr [:pick $content ($pos-16) ($pos-3)];
:set marker "position fined and variables set";
:if ([ip hotspot user find name=$uname]="") do={
:if ([ip hotspot user find address=$ipaddr]!="") do={
/ip hotspot user remove [find address=$ipaddr];
:set marker "clean ipaddr";
}
#Password generation
:local date [/system clock get time]
:local hour [:pick $date 0 2]
:local min [:pick $date 3 5]
:local sec [:pick $date 6 8]
:global pass 27394
:set pass ($hour * $min * $sec)
:set marker "password generated";
:if ($pass = 0) do {
:set pass 6524
}
#Add user
:global ts [/system clock get time]
:global ds [/system clock get date]
:global dt "$ds-$ts"
:set marker "before add user";
/ip hotspot user add name=$uname address=$ipaddr password=$pass comment=$ipaddr;
:set marker "after add user";
/tool sms send usb2 "$phone" message="$pass"
:set marker "added user and send sms";
}
:if ([ip hotspot user get [find name=$uname] address]!=$ipaddr) do={
/ip hotspot user set address=$ipaddr [find name=$uname];
}
:set $pos "";
:set marker "reset position";
}
Note that the ip address must have a fixed length. Otherwise, there will be difficulties in retrieving the phone number from the logs.

Re: Generating hotspot passwords and sending them via sms

Posted: Sat Jul 01, 2017 6:13 pm
by ydfkensai
@Dante

Did u get the final solution?
Need some help.

Thx

Re: Generating hotspot passwords and sending them via sms

Posted: Sun Jul 08, 2018 3:51 pm
by waeel
Did u get the final solution?

Re: Generating hotspot passwords and sending them via sms

Posted: Wed Sep 18, 2019 5:00 am
by reyvilla93
any ideas how to make:

1. HotSpot welcome page telling you to enter your phone number
2. You enter your phone number, press "submit"
3. You recieve sms and enter a password to a field "access code"?
Do you have any solution for that yet?

Re: Generating hotspot passwords and sending them via sms

Posted: Thu Sep 10, 2020 3:20 pm
by waeel
any ideas how to make:

1. HotSpot welcome page telling you to enter your phone number
2. You enter your phone number, press "submit"
3. You recieve sms and enter a password to a field "access code"?

any update