Generating hotspot passwords and sending them via sms

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

Any progress in this topic ???

Very interested in self-authentication by SMS

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.

@Dante

Did u get the final solution?
Need some help.

Thx

Did u get the final solution?

Do you have any solution for that yet?

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

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”?

Could someone tell me how to create the login page with the key to enter the phone number?

I built my own self-hosted captive portal for MikroTik RouterOS 7 that does exactly this: guests enter their phone number, get a one-time code by SMS (Clickatell or any SMS gateway via webhook), and access is enforced through RADIUS. It also supports voucher codes, Telegram/Gotify approval and social login.

It’s still beta (:edge). Tested so far:

  • Portal container on Docker in a VM
  • RouterOS x86 as hotspot router (RADIUS client)
  • Chateau 5G as hotspot router with local guest Wi-Fi
  • Guest SSID via CAPsMAN

Running the container directly on RouterOS is supported but not tested yet.

More info: https://portal.helminet.ch

If you test it, please send me your feedback as a GitHub issue: Issues · helmi1987/guest-portal-helminet · GitHub