Digital Jersey Medical Hackathon

This my story of entering the Digital Jersey Medical Hackathon which took place over last weekend, now that I have recovered from lack of sleep.

The Concept

To build a low cost open source messaging platform using a Raspberry Pi, MQTT broker and a custom version of Android with a web app to monitor air quality. The name of the project was called “Health Stage”

Friday Night

I got to Digital Jersey  early on friday evening to setup, I choose one of the side rooms as it has a wall mounted TV with a good sized desk. As you can see, I had quite a bit of equipment with me for the build.

INITIAL sETUP

At 20:00 hours, the hackathon started, so I started my build of Android whilst soldering the pcb daughter board for the Raspberry Pi. By just after 11:00, the pcb was soldered, so next came polarity checking to make sure it was all good.

Yeah, we have a powered board that did not go bang!!!

Working Board

So I had basic hardware build out of the way, but this is when I hit “the software wall”. A mix of library issues, caused sensors  to provide no data, as well as not seating boards correctly. Also the Android build had an issue, which could not be corrected remotely correctly. At just before 2 a.m, I decided that was it, time to go home to kick off the Android build and get some sleep at about 02:30 a.m.

Saturday

I woke up at about 07:30 a.m, checked my Android build on my server at home, it had completed. Next, I had some breakfast, transferred it to the phone and tried to “boot it”. The phone booted fine after a cache wipe, so that was another objective completed, the “about phone ” screen is shown below:-

Build state rom

On returning back to DJ at  around 11:30 a.m, it was obvious that some people had pulled an “all-nighter”, @JerseyITGuy was still in the corner seat where I had left him the night before. The the next few hours were spent breaking and fixing various software libraries. I ended up writing some custom python to get one of the sensors (AM2302 Temperature and Relative Humidity) working. I went out to lunch with the family and then returned to start building the Health Stage website, as I now had sensor data going to the internet.

At this point, I still had to build the MQTT broker, website and dashboard. It became clear that I would have to abandon building the broker  in order to get over the finishing line. So the point I want to make, is that you should have a plan that is flexible enough to cope with road blocks induced by time and or other factors.

So I set about building the website. Around 7 p.m, the majority of the website was uploaded. Lastly, there was the dashboard to code. I had allowed the whole of Saturday afternoon to code it, as I had recognised it was my weakest area of the build. I then had to reassess my plan once again, using freeboard.io directly for the dashboard rather than integrating it in the website.

By 10.00 p.m, I decided to stop and let the system settle down as I had live data on the dashboard at http://www.healthstage.co.uk/live.html with the web application left to finish. A few of the hackathon competitors, decided to adjourn for a beer / cider across the road. I walked home after that to bed.

Working Dashboard.

Sunday

I got to DJ just after 8 a.m, I decided to get my submission out of the way and then concentrate on the web application. I had a basic shell of an application to build and then I hit more software issues with the Android SDK, it became clear I was not going to solve it before the presentations.

At around this time, I saw Bendict who came in to see how the project was going. I showed him the project running with the light level, that I was going to demonstrate. Suddenly,to mu surprise, Benedict picked up his vape stick and blew on the contaminant sensor, it reacted crazy showing a large decrease in air quality. I asked Benedict, if he would not mind polluting the sensor during my presentation.

The Pitch

The four minute pitch went well, with the demo working perfectly, demonstrating the light level and Benedict’s pollution.

The Judging

I did not envy the judge’s task, as all the pitches were of an incredible standard with an amazing amount of variety of ideas. Everyone waited for the decision. Third place was awarded to MyGP, for their app which enabled better patient and doctor communication. Next second place. Boom, it was awarded to my project. I collected my prize (“a green laser printed robot trophy” plus £500) feeling immense. Now it was just time to see who had won.  The winner were Beacon, an app to help people call emergency services to their location. Here is my cool green robot trophy.

A Cool Trophy

The Future

The project is currently running as an indoor sensor with a thirty second update interval. I hope to move it outside, in an enclosure soon.

I will continue to work on the project, as I want to finish the web application part. In the next few weeks, I will putting up a detailed build guide and software configuration in the cyberkryption github repository. I intend to redesign the pcb, so that the modified sensors can be properly installed with jumper wires.

In the near future, I hope to get my hands on a “ehealth” shield and a set of sensors with a view to integrating it all with the new raspberry pi touchscreen. I also hope that we can get the air monitoring live in a few locations as well.

A Final Thank You

Finally, I would just like to thank the event sponsors and  Digital Jersey for a great event.

Regards

Cyberkryption

Kali Linux 1.10 on a Pi-2 Update

Hi, this is an update on Kali 1.10 after my last post. It appears Muts(@kalilinux) and the Offensive Security crew have updated their github repo. Within the kali-arm-build-scripts is a new script for the Raspberry Pi-2 called rpi2.sh. The stages to build the image are as follows:-

  • gitclone the offensive security repository
  • put the the kernel image file in the kernel configs directory from here, making sure it is called ‘rpi-3.1.8.config’.
  • run the ‘rpi2/sh. 1.1.10’
  • burn the image to your sdcard

In bash, it goes something like this :-

mkdir arm-stuff
cd arm-stuff
<code>git clone https://github.com/offensive-security/gcc-arm-linux-gnueabihf-4.7
export PATH=${PATH}:/root/arm-stuff/gcc-arm-linux-gnueabihf-4.7/bin</code>
git clone https://github.com/offensive-security/kali-arm-build-scripts
cd kernel-configs
wget https://github.com/yhfudev/arch-kali-rpi2/blob/master/rpi2-3.19.config -O rpi-3.1.8.config
cd ..
./rpi2.sh 1.10
dd bs=4M if=kali-image-name of=/dev/mmcblk0

