cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

command over sms

10171
Views
5
Helpful
24
Comments

Attached policy provides CLI access to the Cisco 4G router over text messaging.   Two files are in the attached .tar file:

1.  commandoversms.tcl

2.  PDF with instructions on how to load and use the .tcl file.

Comments
Daniel Frey
Cisco Employee

Hi @Andreas Foerby 

Thank you for the feedback.   I can see where this feature would be useful.   I have added version 3.1 of this script to deny user configurable CLI commands over SMS.   Users can make a list of CLI commands in the router CLI by executing this command:  "event manager environment denysms "list of deny commands, separated by comma"
 
 

example "event manager environment denysms "write erase, configure"

 

This takes regular expression pattern as well so same line could be written as

"event manager environment denysms "wr[a-z]+ er[a-z]+, conf[a-z]+"

Andreas Foerby
Beginner

Hi @Daniel Frey 

 

Thanks for quick response! 

I have uploadet the new version to the router, removed the old one and I did run a few tests.. 

It do catch the "denysms" and sends it to the console, but it is also executing the commands.. 

Se below: 

 

event manager environment removeprefix 45
event manager environment whitelist (XXXXXXXX)|(XXXXXXXX)
event manager environment denysms "conf[a-z]+ ter[a-z]+, wr[a-z]+ er[a-z]+"
event manager directory user policy "flash:/"
event manager policy commandoversms3-1.tcl type user

Jul 1 18:33:47.025: Cellular0: New SMS received on index 4 . Please issue a view command to see it
Jul 1 18:33:48.577: %HA_EM-6-LOG: commandoversms3-1.tcl: received SMS from XXXXXXXX : Wr erase
Jul 1 18:33:48.625: %HA_EM-6-LOG: commandoversms3-1.tcl: denysms variable exists
Jul 1 18:33:48.645: %HA_EM-6-LOG: commandoversms3-1.tcl: sms-cmd: Wr erase
Jul 1 18:33:53.261: %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
Jul 1 18:33:53.693: %HA_EM-6-LOG: commandoversms3-1.tcl: SMS sent = RTR# Erase of nvram: complete [OK] Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
Jul 1 18:33:53.693: %HA_EM-6-LOG: commandoversms3-1.tcl: ---------------------------------------------------------------------------------------
Jul 1 18:33:54.161: sms_delete_by_id, msg_id = 7 message_index = 4
Jul 1 18:33:54.337: %HA_EM-6-LOG: commandoversms3-1.tcl: Successfully deleted SMS message 4 from SIM
Jul 1 18:33:54.553: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.
Jul 1 18:33:54.553: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0 has just sent an outgoing SMS successfully.

Daniel Frey
Cisco Employee

I believe this is because the command sent did not match the regular expression.  You sent "Wr erase" and your regexp is "wr[a-z]+ er[a-z]+ .   Regexp [a-z]+ means one or more in the range of a-z.   It will match on "Wr" but nothing is matching on [a-z]+ so regexp did not match.   Two ways to address this condition.

 

1.   Change regexp to "w[a-z]+ er[a-z]+" and send same SMS syntax.   

2.  Keep regexp the same but send "Wri erase".    The "i" will meet the requirement of one or more for [a-z]+.

 

 

 

Andreas Foerby
Beginner

Hi @Daniel Frey 

 

You nailed it..! 

 

I changed the regexp to:

- event manager environment denysms "conf t, con[a-z]+ t[a-z]+, w[a-z]+ e[a-z]+" 

 

Thank you for your time and help on this! 

 

/Andreas Foerby

zia.u.abid
Beginner

I upgraded the IOS to 159-3.M this script stopped working. Any help is greatly appreciated.

Daniel Frey
Cisco Employee

Can you provide some details of what is not working, log messages, ect....    I just loaded 15.9.3M and its working for me.

C819-Tmobile#

*Dec  9 18:19:17.523: Cellular0: New SMS received on index 1 . Please issue a view command to see it

*Dec  9 18:19:17.523: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Dec  9 18:19:18.623: %HA_EM-6-LOG: commandoversms3-1.tcl: received SMS from XXXXXXXXX : Show clock

*Dec  9 18:19:18.639: %HA_EM-6-LOG: commandoversms3-1.tcl: denysms variable exists

*Dec  9 18:19:18.655: %HA_EM-6-LOG: commandoversms3-1.tcl: sms-cmd: Show clock

*Dec  9 18:19:18.899: %HA_EM-6-LOG: commandoversms3-1.tcl: SMS sent = C819-XXXXXX# C819-Tmobile# *14:19:18.663 EDT Mon Dec 9 2019

*Dec  9 18:19:18.899: %HA_EM-6-LOG: commandoversms3-1.tcl: ---------------------------------------------------------------------------------------

*Dec  9 18:19:19.135: sms_delete_by_id, msg_id = 0 message_index = 1

*Dec  9 18:19:19.203: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Dec  9 18:19:19.203: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0 has just sent an outgoing SMS successfully.

*Dec  9 18:19:19.243: %HA_EM-6-LOG: commandoversms3-1.tcl: Successfully deleted SMS message 1 from SIM

C819-Tmobile#

C819-Tmobile#

C819-Tmobile#show ver

Cisco IOS Software, C800 Software (C800-UNIVERSALK9-M), Version 15.9(3)M, RELEASE SOFTWARE (fc5)

Technical Support: http://www.cisco.com/techsupport

Copyright (c) 1986-2019 by Cisco Systems, Inc.

Compiled Tue 13-Aug-19 17:42 by prod_rel_team

 

dimitentas
Beginner

Hello Daniel,

 

Many Thanks for the script and support.

We have an IR807 with 159-3.M2. When i i am sending sms to reload i have this output 

 

*Oct 23 14:53:07.900: %HA_EM-6-LOG: commandoversms3-1.tcl: received SMS from 947 : Reload

It says 947 instead of my mobile number.

 

Addition to this i have this output on ftp:

 

***Incoming SMS to archived at 17:53:06 EEDT Fri Oct 23 2020
TIME: 20-10-23 16:47:33
FROM: 947B9FD3D6E41
TO:
SIZE: 6
Reload

 

Any ideas?

Thank  you in advance

 

Daniel Frey
Cisco Employee

 dimitentas,

The "FROM" field has to be all numbers.

dimitentas
Beginner

So may it is something from mobile provider?