SMSCON

SMSCON provides complete control of your N900 by sending SMS commands to it. This is particularly handy in case you cannot find your phone, for example if it has been lost or even stolen. SMSCON is a two part Python script running in command-line;  and. is the command-line control part and  is the daemon (running in the background) part. The configuration file for all the user settings is in the  file.

SMSCON will also auto-load silently at boot, waiting for a special SMS command message in case you phone is lost (or even stolen).

SMSCON can't guarantee that you will find your phone again, but it will provide the maximum chance to recover it. If this application ever helps you to recover your phone please tell the story on Maemo.org! The best way is of course to never lose your phone or let it get stolen...

SMSCON Editor is a GUI helper application for SMSCON to set/edit user settings & control SMSCON.

SMSCON is intended for people who have experience with Python programming and/or the Linux commandline so you can adjust the application to their own needs.

WARNING: This application can send (multiple) SMS messages automatically (in the background). Be aware that SMS sending is *not free* and it's costs depends on the used telephone subscription with your Nokia device.

Functionality
SMSCON can:


 * autoload at boot (this is set by default during the installation of smscon package); when the device (re)boots it loads the  silently in the background.
 * create and keep a log file (on the device).
 * detect SIM card change; it will send the new SIM card phonenumber, IMSI code & telecom operator name to other known mobile number (through an SMS message). E.g. if somebody has stolen your phone and put his/hers own SIM card in it.
 * send current GPS location coordinates (returns user selectable SMS message or EMAIL with GoogleMaps picture with your phone's location on it).
 * reboot the phone; only works if your SIM card hasn't got a lock code.
 * shutdown the phone.
 * open a (reverse-)SSH connection to your own (home-)server (GPRS connection); control the phone at command-line level from your own home.
 * email a frontcam picture to your email address (GPRS connection) to maybe see where your phone is or who is using it.
 * send the current remaining battery charge (returns user selectable SMS/email message).
 * make the phone call you; you can listen where your phone is (returns phonecall)
 * lock the phone; nobody can use your phone anymore.
 * detect keyboard slider use; when somebody has found your phone and uses the keyboard. (only after one of the valid SMS commands is send to you phone) (returns user selectable SMS/email message)
 * send all valid SMS commands to you if you forgotten it (returns one or more user selectable SMS message and/or email message)
 * run a predefined shell script to start other programs, delete files etc.
 * run directly a shell command through SMS message sending.
 * turn the phone silent when SMSCON is set active with an SMS command.
 * send automatically SMS messages about the current battery status when SMSCON is set active with a SMS command.
 * use multiple SIM cards (the IMSI numbers are stored in  file)
 * play a sound file (only WAV) when SMS command is received (to localize your phone when lost). NEW IN 0.8.1
 * restart itself by SMS command. NEW IN 0.8.1
 * send a SMS/email message when it crashes. NEW IN 0.8.1
 * be triggered (activated) by changing the contents of a file on your own server. NEW IN 0.8.1

Installation
The SMSCON & SMSCON Editor packages can be found in the Extras repository and can be installed using the Application Manager (HAM).

Always install the latest stable version on your phone; previous version can have bugs and have less functionality!

SMSCON is written in Python and needs the following packages, besides python2.5, being installed on your device to operate (NOTE: they will be installed automatically by the HAM):

python-crypto python-gobject python-location python-dbus pexpect gstreamer-tools openssh-client openssh-server alsa-utils  /* NEEDED IN >= 0.8.1 */

The files  and   are placed by the installer in the   directory.

The installer will also generate a  file in   for autoloading at boot of the device.

Finally, SMSCON generates a default settings template file with all the user settings of SMSCON. It also creates a  file (for storing the current IMSI number of your inserted SIM card) and a   file (for running a custom user shell script). Finally a log file  will be created in   directory.

It's essential that the  file *must* be edited by SMSCON Editor or with commandline commands before use of SMSCON!''

Finally: if you want to use the SSH connection feature of SMSCON (i.e. 'Remoteon' and 'Remoteoff' commands), you also need a fixed IP address on your preconfigured remote server for the SSH (default port 22) connection.

Usage
SMSCON is triggered by a SMS message with a predefined known command and then will execute the task in the background. If so it will send a reply SMS or email with the information.

Commands
The (default) predefined commands are: Nokia-N900:~# smscon -sms COM_CHECK        = 'Check' COM_REBOOT       = 'Reboot' COM_POWEROFF     = 'Poweroff' COM_POWER        = 'Power' COM_LOCATION     = 'Location' COM_REMOTEON     = 'Remoteon' COM_REMOTEOFF    = 'Remoteoff' COM_CAMERA       = 'Camera' COM_CALL         = 'Call' COM_LOCK         = 'Lock' COM_UNLOCK       = 'Unlock' COM_TRACKON      = 'Trackon' COM_TRACKOFF     = 'Trackoff' COM_CUSTOM       = 'Script' COM_SHELL        = 'uptime >> /tmp/shell_log' COM_ALARM        = 'Alarm'   /* NEW IN 0.8.1 */ COM_RESTART      = 'Restart'  /* NEW IN 0.8.1 */

NOTE: These commands can be changed using the SMSCON Editor and also at the command-line with the  command (see SMSCON command-line options).


 * When sending 'Check' to you phone it sends one or more SMS messages with all the available SMSCON commands.
 * Sending 'Reboot' it will reboot your phone.
 * Sending 'Poweroff' is will shutdown your phone.
 * Sending 'Location' is will send it's current position by SMS or EMAIL (or both).
 * Sending 'Remoteon' it will enable the SSH connection to your (home-)server. 'Remoteoff' will kill the connection.
 * Sending 'Camera' will send a frontcam picture by email.
 * Sending 'Call' will call you.
 * Sending 'Lock' will lock the device, so nobody can use your phone. 'Unlock' will remove the device lock.
 * Sending 'Trackon' will continiously send SMS or email (or both) with location of the device & 'Trackoff' will disable this.
 * Sending 'Script' will run a predefined by user shell script.
 * Sending 'uptime >> /tmp/shell_log' (an example shell command) will exectute the shell command on your phone (no checks & output are returned!)
 * Sending 'Alarm' will play once a user selectable file (only WAV format and must be named  in   directory)   NEW IN 0.8.1
 * Sending 'Restart' will kill the smscon_daemon and restart it.  NEW IN 0.8.1

USAGE EXAMPLE:
 * To trigger any of the commands the phone should receive an SMS having in the subject its defined name. E.g. to trigger the  command the phone should receive:.
 * The commands can use spaces in them and can be altered in a command only you know what it is and what it means.
 * the alarm audio file (only WAV format and must be named ) must be placed, if the option is used, in  .   NEW IN 0.8.1
 * To trigger any of the commands by a remote file on your own server (when option ENABLECHECKHOST is enabled), the file only must contain one of the following values from 00, 01 to 17 or -1:

01 = COM_CHECK 02 = COM_REBOOT 03 = COM_POWEROFF 04 = COM_POWER 05 = COM_LOCATION 06 = COM_REMOTEON 07 = COM_REMOTEOFF 08 = COM_CAMERA 09 = COM_CALL 10 = COM_LOCK 11 = COM_UNLOCK 12 = COM_TRACKON 13 = COM_TRACKOFF 14 = COM_CUSTOM 15 = COM_SHELL 16 = COM_ALARM 17 = COM_RESTART

When value is 00 smscon_daemon will not be activated (normal situation) and when value is -1 the smscon_daemon will be restarted. It is of course necessary that the file on your server publically can be reached by your Nokia device, otherwise it won't work. Check this! The default CHECKTIME is 15 minutes (this can be changed by user), so when you change the content of your file it can take a maximum CHECKTIME minutes to execute the command. NEW IN 0.8.1

The user editable settings of the  file:


 * 1) smscon user settings (v0.8.1)
 * 2) (DO NOT edit the encrypted user settings below, use SMSCON-editor or SMSCON!)

SENDERNUMBER     = '+1234567890'
 * 1) SMS number

COM_CHECK        = 'Check' COM_REBOOT       = 'Reboot' COM_POWEROFF     = 'Poweroff' COM_POWER        = 'Power' COM_LOCATION     = 'Location' COM_REMOTEON     = 'Remoteon' COM_REMOTEOFF    = 'Remoteoff' COM_CAMERA       = 'Camera' COM_CALL         = 'Call' COM_LOCK         = 'Lock' COM_UNLOCK       = 'Unlock' COM_TRACKON      = 'Trackon' COM_TRACKOFF     = 'Trackoff' COM_CUSTOM       = 'Script' COM_SHELL        = 'uptime >> /tmp/commandlog' COM_ALARM        = 'Alarm'   /* NEW IN 0.8.1 */ COM_RESTART      = 'Restart'   /* NEW IN 0.8.1 */
 * 1) SMS commands

ENABLECHECKHOST  = 'no' CHECKHOST        = 'www.bla.com/filetocheck' CHECKTIME        = 15
 * 1) REMOTE command   /* NEW IN 0.8.1 */
 * 2) (check server file at remote host to trigger smscon: 'yes', 'no')
 * 1) (check host)
 * 1) (check interval in minutes)

EMAILADDRESS     = 'bla@bla.com' USER             = '' PASSWORD         = '' EMAILFROM        = 'bla@bla.com' MAILSERVER       = 'www.bla.com' MAILPORT         = 25
 * 1) Email settings
 * 1) (encrypted setting)
 * 1) (encrypted setting)

