Archiv für den Autor: self

Kids: Developer and Bug (Hi-Res)

Inspired by this tweet

I re-made the picture in a higher resolution. It is based on a ad of Solid.

The picture is also available in German – use the language switch.

Brave.svg
brave

New TextSecure-Browser Build

There were several Commits in the TextSecure-Browser-Plugin (see also the old blog)  on GitHub.

I merged them with my fix for the message times and made a new package.

The most visible change is, that the conversations now happen in the main window as well (you might have to make it a bit broader).

Attention: This is still a developer’s version and use on the normal server as well as using it in daily live is discouraged. Anyways: I think beta testing is fun!

If you spot bugs, please consider reporting and/or fixing them and submit a pull request on the GitHub page.

You’ve been warned – download here: textsecure-dist-2015-08-29

textsecure-dist-2015-11-09

Finally: Cross Platform Secure Chat – Signal (was TextSecure) on the Desktop HowTo

*Updated 07.11.2015*

TL;DR

TextSecure already works pretty well on phone and desktop in a synced manner. But only with the developer builds.

Quick Guide

If you trust me, just install the pre-compiled latest TextSecure Android App in your phone and TextSecure Browser Chrome Plugin in your browser. Both are not signed, so you have to allow insecure sources and so on. Then start the mobile app, register (which will generate a key). Run the browser plugin and scan the OR code to pair with the phone.

Intro

Since quite a while I was searching for an encrypted chat solution for my smart phone and desktop. It should be easy to use. Well encrypted. And history should be synced between the devices.

My hope was that a Jabber client for the smart phone finally gets message archiving working with OTR or another encryption. OTR will probably never work, because it does (additonally) not have offline capabilities. There were standardization efforts, but those timed out.

TextSecure

A friend pointed me to TextSecure by WhisperSystems. It is Free and Open Source. Works pretty well on the smartphone (both Android and iOS) in the same way like WhatsApp: It uses your phone number for identification, so it is easy to find your contacts. The only problem remaining: There is no finished desktop app for it.

Diving into the developer grounds

But: There is a quite active development going on for the Google Chrome Plugin TextSecure in the Browser. In the readme they say you should not install it, but I did anyways 😉 Anyway it needs some steps

Install Guide

Basically you need the cutting edge App (not the one from the app store) and point the browser plugin to the production server.

 HEAD of the APP

  1. Get android studio
  2. Clone the GIT https://github.com/WhisperSystems/TextSecure in Android Studio
  3. Choose build variant dev
  4. Uninstall the stable TextSecure from your phone
  5. Enable Android Debugging
  6. Connect your phone to the computer
  7. Run the app from Android Studio on your phone (which will also install it)

No necessary anymore, the google play version is fine.

Get The TextSecure Browser Plugin

  1. Clone the GIT https://github.com/WhisperSystems/TextSecure-Browser
  2. Change the server addresses to the live system (with the text editor or SED)
    sed -i s/textsecure-service-staging/textsecure-service/ Gruntfile.js
    sed -i s/textsecure-service-staging/textsecure-service/ js/background.js
    sed -i s/textsecure-service-staging/textsecure-service/ js/libtextsecure.js
    sed -i s/textsecure-service-staging/textsecure-service/ libtextsecure/api.js
  3. Install grunt and call grunt copy
  4. Install in the browser as described in the CONTRIBUTION Readme.
    The important steps follow:

    1. Go to chrome://extensions/
    2. Enable developer mode (checkbox on the top right)
    3. Click „Load unpacked extension…“
    4. Point to the dist subfolder of the repo directory
  5. Run the plugin
  6. You should see a QR code which your have to scan using a QR app on your phone to pair (if you don’t see the QR code, probably something with the SSL certificate went wrong). Remark: The QR app has to open the tsdevice:/ link from the QR code as a link. QR droid does not work. „Barcode scanner“ works. Also the scanning function in the Signal app does not work for this.

That’s it!

My tests

  1. Write something on the phone: appears on desktop
  2. Go offline (airplane mode on the phone) as well on the desktop (disable plugin). Write something on the phone. Go online: appears on the desktop

Happy secure chatting!

Simple Wildcard DNS für *.local for Web Development on Ubuntu

As a Web developer you often use a local webserver. You might create an own VHost for each project. The next step is to add a domain like mycustomer.local with the IP 127.0.0.1. This is done by adding a line to your /etc/hosts file.

If you do not want to add a new entry each time you create a new project to  /etc/hosts, the is a simple way to add a wild card entry on Ubuntu.

This works, because current Ubuntu versions use the Network Manager which itself starts the local DNS server „dnsmasq“.

  1. Create a file /etc/NetworkManager/dnsmasq.d with the contents:
    address=/.local/127.0.0.1
  2. Restart the network manager.
    service network-manager restart
  3. Check if everything went well
    # host foobar.local
    foobar.local has address 127.0.0.1

„The MAC address can not be the multicast address“ fix for Cisco routers WAG160N

We have one (a bit old) Linksys / Cisco ADSL router of the type WAG160N. Recently we decided to set up MAC filtering (in addition to a WPA password of course). We only allow access to the WiFi after we know which MAC the person’s device has. The reason is that we have only a very narrow connection speed and want to be able to see if anybody is (unintentionally) using to much bandwidth – due example by automatic updates.

All was fine for some days until we tried to add another MAC address to the filter and got the message „The MAC address can not be the multicast address“. It was an address starting with „5C: …“ which does not seem to be a multicast address at all according to Wikipedia.

bug

I digged into the webinterface and found that there is a JavaScript function isMacMulticast


