Community discussions

MikroTik App
 
User avatar
Świętopełek
newbie
Topic Author
Posts: 32
Joined: Sat Nov 26, 2022 12:33 am

[request] option to disable "secret" SMS protection

Mon Nov 28, 2022 11:11 pm

Hi,

I'd like to configure RouterOS to act as a simple SMS > Email forwarding gateway.
Everything seems to be already there, as it is possible to trigger scripts with SMS (like shown on most recent video https://youtu.be/Cv8yEb9MyCY).
Unfortunately the "secret" restriction prevents that functionality from working for all unknown / external mobile numbers.

Would you be so kind as to consider adding an option, to completely disable "secret" protection?
Currently the only alternative I'm familiar with is to use a specialized SMS gateway device, like for example SMSEagle (it has "Email to SMS" option). But I would really prefer to use MikroTik instead.

Thank you!
Last edited by Świętopełek on Tue Nov 29, 2022 12:11 pm, edited 1 time in total.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: [request] option to disable "allowed-number" SMS restriction

Tue Nov 29, 2022 9:06 am

So what's wrong with not expanding and setting the "allowed number" field? If It's not set, then it will accept (and run script) for SMSes from any number. Also video has a caption saying "you can" at around 1:00 ...

If you already have set "allowed number", then close those entries by clicking up-arrow on right side of each value field until all are closed.
 
User avatar
Świętopełek
newbie
Topic Author
Posts: 32
Joined: Sat Nov 26, 2022 12:33 am

Re: [request] option to disable "allowed-number" SMS restriction

Tue Nov 29, 2022 12:10 pm

So what's wrong with not expanding and setting the "allowed number" field?
I think you are right and "allowed-number" is indeed optional.

However, it appears that the "secret" is not (documentation says the secret password, mandatory). I will edit the original post and change the topic accordingly.

My goal is to create a SMS > Email forwarding configuration allowing all numbers -- whatever someone sends via SMS, will be forwarded to email. So that people don't need to know that they are sending SMS to router. It should just work for everyone, including external SMS authentication services.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 12:40 pm

I didn't understand why you need to remove "secret" when the router can receive any SMS...
Simply "secret" is used to execute commands, not to simply receive one SMS...
 
User avatar
Świętopełek
newbie
Topic Author
Posts: 32
Joined: Sat Nov 26, 2022 12:33 am

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 1:21 pm

Ok, but once it receives SMS, then what next?
I mean, I need to trigger a script that will forward it to e-mail

Just to get some idea, here is how the configuration looks in a SMS gateway:
"useless" screenshot: https://i.imgur.com/Ug43D5U.jpeg
Last edited by Świętopełek on Tue Nov 29, 2022 2:44 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 1:36 pm

"others do this", "others do that"... the mikrotik product is neither this nor that.

This is the xyproblem, you are looking for a solution based on your beliefs and your mistakes (such as not entering the number or not entering the password),
instead of directly requesting a solution for the final purpose (sending the received SMS via e- email).

Your idea is wrong and screenshots from other products are completely useless.
Probably somewhere in the forum there is already a script to schedule
to automatically check if there are new SMS and then send them via email.
I won't do the search on forum for you, but if for some reason that script doesn't already exist, any "feature requests" are perfectly useless.
Write your own script to do this.
 
User avatar
Świętopełek
newbie
Topic Author
Posts: 32
Joined: Sat Nov 26, 2022 12:33 am

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 2:40 pm

to automatically check if there are new SMS
Yes, there are plenty of scripts.
I'm requesting exactly what I described. The possibility to trigger a script from any unknown number.
I don't want to automatically check if there are new SMS. I want the SMS to trigger the script once the message is delivered.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 6:59 pm

Guess what: modem doesn't notify host about newly arrived SMS, it only says so if host interrogates it. Since scripting is pretty decent in ROS, it's not necessary for MT devs to add a job polling modem, you can do it from script and run it from scheduler.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: [request] option to disable "secret" SMS protection

Tue Nov 29, 2022 9:27 pm

The script below sends each received SMS message to Telegram and removes it from the input buffer if successful. You have to use a scheduler to run it every minute or so.
:local token "0000000000:AAAAAAAAAAAAAAAAAAAAAAAAAAA"
:local chatId "-11111111"

:local escapeUrl do={
  :local sourceString $1
  :local outputString ""

  :local escapeTable {
    " "="+";  "\$"="%24"; "%"="%25"; "&"="%26"; "+"="%2b"; ","="%2c"; "/"="%2f"; ":"="%3a";
    ";"="%3b"; "="="%3d"; "?"="%3f"; "@"="%40"; "["="%5b"; "\"="%5c"; "^"="%5e"; "]"="%5d";
    "`"="%60"; "{"="%7b"; "|"="%7c"; "}"="%7d"
  }
  :for i from=0 to=[len $sourceString] do={
    :local symbol [:pick $sourceString $i]
    :local substitute ($escapeTable->$symbol)
    :if ([:typeof $substitute]="nothing") do={
      set substitute $symbol
    }
    :set outputString ($outputString . $substitute)
  }
  :return $outputString
}

:local success 1
/tool sms inbox {
  :while (([:len [find]] > 0) and ($success = 1)) do={
    :local smsList [find]
    :local timestamp [$escapeUrl [get ($smsList->0) timestamp]]
    :local phone [$escapeUrl [get ($smsList->0) phone]]
    :local message [$escapeUrl [get ($smsList->0) message]]
    :local msgText "At+$timestamp,+the+router+has+received+the+following+message+from+$phone%3a%0a$message"
    :do command={
      /tool fetch url="https://api.telegram.org/bot$token/sendMessage\?chat_id=$chatId&text=$msgText" output=none
    } on-error={:set success 0}
    :if ($success=1) do={remove ($smsList->0)}
  }
}
 
User avatar
Świętopełek
newbie
Topic Author
Posts: 32
Joined: Sat Nov 26, 2022 12:33 am

Re: [request] option to disable "secret" SMS protection

Wed Nov 30, 2022 1:52 am

Yes, I get your point, but please try to understand my point of view as well.

We already have a functionality that triggers the script precisely when SMS is received, correct? Now let's say I would like to "SMS > Email" external SMS authentication services (like any kind of 2FA services based on SMS confirmation). Why would I want to poll the router every now end then for that? Even 10 second unnecessary lag is just pure annoyance. Instead I would like to use the existing functionality that triggers the "SMS > Email" script precisely when SMS is received. The only "obstacle" is that the "secret" field is mandatory. Just please make it optional. That's it.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: [request] option to disable "secret" SMS protection

Wed Nov 30, 2022 9:03 am

I also get your point, and I would myself also like to see many more trigger events you could hook script execution to than those currently available, but:
  • you can schedule the script to be executed every second, the router has enough CPU power to do that; if even that is not sufficient, you can let the script run permanently and put your own loop into it with even more frequent polling. RouterOS does not poll the modem for new SMSes, it subscribes for notifications, so the script polls just the internal buffer, so you won't block the communication channel between the modem and the main CPU even by polling for message appearance 10 times per second.
  • Mikrotik R&D has a very long todo list that contains features that cannot be achieved through scripting and prevent many users from buying new device models because these only support RouterOS 7 and RouterOS 7 does not support some necessary features that do work in RouterOS 6.
  • starting a separate topic on this forum is not the correct channel to issue feature requests. There is a dedicated forum topic created by Mikrotik staff for that, and there's the support e-mail and JIRA web interface. Mikrotik staff does not monitor every single post on the forum, they are busy enough dealing with support tickets. The forum is intended to let more experienced users help less experienced ones with configuration and other stuff that does not require R&D to be involved.

Who is online

Users browsing this forum: Ahrefs [Bot], rplant and 75 guests