REMOTEHOST       = 'www.bla.com' REMOTEPORT       = 22 REMOTEUSER       = '' REMOTEPASSWORD   = ''
 * 1) SSH settings
 * 1) (encrypted setting)
 * 1) (encrypted setting)

MESSAGESEND      = 'sms' ENABLERESEND     = 'no' RESENDTIME       = 15
 * 1) Reply message settings
 * 2) (method to send reply messages: 'sms' / 'email' / 'both' / 'none')
 * 1) (enable resending of reply message after  minutes
 * 2)  until successful sending; 'yes' / 'no')
 * 1) (resend waiting time in minutes)

COMMANDREPLY     = 'no'
 * 1) Send acknowledge SMS
 * 2) (send acknowledge SMS after receiving valid SMS command: 'yes' / 'no')

KEYBOARDDETECT   = 'no'
 * 1) Detect keyboard use
 * 2) (send acknowledge SMS if keyboard is sliding: 'yes' / 'no')

AUTODEVICELOCK   = 'yes'
 * 1) Device lock
 * 2) (lock device after receiving valid SMS command: 'yes' / 'no')

AUTOBATREPORT    = 'no'
 * 1) Auto battery status SMS report
 * 2) (sends SMS when SMSCON is set active with a SMS command & battery
 * 3)  is depleting: 'yes' / 'no')

SIMUNLOCK        = 'no'
 * 1) Auto device unlock
 * 2) (unlocks device when new SIM is inserted; 'yes' / 'no')

SILENCEDEVICE    = 'no'
 * 1) Silence the phone
 * 2) (disable all phone sounds when SMSCON is set active with a SMS command: 'yes' / 'no')

GPSTIMEOUT       = 1800 GPSPOLLING       = 3 GPSINTERVAL      = 60 GPSSEND          = 'sms'
 * 1) GPS settings
 * 2) (if no GPS coordinates after  seconds then stop aquiring)
 * 1) (number of GPS coordinates to acquire and use the most accurate in "Location"-mode)
 * 1) (time between sending GPS coordinate SMS in "Trackon"-mode: 10 / 20 / 30 / 60 / 120)
 * 1) (method to send GPS coordinates: 'email' / 'sms' / 'both')

Options
The available command-line options for SMSCON are: Nokia-N900:~# smscon -help

smscon v0.8.1 - Nokia N900 remote control utility
Options: -start            : start smscon_daemon -restart          : stop & restart smscon_daemon -stop             : stop smscon_daemon -status           : get smscon_daemon status -log              : show log file -del log          : erase log file -sms              : show SMS commands -set name "value" : set user setting (name = "value") -config           : show config file -script           : show script file -boot             : start smscon_daemon at device boot -unboot           : remove start of smscon_daemon at device boot -add imsi         : add current IMSI code to code file -remove imsi      : remove current IMSI code from code file -help             : this help menu Special options (normally not needed!): -reset            : factory default (delete boot, config, code & script file) -imsi             : show IMSI code file -del imsi         : delete code file -init             : create default config & script file -del config       : delete config file -del script       : delete script file

