tech stuff

Main - Archive - About - Feed


Short log on using letsencrypt with a 3rd party bash client:

$ sudo su -
# apt-get install git openssl curl
# cd /opt
# git clone
# echo "" > /opt/
# mkdir -p /var/www/html/.well-known/acme-challenge
# echo 'WELLKNOWN="/var/www/html/.well-known/acme-challenge"' > /opt/
# /opt/ -c
# echo "38 4 * * 7 root /opt/ -c" > /etc/cron.d/letsencrypt
# vi /etc/apache2/sites-enabled/010-default-ssl.conf 
# grep SSLCertificate /etc/apache2/sites-enabled/010-default-ssl.conf
  SSLCertificateKeyFile   /opt/
  SSLCertificateFile      /opt/
  SSLCertificateChainFile /opt/
# apachectl restart

Cisco IOU on n900

Cisco IOU has been floating around for quite some time. Out of the boredom, and for fun having Cisco switching lab in my pocket, I've managed to make it running on my Nokia N900.

Prerequisites: Debian chroot on N900 Maemo - all actions on N900 are assumed within Debian chroot.

Obtain IOU image (insert default joke of you being Cisco employee or having a valid license here) :

N900-deb:~# mkdir -p /data/cisco
N900-deb:~# mv /tmp/a.bin /data/cisco/i86bi-linux-l2-upk9-15.0b.bin

N900-deb:~# file  /data/cisco/i86bi-linux-l2-upk9-15.0b.bin
/data/cisco/i86bi-linux-l2-upk9-15.0b.bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 2.2.5, stripped

N900-deb:~# uname -m

Install qemu-user:

N900-deb:~# apt-get install qemu-user
N900-deb:~# qemu-i386 -version
qemu-i386 version 2.1.2 (Debian 1:2.1+dfsg-12+deb8u5a~bpo70+1), Copyright (c) 2003-2008 Fabrice Bellard

IOU binaries for linux are dynamically linked ELF 32-bit LSB executables for Intel 80386. If we try to simply execute it via qemu-i386, we'll get an error for missing dynamic linker/loader (see "interpreter" part in 'file' output above):

N900-deb:~# qemu-i386 /data/cisco/i86bi-linux-l2-upk9-15.0b.bin 
/lib/ No such file or directory

You can locate the debian package, containing by searching on, for a i386 architecture, (i'm going to use use wheezy packages, because it's the distro my debian chroot is based on). In this case it's libc6 - download it, and extract to a local directory, then copy to /lib, where IOU image expects it:

N900-deb:~# wget
N900-deb:~# dpkg -x libc6_2.13-38+deb7u10_i386.deb /data/cisco/extract

N900-deb:~# find  /data/cisco/extract/ -name

N900-deb:~# file /data/cisco/extract/lib/
/data/cisco/extract/lib/ symbolic link to i386-linux-gnu/

N900-deb:~# cp /data/cisco/extract/lib/ /lib/
N900-deb:~# file /lib/
/lib/ ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=50ea7a832566b8e48b2824267f8f92decdf1c2db, stripped

If you try running IOU image via qemu now, you'll get an error for missing shared library file :

N900-deb:~# qemu-i386 /data/cisco/i86bi-linux-l2-upk9-15.0b.bin 
/data/cisco/i86bi-linux-l2-upk9-15.0b.bin: error while loading shared libraries: cannot open shared object file: No such file or directory

We can use objdump or readelf to find out the needed shared libraries from the foreign architecture binary (ldd won't work here):

N900-deb:~# objdump -x /data/cisco/i86bi-linux-l2-upk9-15.0b.bin | grep NEEDED

N900-deb:~# readelf -d /data/cisco/i86bi-linux-l2-upk9-15.0b.bin | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: []
 0x00000001 (NEEDED)                     Shared library: []
 0x00000001 (NEEDED)                     Shared library: []
 0x00000001 (NEEDED)                     Shared library: []
 0x00000001 (NEEDED)                     Shared library: []

We can even use readelf to generate full dependence list, containing all needed files, to automate package search later:

N900-deb:~# readelf -a /data/cisco/i86bi-linux-l2-upk9-15.0b.bin | egrep "interpreter|NEEDED" | awk '{print $3,$4,$5}' | sed -e 's/\[//' -e 's/\]//'
interpreter: /lib/ 
Shared library:
Shared library:
Shared library:
Shared library:
Shared library:

Use debian package search as per above, to find out and download packages containing needed files, extract packages locally, find, and copy needed files to some location. Please note that in a list is going to be copied from from libssl, and it itself contains additional libz dependency. Final needed package list:

And files within:

Missing Package File in a package
interpreter: /lib/ libc6 /lib/
Shared library: libssl1.0.0 /usr/lib/i386-linux-gnu/
Shared library: zlib1g /lib/i386-linux-gnu/
Shared library: libc6 /lib/i386-linux-gnu/
Shared library: libgcc1 /lib/i386-linux-gnu/
Shared library: libc6 /lib/i386-linux-gnu/
Shared library: libc6 /lib/i386-linux-gnu/


N900-deb:~# ls -1 /data/cisco/pkg/

N900-deb:~#  find /data/cisco/pkg/ -name '*.deb' | while read line; do dpkg -x $line /data/cisco/extract/; done

N900-deb:~# mkdir -p /data/cisco/lib

N900-deb:~# cp /data/cisco/extract/usr/lib/i386-linux-gnu/ /data/cisco/lib/
N900-deb:~# for i in /data/cisco/extract/lib/i386-linux-gnu/{,,,,}; do cp $i /data/cisco/lib/; done

N900-deb:~# ls -1 /data/cisco/lib/

Now we can try pointing LD_LIBRARY_PATH environment variable to our library directory, and run IOU image via qemu again:

N900-deb:~# cd /data/cisco

N900-deb:/data/cisco# LD_LIBRARY_PATH=/data/cisco/lib qemu-i386 ./i86bi-linux-l2-upk9-15.0b.bin
IOS On Unix - Cisco Systems confidential, internal use only

It works:

Last touch: we have all foreign architecture shared library files isolated in a separate directory, but full path to the "" is hardcoded into the IOU binary, and this file polutes our chroot distro. The solution could be modifying IOU binary and changing path to the "interpreter" to someting else, or shrinking it so, it is relative, and then placing dynamic linker/loader to the directory we are running IOU binary from:

There are several standard tools for manipulating ELF headers, like elfedit or objcopy from binutils, or we can simpy use any HEX editor for that, but for a job, the most convenient tool I found was patchelf:

N900-deb:~# readelf -a /data/cisco/i86bi-linux-l2-upk9-15.0b.bin | grep interpreter
      [Requesting program interpreter: /lib/]

N900-deb:~# patchelf --set-interpreter '' /data/cisco/i86bi-linux-l2-upk9-15.0b.bin

N900-deb:~# readelf -a /data/cisco/i86bi-linux-l2-upk9-15.0b.bin | grep interpreter
      [Requesting program interpreter:]

N900-deb:~# mv /lib/ /data/cisco/

Symmetric encryption

For a long time I've been using ccrypt utility for symmetric encryption on linux. The only problem with it - it's not in default install on most debian-based distros I use.

There are 2 possible alternatives present in default install:


Nokia-N900:~# echo "this is plain text" > /tmp/123

Nokia-N900:~# openssl enc -aes-192-cbc -in /tmp/123 -out /tmp/123.sslenc
enter aes-192-cbc encryption password:
Verifying - enter aes-192-cbc encryption password:

Nokia-N900:~# rm /tmp/123

Nokia-N900:~# openssl enc -d -aes-192-cbc -in /tmp/123.sslenc -out /tmp/123
enter aes-192-cbc decryption password:

Nokia-N900:~# cat /tmp/123
this is plain text


Nokia-N900:~# echo "this is plain text" > /tmp/123
Nokia-N900:~# gpg --symmetric --output /tmp/123.gpg /tmp/123 
Enter passphrase: 
Repeat passphrase:

Nokia-N900:~# rm /tmp/123

Nokia-N900:~# gpg /tmp/123.gpg 
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected

Nokia-N900:~# cat /tmp/123
this is plain text

adb on N900

These days I normally carry minimum 2 devices:

  • Android phone as a regular phone
  • Nokia N900 as a linux terminal

Recent android phone now has more computing power than it needs, but lacks handy keyboard present in N900 to fully utilise these resources when needed. So, I am going to use N900 as a terminal towards android phone via wireles adb (Android Debug Bridge).

On N900:

Nokia-N900:~# apt-get install git build-essential libssl-dev
Nokia-N900:~# git clone
Nokia-N900:~# cd adb-arm/
Nokia-N900:~/adb-arm# rm adb-arm-binary
Nokia-N900:~/adb-arm# cp makefile.sample makefile.sample.dist
Nokia-N900:~/adb-arm# vi makefile.sample
Nokia-N900:~/adb-arm# diff -U 0 -u makefile.sample.dist makefile.sample
--- makefile.sample.dist
+++ makefile.sample
@@ -5 +5 @@
-TOOLCHAIN= /opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
+#TOOLCHAIN= /opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
@@ -61 +61 @@
-CPPFLAGS+= -std=c++11 
+#CPPFLAGS+= -std=c++11

Nokia-N900:~/adb-arm# chmod +x
Nokia-N900:~/adb-arm# ./
Nokia-N900:~/adb-arm# install adb /usr/local/bin/
Nokia-N900:~/adb-arm# cd
Nokia-N900:~# adb version
Android Debug Bridge version 1.0.31

On Anrdoid device:

Install wirebug via F-Droid

Configure and enable "Mobile hostpot"

Launch wirebug, enable it

Dont' forget to tick USB debugging in settings

On N900:

Connect to resulting access point. Check gateway IP address:

Nokia-N900:~# route -e | grep default | awk '{print $2}'

Connect adb:

Nokia-N900:~# adb connect
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to

Android device should display debugging authorization window:

Accept it, and launch the shell:

Nokia-N900:~# adb shell

shell@a3lte:/ $ uname -a
Linux localhost 3.10.49-641794 #1 SMP PREEMPT Sat Jul 11 00:57:58 KST 2015 armv7l GNU/Linux

shell@a3lte:/ $ grep ^Hardware /proc/cpuinfo
Hardware        : Qualcomm Technologies, Inc MSM8916

shell@a3lte:/ $ exit

Nokia-N900:~# adb kill-server

Blog engine change

Finally migrated blog from unmaintained nanoblogger to jekyll + github pages + custom domain.

RSS feeds and popular content redirected to new location with apache mod_rewrite:

RewriteEngine On
# blog migration
# redirection exceptions first
RewriteRule ^/favicon.(.*)$ - [L]
# feed redirects for feed readers
RewriteRule ^/blog/feed.xml$ [R=301,L]
RewriteRule ^/b/atom.xml$ [R=301,L]
RewriteRule ^/b/rss.xml$ [R=301,L]
# known/indexed articles
RewriteRule rpi_rtl_sdr_and_diy_discone [R=301,L]
# the rest
RewriteRule ^(.*)$ [R=301,L]