SMSCON

'''Please Note: Update for 0.9.13++ is in progress for this page but will take another couple of days. The section "Usage" still needs updates...'''. -- yablacky 23:44, 14 January 2012 (UTC)

Introduction
SMSCON provides complete control of your N900 by sending SMS commands to it. Other methods are supported as well - we come this is later - but SMS is easiest way and it is the reason why this app is named SMSCON.

Remote controlling your phone is particularly handy in case you cannot find it, for example if it has been lost or even stolen. The first approach to find the phone is giving it a usual phone call awaiting to hear it ringing somewhere in your coat-pocket or the like. If this doesn't help, SMSCON comes into play. 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 to configure and even test SMSCON operation. We recommend normal users of the phone to use SMSCON Editor. Note that this is a separate application that installs additionally to SMSCOM.

Configuring SMSCON without SMSCON Editor is possible but you need some experience in unix command line. As almost ever, the command line offers maximum possibilities to adjust the application to your 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. Sending many SMS might be a minor problem for those having a SMS-flat-rate...

General

 * Looking for commands in received SMS messages.
 * Asking a remote command server for commands (available only if you setup and maintained such a server).
 * Sending notifications, responses and query results by SMS and/or by EMAIL.
 * Send help about all currently recognized SMS commands, e.g. if you've forgotten them. This way you need just to remember the code of one single command (the COM_CHECK command).
 * Supports use of multiple SIM cards.
 * Detect SIM card change. It will send a notification containing the new SIM card's phone number, IMSI code & telecom operator name. This scenario happens if your phone's finder or thief replaces your SIM by his/hers own SIM card.
 * Optionally turn the phone silent on receiving a known command.
 * Stores personal settings encrypted.

Locating the phone

 * Send notification about current GPS location coordinates via SMS message and/or EMAIL. Those EMAIL have even attached a GoogleMaps picture with your phone's location on it.
 * Track the phone's GPS location and location changes by let it automatically send repeated notifications in a selectable time interval.
 * Let front camera take pictures and send them via email notification. With a some luck you may see where your phone is or who is using it.
 * Let the phone make a voice call to your controlling phone. Once the call is established you can listen where your phone is.
 * Play a pre- and user-defined sound file (only WAV supported). May be used instead of just let the phone ring and let it say a special message.

Locking and Unlocking

 * Optionally lock the phone on receiving any known command.
 * Explicitly lock the phone by command. Nobody can use your locked phone until it receives an unlock command (as long unlock code is unknown, of course).
 * Optionally unlock the phone on detection of SIM card change. -- Why unlocking? Well, unlocking makes sense when regular phone owner is more interested on finding the actual device than as keeping its private/sensitive phone data protected/locked. A locked phone prevents even to enter the SIM card PIN. Consequently telephone functions do not work either. This is very secure but makes it almost impossible to contact the phone after booting with unknown SIM card installed. Note that a finder may remove the SD-memory card to read its content.

Direct control

 * Run directly a pre-defined shell command through SMS message where command output is immediately reported.
 * Run a pre-defined (and user-configurable) shell script to start other programs, delete files etc. May be used to wipe out sensitive data from phone. Direct wipe commands are not provided by SMSCON. Writing (and testing) a script doing so is at your own risk.
 * Open a (reverse-)SSH connection to your own (home-)server to control the phone at command-line level from your own home (or any other) computer.

Automatic notifications

 * Detect changing battery charge level and send notification about that.
 * Detect keyboard slider movement and send notification about that. Keyboard usage might indicate that somebody has found your phone.

System

 * Autoloads at boot. This ensures that SMSCON is active (that means is listening for commands) even after device (re)boot. Autoload is enabled by default during installation of a SMSCON package.
 * Create and keep a log file on the device. The log file can be queried remotely by SMS command as well as locally via command line.
 * Reboot the phone. Albeit this is possible it is not generally recommended if your SIM card has a PIN: If nobody enters the PIN correctly, the phone would boot but could not connect to GPRS network.
 * Shutdown the phone. Also just possible but not generally recommended.
 * Stop & restart SMSCON activity by SMS command. On trouble, this might be preferred operation instead of rebooting the phone.
 * Send notifications if SMSCON crashes on activity. Should this ever happen, you're encouraged to forward them to the SMSCON developer team (make a bug report).

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

Where to get from
The latest stable versions are available in the Extras repository and can be installed simply using the phones Application Manager (HAM). Therefore, in HAM ensure Extras repository is enabled then open the "ALL" category and search for "smscon".

Alternatively the packages can be found here: SMSCON and there: SMSCON Editor.

If you are willing to try unstable versions and help testing the application, consider to install packages from here: SMSCON Releases and there: SMSCON Editor Releases. Be warned.