The good news, is that the image has a patch for wireless injection for the 3.18 kernel and we should not need to copy the /lib/modules across as we have had to in previous builds. The only extra task, I would consider is to copy a config.txt to the boot directory to assign more graphics memory from the XFCE desktop. You can get one here.

Screenshot

desktop

In a further development, I received a comment from comment from YunHui Fu about a script that he has developed which not only builds Kali Linux but also Arch Linux with the wireless patches as well. YunHui github repo is here and you can build it as follows:-


git clone https://github.com/yhfudev/arch-kali-rpi2.git
cd arch-kali-rpi2
./runme.sh

Update

In order to build by YunnHui method, you need to use a Ubuntu host or soething similiar with Glibc > 2.14 otherwise the build will fail, a good choice would be Ubuntu 14.04.

You will need to make sure that you have alll the dependancies sorted, so use the ‘builddeps.sh’ script from the kali arm repository above. Note ‘boot-umakeimage’ is now superseeded by ‘u-boot-tools’ and ia32libs is replaced by a number of packages, these are lib32z1,lib32ncurses5 and lib32bz2-1.0 respectively.

I am currently building Yunn Hui’s build and will post some screen shots on here.

Regards

Cyberkryption

Kali-1.1.10 on a Raspberry Pi-2

I’m back and building Kali 1.1.10 for my raspberry Pi-2 with  the kernel from the latest raspbian image at the time of writing, which is 2015-02-16-raspbian-wheezy.img. The video below shows the actual image running, apologies for tint in the video.

The procedure is pretty much the same as per my previous post here, so if you have not read it, please read it first.

The kernel configuration was taken from the above raspbian image and is pastebin’ed here. Simply save it in the kernel configs directory within the kali-arm build system.

Update – 23/02/2015

I would also recommend modify the kernel configuration as per Step 10 here, although I did not do this in my initial build.

Now go ahead and run the rpi.sh script and go get a cup of something as you will have to wait a while..

Now that it is built and you have burned it to your sd card, a word or two about the ‘modules’ problem.

‘Modules’ problem

On my Pi-2, the normal raspbian image has the following modules loaded shown below

pi-modules

Now, if you do the same on your kali image, you will find that no modules are loaded. The upshot of this is that when you try to ‘startx’ everything will freeze. The solution to the problem is shown below:-

  1. mount the raspbian image,
  2. delete the contents of lib/modules directory on your kali image that is burned to your sd card
  3. copy the contents of lib/modules from raspbian image to kali image.

Mounting the raspbian is easy and is shown below:-

mount-raspbian

Now use your favourite graphical file manager to do the rest. The problem is that during the build process, the kernel was patched for wireless injection. Copying the files from the raspbian image breaks this, leaving us with a kernel not patched for injection. In order to resolve this, we patch the running kernel on the Pi-2, recompile and install the kernel.

Kernel Recompilation

The procedure for recompiling the kernel goes like this

sudo apt-get install linux-source
sudo apt-get install bc gcc gcc-4.6 libc-bin libc-dev-bin libc6 libc6-dev linux-libc-dev make manpages-dev
git clone --depth=1 https://github.com/raspberrypi/linux
cd linux
zcat /proc/config.gz > ~/linux/arch/arm/configs/pi_defconfig
mkdir -p ../patches
wget https://raw.github.com/offensive-security/kali-arm-build-scripts/master/patches/kali-wifi-injection-3.12.patch -O ../patches/mac80211.patch
patch -p1 --no-backup-if-mismatch < ../patches/mac80211.patch
make pi_defconfig
make modules
make modules install
sudo cp /boot/kernel.img /boot/kernel-bup.img
sudo cp arch/arm/boot/Image /boot/kernel.img

So now, we havewireless injection working.

 [Optional] – Raspi-Config Package

In order to add the raspi-config package to overclock etc. Simply watch the video and down load the deb packages and install in the correct order.

From the command line, it goes something like this, but I just downloaded them using my browser on the Pi-2.

wget http://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20150131-1_all.deb
wget http://http.us.debian.org/debian/pool/main/l/lua5.1/lua5.1_5.1.5-4+deb7u1_armhf.deb
wget http://http.us.debian.org/debian/pool/main/t/triggerhappy/triggerhappy_0.3.4-2_armhf.deb
dpkg -i triggerhappy_0.3.4-2_armhf.deb
dpkg -i lua5.1_5.1.5-4+deb7u1_armhf.deb
dpkg -i raspi-config_20150131-1_all.deb

Enjoy, That’s all Folks

Kali Linux on a Raspberry Pi 2

First git clone the kali linux arm repo from https://github.com/offensive-security/kali-arm-build-scripts

Now modify, the architecture in the rpi.sh script to read “armhf” rather “armel” as the Raspberry Pi 2 has a different processor architecture

rpi-mod1

Create our kernel configuration by copying the one that is pastebin’d here

Save the file as “rpi-3.1.8.config” in the kernel config directory.

Modify  the rpi.sh script to use our new kernel configuration.

rpi-mod2

Now run the rpi.sh command, if all goes well, you should see something like below.

kali-complete

14/02/2015 Update

You will probably encounter a problem with ‘startx’ command freezing the ‘X’ environment with the build. If this is the case, then look at the kali linux forum post here.

The solution is essentially to copy the /lib/modules directory from the Raspbian image. I will look at modifying the build script to solve this in the near future.