function isMacMulticast(mac)
{
var mac1=mac.toUpperCase();
var byte=parseInt(mac1.substr(0,2));
if((byte&0x1)==0x1)//if lowest bit of first byte is 1, then it is multicast address.
return true;
else
return false;
}

While I think it shouldn’t it does return „true“ for the mac address starting with 5C – but the lowest bit of the hexadecimal value 5C is not 1! The should have used

byte=parseInt("0x" + mac1.substr(0,2));

Quickly I found a workaround for this problem.

Just open your browser’s developer’s console and enter


isMacMulticast = function(e) { return false; }

After this you can save the settings. There is no router-side validation at all.

Change fields of „Personal Data“ in Contao Backend

I was wondering how to change the fields which a backend user can edit by clicking on „User John Doe“ in the backend.

personal-data

It’s simple.

Just create a new module (or use an existing one like mycompany_mycustomerlocal) and under dca/tl_user.php with the following palette definition:

$GLOBALS['TL_DCA']['tl_user']['palettes']['login'] = '{name_legend},username,'    . 'name,email;{password_legend},password';

That is it.

I found this by digging into the code a system/modules/core/modules/ModuleUser.php:52

Generate pronounceable Passwords

I am using KeePass2 to generate pronounceable and easy to remember passwords using the generate-by-pattern function. The pattern is use is similar to „ddLvLvsLvLv“. Be aware to modify the pattern so others can not easily crack your passwords.

Screenshot_Password Generator_007

Sample passwords

Screenshot_Password Generator_008

 

 

 

Save Google Camera Pictures to SD Card and Android Internals

Google Camera does not allow choosing the save location

On my Android phone I use Cyanogen Mod 11. Unfortunately the integrated picture taking app does not support Google’s Photo Sphere function which I like a lot.

That is why I installed Google Camera from Google Play. This comes with one disadvantage: The Google Camera does not allow choosing the storage path which I would like to set to the SD card which has more space.

Proof of concept: Symlinks and Mounts

I tried and learned a lot: First I was trying creating a symlink using the Terminal Emulator. Setting a symlink using the command ln -s /storage/sdcard1/DCIM/ /storage/emulated/legacy/DCIM  is not working an gives me a „link failed Function not implemented“ error.

Finally I figured mount -o bind /storage/sdcard1/DCIM/ /storage/emulated/legacy/DCIM has the desired effect but how can I make this on every boot?

ADB – Android Debug Tool

I thought of editing the fstab but now the Terminal Emulator was a bit hard to use so I Googled for SSHing to my phone and discovered the Android Debug tool. First I activated USB debugging by clicking seven times on the build number on the about screen to activate the developer mode which reveals the USB debugging option. We have to specify root permissions for ADB. On my Ubuntu computer I install using aptitude install android-tools-adb and after connecting my phone via USB I can execute adb shell to open a shell.

How can we make this persistent?

Back to the original problem, there is no /etc/fstab but a /etc/fstab.qcom. Unfortunately this file can not be edited. We can make it read-writeable using mount -o remount,rw / but now I figured that the changes are not persisted during a reboot.

Next I learned about the file /data/local/userinit.sh which is executed on each boot if it exists. I put

#!/system/bin/sh
mount -o bind /storage/sdcard1/DCIM/ /storage/emulated/legacy/DCIM

in it, but it did not work and using the logcat command I found that the mounting takes place to early:

I/sh ( 178): mount: No such file or directory

It’s simple: Folder Mount App

To make a long story short I finally found the folder mount app (needs root of course) which gives an easy GUI to move the folder and mount it on the next boot. Now my pictures are stored on the SD card.

Rewrite Classes in Contao

The Contao Web CMS System provides the possibility to rewrite classes of the core or of 3rd party modules.

In case you want to publish your extension, this is not a suggested way because this can create conflicts if two installed modules try to rewrite the same class. But for local modules this is a valid method.

First of all you must ensure, that your module is loaded after the module you want to rewrite. You can assure this by giving your module a name which comes alphabetically after the name of the module to be rewritten. Or you can add a line

requires[] = "dlh_googlemaps"

to your autoload.ini. Digging into the code you find out that this require statement is evaluated in \Contao\ModuleLoader::scanAndResolve.

Now you simply have to add your class to the autoload.php with the same class name (without namespace prefix) as the class to be rewritten:

ClassLoader::addClasses(array
(
	'Mymodule\Googlemap' => 'system/modules/mymodule/classes/Googlemap.php',
));

The class loader uses the class_alias() PHP function to define an alias for the class name without the namespace. So now the class can be instantiated using \Googlemap.

Your Googlemap.php would look like this

namespace Mymodule;

class Googlemap extends \delahaye\googlemaps\Googlemap {
    public static function getMapData($intMap, $strFormat= '', $arrParams=false) {
        parent::getMapData($intMap, $strFormat, $arrParams);
        // your code
    }
}

If you set

$GLOBALS['TL_CONFIG']['debugMode'] = true;

in your localconfig.php, a debug area is displayed on the page’s bottom indicating which classes are aliased:

 Screenshot_Selection_006

The method \Contao\ClassLoader::findClass() is responsible for searching the registered namespaces for the class. The static field ClassLoader::$namespaces contains the registered namespaces in reverse order of the loading order of the modules so the first match is picked.

There is one catch: if two or more of your modules use the same namespace, all of them have to be loaded before the module you want to overwrite (using the required-configuration mentioned above) . Otherwise the namespace will be listed in the wrong order as each namespace can be only registered once and the overwrite will not have an effect.

References: