July 3, 2009: Hacking an embedded chat room.
July 4, 2009: Announcing Chatbox, a webapp for routers.

Original I got a new, easy to hack toy. Embedded web app? Hacking an embedded chat room. Announcing Chatbox, a webapp for routers. Editable
version 3 & 4 of 4

Jenell gave me a very awesome toy, an old Linksys WRT54G router. Turns out this particular model can run third part open source firmware. I choose an OpenWRT derivative, Gargoyle. One really big reason stands behind this: the author provides prebuilt binaries, giving Gargoyle the lowest barrier to entry. The second, smaller reason: Gargoyle is really pretty, in an SVG sort of way. Third reason: amazing support from the author

I feel like adding a crazy feature to it, a chat room. The environment is pretty limited. One MB of free flash, BusyBox utilities, 2.4 series kernel. Most browser based chats expect PHP and MySQL. I found one using just perl. There is not enough free space to even install microperl, so I will have to roll my own. The existing CGI pages are generated through Haserl, a nifty wrapper for shell scripts. Basically, it acts like PHP but with shell scripts as the embedded language. There is some mild, easy to circumvent sandboxing. It is basically a pleasure to use, though I am constantly working around the cut down feature set of BusyBox.


Since everyone must be in range of the AP, throw whatever is handy at any trolls.

It works! All of the javascript issues have been sorted out. The code feels just good enough to release. There are numerous issues that I need to fix. The horrible pain of IE has been . But first, a few buzzwords and features:

  • AJAX - JSON - Captive portal
  • Server enforced security
  • Random, persistent nickname coloring

Thanks to the help of the Gargoyle forums, I was able to turn Gargoyle into a captive portal of sorts. Typically, at a Starbucks for example, the captive portal intercepts your browsing and throws you to a landing page were you are asked to pay for web access. There is no internet to access, so the arrangement is a bit simpler than the typical captive portal. Also, the mechanism used is a very crude form of DNS poisoning. Probably should fix that.

Sadly, it is not usable. You need to know the IP address of the router and the password to get in. Optimally, when not connected to the internet, all URLs would be redirected to the chat room. I've requested help on the Gargoyle forums.

Some more detail on the primary use case: You have people with laptops all packed together, but there is no available wifi. This scenario sound odd and contrived, but I frequently find myself in just such an arrangement whenever traveling. Except for BoltBus, lack of internet is a common deficiency shared by trains, planes and buses.

I'll be making one small addition to the hardware to better support this use case. A small battery backup, made from eight NiMH AAA batteries, will be put inline with the AC adapter. I've designed the dumbest possible slow charger, with automatic switchover when power is lost. It should be enough to run the router for 30 minutes with several active wifi connections. Draining the batteries that fast might be a bad idea, AAs might be a better idea.

Finally, here is the code: chat.sh code, installation instructions inside: chatbox.tar.gz.