Dec 062015
 
 December 6, 2015  Posted by at 10:36 pm android, backup, documentation, security Tagged with: , , ,  Add comments

For those unfamiliar: SMSSecure (now called Silence) is a text messaging application that supports encryption. It has exceptional integration on your phone and will handle your non-encrypted friends acquaintances texts as well.
https://smssecure.org
I recommend using fdroid to install it. F-droid is a Free Software repository for Android.
https://f-droid.org

When moving to a new phone you can export a plain text copy of all your sms texts for import on the new phone. This is fine but has many drawbacks. The export feature of smssecure does not export a users encryption keys. Here are instructions on doing this yourself. Its really not as bad as it might seem and is worth doing to avoid re-keying with every friend you text with. You can also avoid exporting sensitive txt’s to plain-text.

PREREQ’s:
Install SMSSecure on the new phone.
You will need adb access to both phones.

Enable developer options by going into Settings -> About phone -> then press “Build number” 7 times.

Enable adb access under Settings -> Developer options -> Android debugging.

Allow adb root access from “developer options -> Root access” “Apps and ADB”. Otherwise you will get a permission error like so:

shell@ville:/ $ su -
Permission denied

Also, be sure your computer can see the phone:
[jason@local ~] $ adb devices
List of devices attached
393520931D5B00EC device

    If usb is broken you can use ADB over the network. Enable it under Developer options -> Android debugging -> ADB over network. Connect to your local wireless first and take out your sim card before enabling. Otherwise your phone will be fully reachable over the cell network/public internet.

    Now connect to the phone over the network:
    [jason@local ~] $ adb connect 192.168.123.12:5555

    You can continue as if it was plugged in directly…
    To disconnect from the phone use this:
    [jason@local ~] $ adb disconnect 192.168.123.12:5555

STEPS:
I wasn’t able to directly copy the smssecure directory to my computer. It errors with zero files transferred:

[jason@local ~] $ adb pull /data/data/org.smssecure.smssecure/ org.smssecure.smssecure-balz
pull: building file list...
0 files pulled. 0 files skipped.

First I copy it to the sdcard of the old phone:

[jason@local ~] $ adb shell
shell@crespo:/ $ su -
root@crespo:/ # cp -rv /data/data/org.smssecure.smssecure/ /sdcard/

Copy the smssecure data from your old phone /sdcard/ to your local computer:

[jason@local ~] $ adb pull /sdcard/org.smssecure.smssecure/ org.smssecure.smssecure

Now plugin the new phone

Next, we will copy the org.smssecure.smssecure directory to the new phone:
Note: I attempted to copy directly to the new phone at /data/data but there was a permission denied:

[jason@local ~] $ adb push org.smssecure.smssecure/ /data/data/
push: org.smssecure.smssecure/databases/messages.db-journal -> /data/data/databases/messages.db-journal
failed to copy 'org.smssecure.smssecure/databases/messages.db-journal' to '/data/data/databases/messages.db-journal': Permission denied

Instead copy it to the /sdcard/ of the new phone, first:

[jason@local ~] $ adb push org.smssecure.smssecure/ /sdcard/org.smssecure.smssecure

Before we proceed lets check what permissions the org.smssecure.smssecure directory is currently set to (from the phones shell). In this case its chown u0_a63.u0_a63 and chmod 755:

root@crespo:/ # ls -ld /data/data/org.smssecure.smssecure/
drwxr-xr-x u0_a63   u0_a63            2015-12-06 21:35

Keep note of this for later.

Using the new phone’s root shell you will delete the existing (un-used) directory and copy your smssecure directory (with all your text’s) from sdcard to /data/data:

[jason@local ~] $ adb shell
shell@crespo:/ $ su -
root@crespo:/ # 
root@crespo:/ # rm -fr /data/data/org.smssecure.smssecure/
root@crespo:/ # cp -rv /sdcard/org.smssecure.smssecure  /data/data/

Note: If you try using move (mv) instead of copy (cp) and your sdcard is on a separate partition you will get this error:
root@maguro:/ # mv /sdcard/org.smssecure.smssecure/ /data/data/
failed on '/sdcard/org.smssecure.smssecure/' - Cross-device link
255|

Back to permissions:
After the data is copied to the new phone the directory and file permissions will be wrong (owned by root):

root@crespo:/ # ls -l /data/data/org.smssecure.smssecure/       
drwxrwx--- root     root              2015-12-06 21:35 app_parts
drwxrwx--- root     root              2015-12-06 21:35 databases
drwxrwx--- root     root              2015-12-06 21:35 files
lrwxrwxrwx install  install           2015-12-06 15:07 lib -> /data/app-lib/org.smssecure.smssecure-1
drwxrwx--- root     root              2015-12-06 21:35 shared_prefs

We need to change ownership to user and group. In my case I need to change it to u0_a63. Android’s chown doesn’t work as expected:

root@crespo:/ # chown -R u0_a63.u0_a63 /data/data/org.smssecure.smssecure/
No such user '-R'

Unfortunately, android sucks and chown is broken so we must get creative. Like any puzzle, its simple once you know the answer :-)

root@crespo:/ # find /data/data/org.smssecure.smssecure/ -exec chown u0_a63.u0_a63 {} \;

Luckily, chmod works ok:

chmod -R 755 /data/data/org.smssecure.smssecure/

Be sure to reboot your phone.
Note: My SMSSecure disappeared and I needed to re-install. Everything was there after I re-installed and it survived subsequent reboots.

done;

  2 Responses to “Migrating SMSSecure (Silence) keys and texts”

  1. Thank god that someone else is using smssecure and thanks for the tutorial. What smssecure version you have used for this tutorial? From posting date I guess it could be 0.12.3. In my case, after copying the data, the smssecure 0.12.3 installation recognize the key but all messages are gone. Do you have any further hints from your experience? Thanks in advance.

  2. Hi Phren
    yep, I was using .12.3 for this tutorial. Since then I have upgraded to 0.13.0.
    I would guess your problem is permissions related. Double check that you chown’ed with *your* user and not mine (u0_a63)?
    If you really can’t get it to work, you can always export plaintext and import again on new device. You will lose your key and have to re-initiate with all your friends AND you will potentially compromise your texts privacy. I’m sure you know about the built-in import and export features of smssecure. Just in case, I will point it out for other readers.
    Although, I don’t understand why there is a “restore encrypted backup” option and only a “export plaintext backup” option??

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*