Wednesday, May 21, 2014

Raspberry Pi is really really fun...

Raspberry Pi is really really fun to use.  Really. I keep expanding my list of things to do.

1. Map the network and post results to RabbitMQ queue
2. Install NoSQL datastore (perhaps Redis or MongoDB) to store network info
3. Make an RaspBMC Server (following an XBMC DIY blog post)
4. Create a grid computing system based on nothing but Raspberry Pis, and use the computing power to take over the world!

Okay, I might be getting a little carried away, but it's crazy how many things you can do with the Raspberry Pi!

I continued with the "mapping the network" idea.

This is what I have done so far:

1. Installed RabbitMQ on the Raspberry Pi
2. Created a queue for holding nmap (network mapping program) info
3. Installed Java on the Raspberry Pi
4. Created a Java app that will parse nmap results and can send the results to the RabbitMQ nmap info queue
5. Created a cron job that will run the nmap command, and then execute the Java app
6. Created an Android app that will read from the queue and display the results

I plan to expand the Android app so that it will do something with the info.  One idea is to install OpenAP on a wireless AP hub, and then have the app block specific MAC addresses.  Or perhaps permanently assign specific IPs to certain MAC addresses.  Not sure yet.  Ideas?

Below is a screen shot of the Android app. It shows the OS type based on info that nmap was able to fetch from the machine. The grey WiFi symbol is for a machine that nmap wasn't able to determine the OS type.  Also, nmap wasn't able to recognize the Raspberry Pi, so I added code to check the vendor of the MAC address.  If the vendor name started with "edimax" (Edimax is the manufacturer of the WiFi dongle the Raspberry Pi is using), then I set the OS type to Raspberry Pi. I made a similar assumption for my Samsung phone - which is not shown below, but is displayed using an Android icon. The app is named NetHutch - which doesn't necessarily make sense except that I happen to be pulling network info from RabbitMQ.

I'll create a post with some of the Android code soon. Until then, I will update the app to list the date and times that network mappings were performed on the main screen, and the details of which hosts were found on the next screen.

Here is a wire frame view of what the update will look like (once I get the time to make the changes). I used Evolus Pencil to create the wire frame. The numbers to the right of the date on the first screen will be the number of hosts found.

Tuesday, May 13, 2014

Raspberry Pi fun...

I received a Raspberry Pi for Christmas and I hadn't found a good use for it yet - until now!  Well, sort of.  I at least found something kind of fun to do with long as your definition of fun is very loose.

I've been using RabbitMQ at work, and I found someone's post about running RabbitMQ on their Raspberry Pi.  "A ha!", I thought. "I'll load interesting messages onto channels, and then I can write an Android app that will fetch the messages.  It will be so amazing!"  The problem is that I couldn't think of what type of data I would want to get.  I ended up deciding to capture all IP addresses on my home network using nmap.

I installed RabbitMQ on the Raspberry Pi by following someone's blog post (very well written!), and then added a user and virtual host. I then wrote a script and some Java code to log all of the IP addresses on my local network. We have a number of devices that connect and disconnect throughout the day, so there would be enough of a change as time goes on to make it interesting.

The script runs nmap to get the network info, and then it calls some Java code that publishes the info to a RabbitMQ channel. I decided to use Java because it was the easiest for me to write the code. I might redo the code in Python once I get some experience with Python.

The nmap command is pretty straight forward: 

sudo nmap -oX myscaninfo.xml

The -oX parameter tells nmap to output the results in xml format.  

The IP address with the CIDR (Classless Inter-Domain Routing) value at the end ( specifies the IP addresses to scan.  In the example above, it would mean the following: is the starting IP address. We would then mask the address with 24 1 bits =>  255 is what 11111111 equals (-1 due to 0 based index).  That means that we would want to view all IP address that are in the unmasked range - to

The Java code parses the XML and pulls out all the address info. It then pairs the IP address with a MAC address, and publishes the data to RabbitMQ.

The next step will be to create an Android app to read from the channel and display the data.