Installation details
On very first installation, SMSCON generates


 * a default settings file with all the user settings of SMSCON.
 * an IMSI database to store IMSI numbers of SIM cards allowed. Other SIM cards will cause detection of SIM card change and optionally unlock of the device on boot.
 * a default  file with example code for COM_CUSTOM command.
 * a default  file for COM_ALARM command.
 * a SMSCON logfile.
 * a  command for use on unix command line.

On installation of update versions (since 0.9.*), SMSCON


 * updates the settings file to disable obsolete settings.
 * updates the settings file to add new settings.
 * leaves IMSI database untouched.
 * leaves  file untouched.
 * leaves  file untouched.
 * tries to repair previous SMSCON installation.
 * adds entries to SMSCON logfile.
 * updates the  command.

Before using SMSCON the first time
It is highly recommended to review all user settings and adjust them to your needs. Since this is a lot for the first time, there are two important things for you to setup (no must but recommended):
 * The so-called master number
 * All the EMAIL settings to enable SMSCON to send EMAIL notifications.

The master number is a phone number, namely the phone number of the main controlling phone. It can but should not be number of your N900 being controlled - this would be nonsense. It can also be left empty if you don't want to use the functionality that master-number offers. Best choice is to use the number of a second phone in your phone-portfolio. The number of your boy- or girlfriend's phone also does. No matter if that is a N900 as well.

Controlling your N900 is not restricted to the master number's phone. Any phone in the world can be used to send controlling SMS to your N900 and SMSCON sends SMS responses to it. One role of master numbers's phone is to receive a blind copy of all SMS that SMSCON sends to other phones.

Another role of master number comes into play if you start to control your N900 using different methods than SMS. We come to that later.

Last not least, the master number serves as a kind of password for some functions. This is also the case if you leave the master number empty. Then the password is just the empty password.

We recommend use of SMSCON Editor to review and change settings. Alternatively use the  command on unix command line.

Setting the master number

 * A typo-aware way to set the master number to a particular phone's number is using SMSCON Editor version 0.9.8 or higher and it goes like this:


 * 1) Open SMSCON Editor, ensure daemon runs, quit SMSCON Editor.
 * 2) From the particular phone, send a command to your N900. The default SMS message text for COM_CHECK is just   (note upper/lower case letters!).
 * 3) Wait until your N900 received that SMS.
 * 4) Again open SMSCON Editor go to "General" settings page.
 * 5) Enter the "last sender" number exactly as shown in the "master number" field above.
 * 6) Close "General" settings page and quit SMSCON Editor


 * Set master number directly:

$ smscon -set MASTERNUMBER +xxyyyyyyyyyy    # or $ smscon -set MASTERNUMBER "" # no master number
 * 1) Open SMSCON Editor go to "General" settings page, fill in "master number" field. Leave the field empty if you don't want to use master-number features.
 * 2) Alternativly, on unix command line do this:

Phone number format
All phone numbers should be entered with country prefix. Not only ensures this that SMS are send successfully regardless where your phone actually is located. It further is essential to make phone numbers comparable.

After installation
SMSCON installes to autoload at boot, this can be disabled with the command-line command  and re-enabled by   or with SMSCON Editor.

After you made initial settings start SMSCON activity like this: Nokia-N900:~$ smscon -start INFO: Daemon smscon_daemon requested to start. INFO: Daemon smscon_daemon started [PID=17137].

This starts a background daemon which
 * loads the configured user settings file
 * stores your current IMSI code in the IMSI code database
 * waits for commands until stopped or phone shutdown.

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

Configuration
Prior to use SMSCON you have to configure it. Do this by assigning various settings a value. Settings have an internal name, such as MASTERNUMBER. Most settings have useful default values. But some need to be set to personalized values.

To keep your privacy, SMSCON stores personal settings encrypted in the config file. Note that this is not bullet proof to the maximum extend. Experienced hackers are able to decrypt that.

Following is a categorized list of all currently known settings with their internal names and a short description. To get and set the current value of a user setting enter these the commands: $ smscon -get NAMEOFSETTING "default value"  # query a setting $ smscon -set NAMEOFSETTING "the new value"  # assign new value If querying a setting that is not known or not set, the default value is displayed. An attempt to assign an invalid value is denied.

SMS command source

 * 'SENDERNUMBER': SMS number of recent controller. Receives SMS notifications.
 * 'MASTERNUMBER': SMS number of master controller (encrypted).

List of known sms commands

 * 'COM_CHECK': Command to ask for help.
 * 'COM_REBOOT': Command to reboot the phone.
 * 'COM_POWEROFF': Command to shutdown the phone.
 * 'COM_POWER': Command to ask for phone battery status and many other status information.
 * 'COM_LOCATION': Command to ask current GPS location.
 * 'COM_REMOTEON': Command to start outgoing ssh connection.
 * 'COM_REMOTEOFF': Command to stop outgoing ssh connection.
 * 'COM_CAMERA': Command to take picture.
 * 'COM_CALL': Command to start an outgoing call.
 * 'COM_LOCK': Command to lock the phone.
 * 'COM_UNLOCK': Command to unlock the phone (encrypted).
 * 'COM_TRACKON': Command to start GPS tracking.
 * 'COM_TRACKOFF': Command to stop GPS tracking.
 * 'COM_CUSTOM': Command to run predefined user script.
 * 'COM_CUSTOMLOG': Command to ask for user script output.
 * 'COM_SHELL': Command to execute that shell command. Returns output as notification.
 * 'COM_ALARM': Command to play predefined alarm.wav.
 * 'COM_RESTART': Command to restart the daemon.
 * 'COM_LOG': Command to ask for application log (encrypted).

Prefix/suffix for all command strings (in SMS message only)

 * 'SMS_COMPREFIX': Prefix that must be present before all COM_XXX commands [even COM_SHELL] (encrypted).
 * 'SMS_COMSUFFIX': Suffix that must be present behind all COM_XXX commands [even COM_SHELL] (encrypted).

Remote command server

 * 'ENABLECHECKHOST': Enable checking URL for commands.
 * 'CHECKHOST': The URL to check (encoded).
 * 'CHECKTIME': Minutes between URL checks.

Email settings

 * 'EMAILADDRESS': Recipient of EMAIL notifications (regular owner of this phone, please contact him!).
 * 'USER': SMTP username for EMAILFROM (encrypted).
 * 'PASSWORD': SMTP password for EMAILFROM (encrypted).
 * 'EMAILFROM': Sender address of EMAIL notification (encrypted).
 * 'MAILSERVER': SMTP server hostname or IP (encrypted).
 * 'MAILPORT': SMTP server port number.

SSH settings

 * 'REMOTEHOST': ssh server hostname or IP [to build tunnel] (encrypted).
 * 'REMOTEPORT': ssh server port number [to build tunnel].
 * 'REMOTEUSER': ssh server username [to build tunnel] (encrypted).
 * 'REMOTEPASSWORD': ssh server password [to build tunnel] (encrypted).
 * 'REMOTELISTENIP': ssh server IP address [entry of tunnel itself] that will be forwarded to phone (*|localhost|IP).
 * 'REMOTELISTENPORT': ssh server port number [entry of tunnel itself] that will be forwarded to phone.
 * 'REMOTE2LOCALPORT': Local port number to be forwarded to [exit of tunnel itself] on the phone.

If you want to use the SSH connection feature (COM_REMOTEON and COM_REMOTEOFF commands), you also need a fixed IP address (or a dyndns.org domain name) on your preconfigured remote server for the SSH (default port 22) connection.

Notification settings

 * 'COMMANDREPLY': Send notification if command accepted (yes|no).
 * 'MESSAGESEND': How to send notifications (sms|email|both|none).
 * 'ENABLERESEND': On failure try to re-send reply message (yes|no).
 * 'RESENDTIME': Minutes between message re-send tries.
 * 'RESENDMAXTRY': Maximum number of message re-send tries (0=no limit).
 * 'SMS_PARTS_LIMIT': SMS notification produces no more than this number of single SMS (0=no limit).
 * 'LOG_TIMEFORMAT': Format to use for timestamps (see strftime).

GPS settings

 * 'GPSTIMEOUT': Seconds until give up acquiring GPS coordinates.
 * 'GPSPOLLING': Number of GPS coordinate acquisitions for COM_LOCATIONs best of.
 * 'GPSINTERVAL': Seconds between GPS coordinate acquisitions for COM_TRACKON and COM_LOCATION (10..120:10|20|30|60|120).
 * 'GPSSEND': How to send GPS notifications (sms|email|both).

Miscellaneous settings

 * 'SILENCEDEVICE': Set phone silent before executing command (yes|no).
 * 'AUTODEVICELOCK': Lock phone before executing any command except un/lock (yes|no).
 * 'SIMUNLOCK': Automatically unlock phone when new SIM is inserted (yes|no).

Sensor detections

 * 'KEYBOARDDETECT': Send notification if keyboard is sliding (yes|no).
 * 'AUTOBATREPORT': Send notification on battery discharge (yes|no).

The SMSCON log
All user action and activity of  will be logged. To query the log file use SMSCON Editor or enter a  command like this:

Nokia-N900:~$ smscon -log 2012-01-15 00:16:34[SMSCON] INFO: Daemon smscon_daemon requested to start. 2012-01-15 00:16:35[SMSCON] INFO: Daemon smscon_daemon started [PID=17137]. 2012-01-15 00:16:35[DAEMON] CRITICAL: smscon_daemon is starting. 2012-01-15 00:16:35[DAEMON] INFO: Successfully loaded "/opt/smscon/smscon_config" file. 2012-01-15 00:16:36[DAEMON] INFO: Found 1 IMSI code(s) in "/opt/smscon/smscon_code" file. 2012-01-15 00:16:36[DAEMON] INFO: Authorized IMSI code found. 2012-01-15 00:16:36[DAEMON] INFO: Phone battery charge is 45%, charging. 2012-01-15 00:16:36[DAEMON] INFO: Preferred GPS query interval is 20 sec. 2012-01-15 00:16:36[DAEMON] INFO: Keyboard slider change detection is off. 2012-01-15 00:16:36[DAEMON] INFO: Battery status change detection is off. 2012-01-15 00:16:36[DAEMON] INFO: (CHECKHOST) After 0 errors since 2012-01-14 23:16:35 GMT: Successfully read remote file. 2012-01-15 00:16:36[DAEMON] INFO: (CHECKHOST) smscon_daemon is deactivated (00) by remote host file. 2012-01-15 00:16:36[DAEMON] INFO: (CHECKHOST) Checkhost is on. Checking each 30.0 minutes. 2012-01-15 00:16:36[DAEMON] INFO: smscon auto-loads at boot. OK.

By default  outputs the log information in a way that privacy data is somehow anonymous. But no guarantee! To view the log containing all data "as is" you need to provide the master number as a password like this:

Nokia-N900:~$ smscon -pw "+4912345678901" -log Where the value of  option is the master number.

When having trouble with SMSCON always check the log! Note that the log file itself is not readable by normal users. You need to use the  command or use SMSCON Editor to display it (or be a super user ...).

Usage
This section explains how to operate in case you need to control your phone remotely. You need at least one of this:
 * the ability to send SMS to your phone, or
 * access to the remote command server your phone is polling.

To send SMS any phone does. Security note: From a foreign phone, remember to remove all SMS you sent from that phones SMS-sent-history. Otherwise someone else may send them later again. If you're lucky to hold your N900 in hands again, then defining different command prefix/suffix asap is a recommended alternative or additional security option.

Won't miss to say: For using a remote command server, SMSCON and the command server must be setup and configured accordingly before you lost your phone.

No matter if SMSCON is triggered by a SMS message or by remote command server, it will first and optionally reply an acknowledge message and then execute the command in the background.

Commands usually generate a reponse that SMSCON sends as an SMS-reply, EMAIL, both (SMS and EMAIL) or not et all. If SMS replies are enabled, they go to the phone that sent the command and to the master number if one is defined (only once if both numbers are the same). If the command comes from remote command server and SMS replies are enabled, they go to the master number if one is defined.

Commands
The (default) predefined SMS commands are: Nokia-N900:~$ smscon -sms COM_ALARM       = Alarm   /* NEW IN 0.8.1 */ COM_CALL        = Call COM_CAMERA      = Camera COM_CHECK       = Help COM_CUSTOM      = Script COM_CUSTOMLOG   = Script.log    /* NEW IN 0.9.x */ COM_LOCATION    = Location COM_LOCK        = Lock COM_LOG         = Log           /* NEW IN 0.9.x */ COM_POWER       = Power COM_POWEROFF    = Poweroff COM_REBOOT      = Reboot COM_REMOTEOFF   = Remoteoff COM_REMOTEON    = Remoteon COM_RESTART     = Restart   /* NEW IN 0.8.1 */ COM_SHELL       = uptime    /* CHANGE: Better no i/o redirection since 0.9.x */ COM_TRACKOFF    = Trackoff COM_TRACKON     = Trackon COM_UNLOCK      = Unlock

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

Remote command server
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:

-1 = restart SMSCON (use this for restart rather than 17. 17 would restart all the time) 00 = no command 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 18 = COM_CUSTOMLOG 19 = COM_LOG

It is of course necessary that the file on your server can be read by your N900 via the http protocol (or the protocol you set). Otherwise it won't work. If it don't work, check the log for CHECKHOST errors.

The default CHECKTIME is 15 minutes but can be changed via CHECKTIME setting. Note that after giving a command via remote command server, it can take up to CHECKTIME minutes to execute the command.

Example config file
Shown is an example config file as stored in. This is presented for the gentle user only. Normal users never need to see nor edit this directly. Please use smscon command line or SMSCON Editor to edit settings.

Recent version

 * 1) smscon user settings (initially written by version 0.9.13)

@APPVERSION     = '0.9.13'
 * 1) smscon configuration file written by:

AUTOBATREPORT   = 'no'
 * 1) Send notification on battery discharge (yes|no):

AUTODEVICELOCK  = 'no'
 * 1) Lock phone before executing any command except un/lock (yes|no):

CHECKHOST       = 'yEBTfGI6EAJaWzmy73SqVEwUB6FcWazAIQzrVsS0qE1CuD0='
 * 1) The URL to check (encoded):

CHECKTIME       = '15.0'
 * 1) Minutes between URL checks:

COMMANDREPLY    = 'no'
 * 1) Send notification if command accepted (yes|no):

COM_ALARM       = 'Alarm'
 * 1) Command to play predefined alarm.wav:

COM_CALL        = 'Call'
 * 1) Command to start an outgoing call:

COM_CAMERA      = 'Camera'
 * 1) Command to take picture:

COM_CHECK       = 'Check'
 * 1) Command to ask for help:

COM_CUSTOM      = 'Script'
 * 1) Command to run predefined user script:

COM_CUSTOMLOG   = 'Script.log'
 * 1) Command to ask for user script output:

COM_LOCATION    = 'Location'
 * 1) Command to ask current GPS location:

COM_LOCK        = 'Lock'
 * 1) Command to lock the phone:

COM_LOG         = '+YjK8eIOzf+0n0uUJwSuUd3cKw=='
 * 1) Command to ask for application log (encrypted):

COM_POWER       = 'Power'
 * 1) Command to ask for phone battery status:

COM_POWEROFF    = 'Poweroff'
 * 1) Command to shutdown the phone:

COM_REBOOT      = 'Reboot'
 * 1) Command to reboot the phone:

COM_REMOTEOFF   = 'Remoteoff'
 * 1) Command to stop outgoing ssh connection:

COM_REMOTEON    = 'Remoteon'
 * 1) Command to start outgoing ssh connection:

COM_RESTART     = 'Restart'
 * 1) Command to restart the daemon:

COM_SHELL       = 'uptime'
 * 1) Command to execute that shell command. Returns output as notification:

COM_TRACKOFF    = 'Trackoff'
 * 1) Command to stop GPS tracking:

COM_TRACKON     = 'Trackon'
 * 1) Command to start GPS tracking:

COM_UNLOCK      = '3YGdCMKu7rWGnlPSqCkSzz62uA=='
 * 1) Command to unlock the phone (encrypted):

EMAILADDRESS    = 'to@example.com'
 * 1) Recipient of EMAIL notifications (regular owner of this phone, please contact him!):

EMAILFROM       = 'VsPk5cxygm5nGmucyzirv1skvPHrQadT5gqkM5/zM9bSywc='
 * 1) Sender address of EMAIL notification (encrypted):

ENABLECHECKHOST = 'no'
 * 1) Enable checking URL for commands:

ENABLERESEND    = 'no'
 * 1) On failure try to re-send reply message (yes|no):

GPSINTERVAL     = 60
 * 1) Seconds between GPS coordinate acquisitions for COM_TRACKON and COM_LOCATION (10..120:10|20|30|60|120)

GPSPOLLING      = 3
 * 1) Number of GPS coordinate acquisitions for COM_LOCATIONs best of:

GPSSEND         = 'sms'
 * 1) How to send GPS notifications (sms|email|both):

GPSTIMEOUT      = 1800
 * 1) Seconds until give up acquiring GPS coordinates:

KEYBOARDDETECT  = 'no'
 * 1) Send notification if keyboard is sliding (yes|no):

LOG_TIMEFORMAT  = '%Y-%m-%d %H:%M:%S'
 * 1) Format to use for timestamps (see strftime):

MAILPORT        = 25
 * 1) SMTP server port number:

MAILSERVER      = 'dXXpTEa3MZ+05r/ALbHbKt/RePHrQadT5gqkM5/zM9bSywc='
 * 1) SMTP server hostname or IP (encrypted):

MESSAGESEND     = 'sms'
 * 1) How to send notifications (sms|email|both|none):

PASSWORD        = 'WfxI7aL07RhrI83CRQMCC3Ocew=='
 * 1) SMTP password for EMAILFROM (encrypted):

REMOTE2LOCALPORT = 22
 * 1) Local port number to be forwarded to [exit of tunnel itself] on the phone:

REMOTEHOST      = 'iTxPVquDQU92cRF2bmlIRj/pGQ1T+fy7Qek0+9iEtxxVjHg='
 * 1) ssh server hostname or IP [to build tunnel] (encrypted):

REMOTELISTENIP  = 'JJ+/0x2Zo0/a9USQybIzKfa5Ww=='
 * 1) ssh server IP address [entry of tunnel itself] that will be forwarded to phone (*|localhost|IP):

REMOTELISTENPORT = 'viXjs4DLHdkREGe/SdCvOiANqA=='
 * 1) ssh server port number [entry of tunnel itself] that will be forwarded to phone:

REMOTEPASSWORD  = 'ONm0UoDc3e3ireKwmSpwJBLylw=='
 * 1) ssh server password [to build tunnel] (encrypted):

REMOTEPORT      = 22
 * 1) ssh server port number [to build tunnel]:

REMOTEUSER      = 'I4eLEW9zhSuGD8bgA5b3K3aSNQ=='
 * 1) ssh server username [to build tunnel] (encrypted):

RESENDMAXTRY    = 10
 * 1) Maximum number of message re-send tries (0=no limit):

RESENDTIME      = '15.0'
 * 1) Minutes between message re-send tries:

SENDERNUMBER    = '+0000000000'
 * 1) SMS number of recent controller. Receives SMS notifications:

SILENCEDEVICE   = 'no'
 * 1) Set phone silent before executing command (yes|no):

SIMUNLOCK       = 'no'
 * 1) Automatically unlock phone when new SIM is inserted (yes|no):

SMS_COMPREFIX   = 'IJJTaoMyBiJLG3ArS7LeZXOs2w=='
 * 1) Prefix that must be present before all COM_XXX commands [even COM_SHELL] (encrypted):

SMS_COMSUFFIX   = 'U9Vq6qDkHLB/px5Lnq4ZXgZeVQ=='
 * 1) Suffix that must be present behind all COM_XXX commands [even COM_SHELL] (encrypted):

SMS_PARTS_LIMIT = 10
 * 1) A SMS notification produces no more than this number of single SMS (0=no limit):

USER            = 'x22rmwo4SeWn8OqA4Vx+84kf8g=='
 * 1) SMTP username for EMAILFROM (encrypted):

MASTERNUMBER    = 'ZaZrsVQQgtT8cydYgqc3vYgIhg=='
 * 1) SMS number of master controller (encrypted):

Older version
The config file of older version 0.8 may look like this:


 * 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 basically available command-line options for SMSCON are as follows. There are more options e.g. to export and import all settings via command line. They are not shown here; should you ever need to use them, use  option for help. Nokia-N900:~$ smscon -help

smscon 0.9.13 - Nokia N900 remote control utility
usage: smscon [Options]... Options: -start            : Start smscon_daemon -restart          : Stop & restart smscon_daemon -stop             : Stop smscon_daemon -status           : Get smscon_daemon status -log              : Show log file. Anonymized if no or wrong -pw option seen before. -del log          : Delete log file -sms              : Show SMS commands -set name "value" : Set user setting (name = "value") -config           : Show config file -script           : Show script file -scriptlog        : Show script.log file -del scriptlog    : Delete script.log file -boot             : Enable smscon_daemon to start at phone boot -unboot           : Disable smscon_daemon to start at phone boot -add imsi         : Add IMSI code of current SIM to code file -remove imsi      : Remove IMSI code of current SIM from code file -pw password      : Password to enable non-anonymized output. MASTERNUMBER is password. -version          : Show version number -help             : This help menu -help2            : More help (special options, rarely used).

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

Files
This section is a description of what you get when installing SMSCON. This is not a must-read when getting in touch with SMSCON for the first time.

If not otherwise stated, the location of all files mentioned in this section is.

SMSCON is a command line application whose executables parts are mainly:
 * , the command-line control part and
 * the daemon part, running in the background.

SMSCON is highly configurable and all the settings are stored in the  file. Many settings are stored encrypted, so - from version 0.9.3 on - do not edit the file directly. See below for how to change settings.

Files intended to be edited by user directly

 * , a unix shell script to extend SMSCON functionality. This script is intended to be edited by the gentle user. The installation of SMSCON provides a file with some non-destructive example code. SMSCON executes the script in the background with root-rights when receiving a COM_CUSTOM command. You need to be root to change.


 * , a WAV-format sound file. SMSCON plays the sound when receiving a COM_ALARM command. A special sound file (suitable to all languages) is provided by default. You're encuraged to replace it by your own sound. Write it to . Note: currently only WAV sound is supported by SMSCON.

Files used internally
None of these files are intended to be viewed or even edited by a user directly. So don't do it. Use SMSCON commands to view and change them in a consistent way:


 * application program files and libraries
 * several log files
 * internal configuration files
 * temporary files to hold camera pictures, google maps etc.
 * last not least, there are some internal files not stored in.

Names of internal files are not mentioned here by design. They are matter to change without notice as is the existence of this files itself.

Files from other packages
The installation of SMSCON via application manager ("HAM") usually installs other software packages implicitly. They are also de-installed on SMSCON's de-installation (via HAM) in case they are no longer referenced otherwise.

Besides python2.5 this is: python-crypto python-gobject python-location python-dbus pexpect gstreamer-tools openssh-client openssh-server alsa-utils  /* NEEDED IN >= 0.8.1 */

As said above, regular use of SMSCON does not require knowledge of files nor packages used.

0.9.11-2 Development'''
Availability: Extras-devel

Changelog FIX: Fixed repeated resending of sms or email in almost zero-time intervals in case resend-time interval was configured to less than 1 minute. ADD: Anonymized log files. Can be used to post logs in bug reports etc. Works like this: Logfile shown by command "smscon -log" is now anonymized by default (phone numbers, host names, IP-addresses) IMPORTANT NOTE(1): Anonymizing takes place with ABSOLUTELY NO guarantee! IMPORTANT NOTE(2): It is NOT A BUG if there is too much or "wrong" anonymizing. If new option "-pw password" was seen on command line before -log, then logfile is shown un-anonymized as before. And of course a super user has not limits anyway. CHANGE: Logfile is no longer readable by normal user. FIX(MINOR): Fixed typos and added more comments.

0.9.10-1
Changelog FIX: If called in user mode, prevent -export or -export! option to create/write files that user has no permissin to create or write. FIX: Fix crash: TypeError: can only concatenate tuple (not "list") to tuple

0.9.9-1
Changelog CHANGE: Deamon does no longer need to restart for switching between test mode and normal operation mode. FIX: Daemon now reads test command requests from a named pipe and works them off sequentially (allows to quickly start several tests in a short time). FIX: Fixed that COM_REMOTEOFF command did not work. FIX: Fixed daemon crash ("need more than 3 values to unpack") FIX (AGAIN): Force using busybox ps-command to ensure that process information like PID is at expected place.

0.9.8-1
Changelog FIX: Fixed problems with daemon process ids on devices with extended "ps" command installed. This bug might prevent power users from using smscon. So this fix is reason for early release of new version. FIX: Fixed interchanged message parameters in smscon -init! command output. ADD: Added usage hints to initial smscon_script file (minor change).

0.9.7-1
Changelog FIX: Send battery status notification if charge is below 10% AND discharging (not OR discharning). If devices can't tell change/discharge status; discharge is assumed. FIX: Don't check for bootloader if in test mode. FIX: Wrong error message that daemon did not start on devices with extended "ps" command installed.

0.9.3-1
Changelog

REFACTURING: * Extracted common code to a library (smsconlib.py) which is now used by smscon_daemon, smscon control program and smscon-editor. * Added a lot of code comments. * Encapsulated many code into classes. E.g. the complete encyption stuff is now transparent to smscon control program and smsmcon editor. * Restructured code, written new and renamed a lot of old stuff. * Moved code from files "smscon" and "smscon_daemon" to pure python-modules (smscon_master.py and smscon_service.py respectively). The original files are now just jackets calling main in associated python module. This allows to compile the modules and hiding source code. NEW:   Encryption now uses salt (formerly encrypted data can be read). FIX:   Encryption does no longer fail on text ending with curly open brace. NEW:   "MASTERNUMBER" concept: A SMS number stored in the config file that  does NOT change due to SMS commands like "SENDERNUMBER" does. Each SMS is send to both (only once if they are the same numbers, of course). SMS replies to commands which are not introduced by SMS (e.g. via CHECKHOST) are sent to the MASTERNUMBER only. On upgrading, the default MASTERNUMBER is set to the current SENDERNUMBER. NEW:   "COM_CUSTOMLOG" command: A SMS command to retreive the output of the last "COM_CUSTOM" command. Will be sent via email only - would send too much SMS... NEW:    "COM_LOG" command: A SMS command to retreive the smscon.log file. Will be sent via email only - would send too much SMS... NEW:    The output of "COM_SHELL" SMS command is now sent as a command reply. You may have to remove output redirections from your shell command to get non-empty reply. NEW:   "SMS_PARTS_LIMIT": A number to limit the number of single SMS that would otherwise be generated to send a too long SMS message. Zero means no limit. NEW:   "LOG_TIMEFORMAT": Format to be used in time stamps of SMS and EMAIL messages. NEW:   "SMS_COMPREFIX" and "SMS_COMSUFFIX": Instead of explicitly define all your SMS control commands (COM_xxx) to start with a unique prefix and/or suffix, you might now separately define a prefix and/or suffix that is implicitely used. While "SMS_COMPREFIX" and "SMS_COMSUFFIX" are empty, all your commands do as in older versions. Advantage of using "SMS_COMPREFIX" and "SMS_COMSUFFIX": * Prefix and suffix can be changed easyly while embedded COM_xxx remain unchanged. * Prefix and suffix apply to COM_SHELL command as well. Example: With the configuration set to: COM_SHELL=uptime SMS_COMPREFIX=aaa. SMS_COMSUFFIX=.bbb The recognized SMS command to execute the shell command "uptime" is: aaa.uptime.bbb FIX:   It is no longer possible to define two SMS commands as the same string except the empty string, which means to disable that command being given via SMS. FIX:   SMS command recognition is no longer restricted to ASCII characters. The complete GSM 7 bit default alphabet may be used now (but not unicode). This gives you a greather variete of chars to use for your SMS commands. NEW:   The config file will now upgrade automagically from any previous version. New options are set to their default, obsolete options are commented out. NEW:   New function to export and import settings to/from arbitrary file. (see smscon -export and -import options). smscon editor makes now use of this functions to retrieve a and deploy editable configuration. NEW:   The smscon_daemon does no longer need to be restarted explicitly if smscon changes a setting. The daemon detects changes automagically and will read and apply the new configuration automatically. NEW:   The smscon_daemon now maintains a "last known good" configuration and uses that as a fallback in case the "official" configuration of smscon can't properly loaded by the daemon. NEW:   Camera picture and GSP Location requests do no longer force unconditional switching to GPRS network connection. The current connection will be used if the internet is reachable. Should a GPRS connection be required to reach internet, the GPRS connection is established but the previous network is re-activated after picture and/or location has been replied. NEW:   A LOGGER is now used wherever possible. So the smscon.log file becomes really interesting. NEW:   The "CHECKHOST" URL is now extended by "?LASTMCD=nn&CHECKTIME=minutes" which will allow the URL being a script that may use this information. CHANGE: "CHECKHOST" now works more clear as follows: While polling for commands, a command is executed once, if it differs from the last polled command. The last polled command is initialized to "-1" on daemon start. Code "-1" is "restart daemon" and this obviously is what happened on daemon start. Code "17" (COM_RESTART) is deprecated as a CHECKHOST command. Since it is different from "-1" it may restart the daemon repeatedly. Use code "-1" to restart the daemon via CHECKHOST instead. Of course, before a change to code "-1" is recognized by the daemon, you must have give it a different command code. If in doubt use "01" (COM_CHECK) because it gives you feedback that the command has been seen. CHANGE: "CHECKTIME" may now be a float to specify fractional parts of a minute: 0.25 is 15 seconds. NEW:   The "CHECKHOST" URL may now have a protocol prefix and it may be different from "http://". If the URL has no protocol prefix, then "http://" is supplied as default as in former versions (e.g. your config file remains valid in this point as well). NEW:   The battery status is logged before a command is about to be executed. NEW:   "REMOTELISTENIP", "REMOTELISTENPORT" and "REMOTE2LOCALPORT": These settings give you greather flexibility of setting up a tunnel to remote control your phone via a reverse ssh-connection: Use "REMOTELISTENIP" and "REMOTELISTENPORT" to define the tunnel entry maintained by the remote ssh-server (which must be setup to allow setting LISTENIP and PORT this way). "REMOTELISTENPORT" defaults to 8080 and "REMOTELISTENIP" defaults to "localhost" as in former versions. With these defaults you must be logged in at the ssh-server to start a remote control connection of your phone. While setting up "REMOTELISTENIP" you may even control the phone from somewhere else (in which case the ssh-server act as a proxy or relay). On the tunnel exit side, which is on your phone, the "REMOTE2LOCALPORT" is the port number where your phone's ssh-daemon is listening (usually 22). CHANGE: The "smscon -devconfig" command now requires a password to show the uncrypted configuration. The MASTERNUMBER is the password. NEW:   "RESENDMAXTRY": This option defines the maximum number of message re-send tries. Applies to SMS and EMAIL as well. (0=no limit) On configuration upgrade this is initialized to 10. NEW:   smscon now has a -sendsms option to send SMS immediately. Despite being a nice feature by itself, it makes smscon editor independent from smssend program which requires an extra package. NEW:   smscon now allows all options to start with the usual double dash as well.

0.8.1-3 (testing)
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)
 * The "_" character does not get decoded correctly on reception and any command having this fails to execute. Recommended: until a fix is made avoid using this character in the commands. (confirmed)

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.
 * CHANGE: The log file location changed from  to   (whereas location of   did not change).

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). INFO: Remote command server (CHECKHOST) already offers silent control.
 * 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. INFO: Since 0.9.x there is a MASTERNUMBER concept. This is a default number that is never replaced
 * add setting to choose the default internet connection (WLAN, GPRS, or ANY).
 * 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 more than one custom command.
 * 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. (INFO: Use the prefix/suffix option in smscon editor application or set SMS_COMPREFIX/SMS_COMSUFFIX options via command-line)
 * 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, accepting 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 happening (if possible with an option to re-dimension 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.