jason schaefer . com

"arguing that you don’t care about the right to privacy because you have nothing to hide is no different than saying you don’t care about free speech because you have nothing to say."

Tag: android

  • Migrating SMSSecure (Silence) keys and texts

    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

    UPDATE: You can now export an encrypted copy of Silence. This export includes your encryption keys. From your old phones Silence “app”lication, under the three horizontal “…” -> “Import / Export” -> “Export encrypted backup”. This exports to the phones /sdcard/SilenceExport or from mtp “mtp://[usb:xxx,xxx]/Internal storage/SilenceExport”. Copy this directory to the new phone, to the equivalent path (/sdcard/). Install Silence on the new phone. In my experience the first-run import prompt didn’t work so I had to do it manually. Click the three horizontal “…” -> “Import / Export” -> “Restore encrypted backup”. Your done!

    I wanted to do this transfer using mtp but neither thunar or nautilus could “see” the SilenceExport directory. I had to do the following:
    plug in old phone and copy the export to my laptop:
    adb pull /sdcard/SilenceExport/
    plug in the new phone:
    adb push SilenceExport/
    Remember you have to authorize your laptop from the phone.

    THE FOLLOWING INSTRUCTIONS ARE CONSIDERED OUT OF DATE yet still useful for some.

    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:
    UPDATE: This doesn’t work anymore

    [jason@local ~] $ adb push org.smssecure.smssecure/ /sdcard/
    adb: warning: skipping empty directory 'org.smssecure.smssecure/code_cache/'
    adb: warning: skipping empty directory 'org.smssecure.smssecure/app_captures/'
    adb: error: failed to copy 'org.smssecure.smssecure/lib' to '/sdcard/org.smssecure.smssecure/lib': symlink failed: Operation not permitted
    
    

    The brilliant developers of adb didn’t write in support for adb push to be recursive? We have to get creative as usual with Android. Use zip if you have unzip on your phone.

    [jason@local ~] $ zip -r org.smssecure.smssecure.zip org.smssecure.smssecure/
    
    And then,
    adb push org.smssecure.smssecure.zip /sdcard/
    adb shell
    cd /sdcard/
    unzip org.smssecure.smssecure.zip

    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;