After installation
After installation  will generate a new configuration file  which you *must* edit to your own needs (i.e. change all xxxxxxx's). To edit this use SMSCON Editor, which will assist in the configuration setup, or use the command-line  option. Also a shell script file will be generated were the user can predefine shell commands to run other programs, delete files etc.

SMSCON will also be installed to autoload at boot, this can be disabled with the command-line command  and re-enabled by   or with SMSCON Editor.

The first time you start SMSCON it loads the configured user settings file and is now active. then stores your valid IMSI code in a file if the file doesn't exist.

When later a new SIM card is inserted the new IMSI code is verified with the code in the stored  file. This is how the "SIM card change" will be detected.

Nokia-N900:~# smscon -start smscon_daemon started.

All user action and behavior of  will be logged in the log file (at  ):

Nokia-N900:~# smscon -log SMSCON INFO: - smscon_daemon is started & running - DAEMON INFO: successfully loaded "smscon_config" file DAEMON INFO: reading 1 valid IMSI code from "smscon_code" file DAEMON INFO: authorized IMSI code found DAEMON INFO: smscon auto-loads at boot

When having trouble with SMSCON always check the  file!

Remote SSH connection
When the (reverse-)SSH connection is made (default command 'Remoteon' / 'Remoteoff') you can from the server side (your own server) connect to your Nokia device with the following command:

ssh -p 8080 localhost -l root

0.8.1-4
Changelog
 * CHANGE: when upgrading from 0.7-2 the smscon_config file will be re-initialized due to changes in options/settings. When upgrading the 0.8 branch the smscon_config file will remain untouched (so no need to re-enter your settings). (Thanks Saturn from SMSCON-Editor!)

Issues
 * Using Wrong 3G connection when fMMS is installed (MMS connection instead)(unconfirmed by Vanvan)

0.8.1-3 (current extras-devel)
Changelog
 * CHANGE/FIX: bug in ENABLECHECKHOST option; would execute wrong command & updated wiki because of some changes. See WIKI/Usage!

Issues
 * Using Wrong 3G connection when fMMS is installed (MMS connection instead)(unconfirmed by Vanvan)

0.8.1-2
Changelog
 * MINOR FIX: removed debug line in smscon code.

Issues
 * Using Wrong 3G connection when fMMS is installed (MMS connection instead)(unconfirmed by Vanvan)

0.8.1-1
Changelog
 * FIX: shutdown & reboot routine (EnablePoweroff & EnableReboot) give internal error.
 * NEW/CHANGE: expanded user setting MESSAGESEND ('sms', 'email', 'both' & 'none')
 * CHANGE: Removed DISABLESMS user setting. This is superseded by MESSAGESEND user setting!
 * CHANGE: with unauthorized SIM card change, SMS always will be send regardless of MESSAGESEND setting.
 * NEW: added smscon command (RESTART); user can restart smscon_daemon by SMS command.
 * NEW: added smscon command (COM_ALARM); phone will play user configurable sound file (only WAV format and must be named  and placed in   directory) when command is received.
 * NEW: smscon_daemon sends SMS/email message if smscon_daemon crashes.
 * CHANGE: changed user setting ENABLERESEND ('yes', 'no'). Resending of messages will again be experimental feature!!!
 * CHANGE: removed MAXRESEND user setting (didn't work properly).
 * CHANGE: some log text changed/added.
 * CHANGE: removed updatechecker during installation of smscon (failed to work previously).
 * CHANGE: some changes in GPS message sending code.
 * CHANGE: AUTODEVICELOCK message is only send if COMMANDREPLY is enabled.
 * FIX: small bug in SMSsend.
 * FIX: bug in GPSINTERVAL handeling; GPSINTERVAL was always set at 60 sec. regardless of user setting.

Issues
 * Using Wrong 3G connection when fMMS is installed (MMS connection instead)(unconfirmed by Vanvan)

0.7-2 (current extras)
Changelog
 * FIX: bug in RestoreNetwork; restoring previous network could fail.
 * FIX: bug in CheckArguments; execution of shell script could fail.

Issues


 * Using Wrong 3G connection when fMMS is installed (MMS connection instead)(unconfirmed by Vanvan)

0.7-1
Changelog
 * NEW: multiple IMSI codes are allowed in smscon_code file; use new option "smscon -add imsi" to store current IMSI code in smscon_code file.
 * NEW: added new user option (DISABLESMS); WARNING: disables ALL SMS sending in smscon program.
 * NEW: added new smscon command (COM_SHELL); run directly shell commands. (no check & feedback from command!).
 * NEW: added new user option (SIMUNLOCK); auto unlock phone after new SIM is inserted (to fool a possible thief of your phone).
 * NEW: added new user option (SILENCEDEVICE); disable all phone sounds (email alert, IM alert, ringing alert & SMS alert) in current active profile, if smscon is activated. All volume levels are set to zero.
 * NEW/CHANGE: new user option (AUTOBATREPORT); user can enable/disable sending automatically a SMS message when smscon is activated & device battery is depleting.
 * CHANGE: when initializing a new smscon_config file all user settings wil be set default to 'no'.
 * REFACTORING: some parts in both scripts.
 * FIX: better number handeling in SMSrecieve routine (thanks to maemo.org user!).
 * FIX: small bug in GSMmodem in smscon_daemon script.
 * FIX: small text bug in smscon script.
 * EXPERIMENTAL/CHANGE: when smscon fails to send SMS message (no cell reception) it will retry after 900 seconds.
 * EXPERIMENTAL/FIX: change in getting the right GPRS connections; MMS & WAP will be discarded in available GPRS network list.

Known issues
 * Bug in RestoreNetwork; will be fixed in v0.7-2. (confirmed; thanks to Saturn)
 * Bug in CheckArguments; will be fixed in v0.7-2. (confirmed; thanks to Saturn)
 * Please test & report on SMSCON thread on forum.

0.5 & 0.4 branch

 * Don't use these anymore and update to 0.7 or 0.8 branch!

Future release

 * CHANGE: for encryption of user settings in  file, now secret code key is based on device serial number (no more predefined key in script); this enhances security.

Future development ideas
Feel free to add requests below.


 * Add a provision for SMS reception without the UI being notified (so that SMSCON control is silent).
 * saving all  user variables in gconf database. No need for   file anymore. (WONT IMPLEMENT)
 * add setting for user's country mobile number prefix.
 * add setting for alternative number (where alternative is a number sent a command and does not match the default) and option to choose where reply should be send, i.e. default number, alternative or both. Default number should not be replaced.
 * add setting to choose the default internet connection (WLAN, GPRS, or ANY). At the moment hardcoded to GPRS. (WONT FIX)
 * when the "Camera" command is sent, the process should wait for keyboard action to capture a picture and send the mail. In that way, there will be more chances to get better face portrait of the "new" user.
 * Add the ability to run custom commands (very useful, but especially needed to delete sensitive data from the phone). (IMPLEMENTED IN 0.5-9 / 0.7-1)
 * Add the ability to turn silent mode on. (IMPLEMENTED IN 0.7-1)
 * Application must be included in the ROM itself so that it cannot be removed. (CAN'T BE IMPLEMENTED)
 * Add a password so that no one else but the legitimate user can send an SMS to the phone and see where the phone is.
 * Auto remove the received sms from conversations.
 * Disable PhoneSpeakerSwitch on receipt of 'call' command.
 * EmailCON: check an specified email inbox, reading it with the program itself and not the built in default mail prog, at a given frequency, paying attention to commands written in the subject and/or body, acceptingg all the commands that are accepted via SMS. (WONT IMPLEMENT)
 * Improve handling of front camera to reduce the odds of crappy or plain blank black pictures being taken. (CAN'T BE IMPLEMENTED)
 * When in "stolen" mode, replace the front cam "recording" LED pattern with a on-lighting pattern for stealthiness.
 * Email, or post online somewhere you choose, any new photography taken with the main camera, geotagging whenever possible, preferably without showing any signs it's happenening (if possible with an option to redimension the picture before sending).

Testers needed
Please test this software, I like to hear if it works for you or not. Please post on forum. I only can test the software with two Vodafone SIM cards from The Netherlands, I want to know if it also works with other cards and networks in other countries...

License
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 only.

Disclaimer
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.