Parser/ Importer for the IEEE OUI list

posted 2010-08-07 01:14:19, link to this article
Read full article

In a distant past I created this vendor lookoup page for MAC addresses, that according to my Google Analytics is still being used from all over the world. Wow.
Most of the information in this tool was pretty outdated, because I had imported the IEEE oui.txt file in a SQLite database by hand and was too lazy to do that again.
Well, today I found some old Perl code back that I started on to automate this process. I never managed to get that to work in the past, somehow it worked after only a few edits today.
I quickly added some SQLite Perl DBI stuff, and suddenly the database for mac2vendor is up to date again.

I have published my code to download, parse and import the IEEE OUI file here or follow the read link for the full article.

From now on this script will run as a cronjob from time to time to keep mac2vendor more up to date.

Why I love HTTP

posted 2010-04-25 13:01:16, link to this article

A few years ago, I worked at a company whose webservers were hosted at a dedicated web-hosting company.
The question rose whether their website could be reached at foo.bar as well as at www.foo.bar.
Well, no problem you'd say, nothing that a simple A or CNAME record in DNS couldn't fix.
Not so, foo.bar had an A record assigned already for a host in the company's DMZ that used to do a *lot* of stuff.

You can imagine adding a webserver to foo.bar, just to serve 301 moved permanently status codes seemed like a bit of overkill to me.
And apart from that, I was too lazy to have another $many_lines_of_code to keep up to date for such a trivial task.

Thanks to the wonders of HTTP the solution was almost as simple as the problem.
I whipped up a small text file containing a static HTTP 301, and used the almighty inetd and cat to glue this to a socket.
It worked like a charm. It was also great to see sites like Netcraft list the webserver of foo.bar as cat/0.9. :-)

I thought of this today, when I was playing a bit with my Nintendo DS running DSLinux.
I could find various MP3 decoders, but nothing to do streaming. So I kludged together the other side of the hack that I explained above:

        #!/bin/sh
        (nc mp3.streampower.be 80 <<_GETREQ
        GET /stubru-low.mp3 HTTP/1.0

        _GETREQ
        ) | sed -n '/^$/,$p' |\
                madplay -

Et voila. Streaming audio. (In this case the Belgian music station Studio Brussel.)
Thank you, sir Tim.

Sitecom WL-340 shell commands via HTTP

posted 2010-04-18 16:40:26, link to this article

My local Media Markt (a large German chain of electronics stores) had some cheap NAT routers for sale. Out of curiosity I bought one.
This router (the Sitecom WL-340) runs Linux and the internal console port is nicely labeled and that alone made me buy two more as you can never have too much hardware to play with. ;)

When poking around in these boxes I found that they have a nice hidden web page to run commands on these boxes.
You can access this page as /system_command.htm on your routers webinterface.

I thought it might be useful to access this command shell from scripts, so that you can use stock WL-340s for various "unintended" purposes. ;)
With the help of the amazing Firebug extension for Firefox I managed to use the remote command facility of these routers from the shell.
Like so:

hessch@kirchhoff:~$ curl -s -o- -u admin -d command='cat /proc/cpuinfo' \
	-d next_file=system_command.htm -d todo=system_command \
	http://192.168.11.128:8080/setup.cgi | \
		sed -n '/outlog_Display/,/\/textarea/{/textarea/d;p}'
Enter host password for user 'admin':
system type		: Ralink SoC
processor		: 0
cpu model		: MIPS 24K V4.12
BogoMIPS		: 212.99
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes
ASEs implemented	: mips16 dsp
VCED exceptions		: not available
VCEI exceptions		: not available

Now, this only needs a small wrapper shell script and it's ready for (ab)use.
I'll probably post some more hacks based on these boxes later on.

isquared.nl via IPv6

posted 2010-04-15 20:20:33, link to this article

My ISP, XS4All started a pilot with native IPv6 over DSL, which I eagerly joined.

I have been playing with 6to4 tunnels for a few years, but the old Cisco routers that I used lacked performance and reliability was also an issue.
Well both issues were actually solved a year ago when I terminated my Hurricane Electric IPv6 tunnel in a Apple Airport Express. But alas, the Express added a new problem: it routes IPv6 to the wireless network only!

Well, all these issues seem to be solved now. IPv6 is now present on both my wired and wireless networks and my Juniper firewall doesn't seem to break a sweat.
And as a test isquared.nl should now be reachable via IPv6 at the address http://www.isquared.nl/
If this test is successful this website will be available via IPv6 without the dubdubdub pretty soon too.

As an bonus, I've added a small "Your IP address is" row to the navigation bar on the left, to see whether your source address is IPv6 or IPv4. And you might find it useful to test your anonymizing proxy, etc... ;-)

GSM IMSI, MCC and MNC lookup tool

posted 2009-06-28 18:59:33, link to this article
Read full article

I've written a small tool to decode (or well, that is a big word for taking some substrings ;) ) GSM IMSI (International Mobile Subscriber Identity) numbers.
It then takes the MCC (Mobile Country Code) and MNC (Mobile Network Code) pair, looks it up, and presents you a mobile operator name and country.

Alternatively, you can search by just a MCC or MNC value, or both, and again, it lists all matches.

Follow the read link to give it a try.

DriveReady SeekComplete Error

posted 2009-06-28 09:17:33, link to this article

Oops, isquared.nl had some unscheduled downtime last night after the telltale signs of a dying disk:

Jun 28 01:09:07 c3 kernel: [  184.700869] hda: dma_intr: status=0x51 { DriveReady SeekComplete Error }
Jun 28 01:09:07 c3 kernel: [  184.700869] hda: dma_intr: error=0x10 { SectorIdNotFound }, LBAsect=20586, sector=20407
Jun 28 01:09:07 c3 kernel: [  184.700869] ide: failed opcode was: unknown

One emergency dd to a disk, stolen from my old TV set-top box, later and we're up and running again.
Only a shame that due to the layout of the partitions on the dead disk, I can't grow my filesystems easily to make use of the much larger disk that is transplanted to the server.

JavaScript unit conversion gadget brings lots of RegEx fun

posted 2009-06-07 20:39:38, link to this article

My girlfriend started a cooking blog recently, if you want to keep track of what I eat, I suggest you subscribe to her feed. ;)
To help her American followers (and others suffering under the burden of a unit system from the middle ages), I kludged together a little gadget to add to her Blogger pages. The gadget tries to convert a few metric units to something equivalent in stones, feet and that Fahrenheit thing.

Doing so, I learned a nifty thing about JavaScript regular expressions. The replace method in JavaScript 3 makes it possible to call a function to return the replacement string. This way, I can match value, a possible prefix and unit, make backreferences and pass those to a conversion function and replace the matched text in the blog posts with converted values in one go, like so:

var re = /(\d+|\u00bd) ?([mcdk]|(?:mili|centi|deci|kilo))?(g(?:r|ram)?|l(?:iter)?|c(?:elcius)?)\b/gi;

function knvrtit() {
        var entries = document.getElementsByClassName('entry-content');

        for (var i = 0; i < entries.length; i++) {
                entries[i].innerHTML = entries[i].innerHTML.replace(re, das_Konvertor);
        };
}

But, what is that unicode \u00bd, you say? Oh, well as it happens some keyboard layouts have a 1/2 character and some people like to use it as well....

Das_Konvertor() then does it's magic using a case construct to multiply values based on the prefix of a unit, and then uses a second case construct to decide to convert in what way based on the type of unit encountered.
The code for das_Konvertor() is a bit long, but it looks somewhat like this:

function das_Konvertor (str, value, prefix, unit, offset, s) {
        // do stuff
        return string_in_imperical_units;
}

It would be fun, and very web2.0ish to, instead of doing my own ugly conversions, pass the calculation to be done to the almighty Google calculator in an XMLHttpRequest and display the result. If it keeps raining in the weekends, I might do so. ;)

TagPop: the making of

posted 2009-05-19 12:28:36, link to this article
Read full article

As promised before, here is a description of the inner workings of TagPop.

TagPop is a tag cloud of all tags used on this website, in which the size of each tag represent its popularity among the visitors of this site. The popularity is measured based on pageviews of individual articles.

NS Zet bussen in (in Dutch)

posted 2009-05-17 10:18:13, link to this article

"NS zet bussen in" is een iCal feed gemaakt van de aankondigingen van werkzaamheden op de NS website.
De aankondigingen op de NS site zijn slecht te lezen door computers, ik heb geprobeerd deze zo goed en zo kwaad mogelijk om te zetten naar "all-day" events.

De feed is beschikbaar op http://isquared.nl/nszetbussenin.ics, deze feed is (bijvoorbeeld) in Google Calendar als gedeelde agenda toe te voegen. Op deze manier weet je de volgende keer vooraf of er werkzaamheden zijn op weg naar de afspraak die je probeert te maken.

TagPop Visualizes tags by popularity

posted 2009-04-22 17:59:45, link to this article
Read full article

The tag cloud on the left side of this page displays tags assigned to articles. The size of each tag is determined on the number of articles to which this tag is assigned.

I was interested how this tag cloud looks like when the size is determined by the popularity of articles tagged with a certain tag among readers of isquared.nl.

To visualize this I have hacked together a quick application, called TagPop, to display the tags based on popularity, this is available here.

In a later post I will write more about the inner workings of TagPop.

Online MAC Address Vendor lookup

posted 2008-11-23 01:59:42, link to this article
Read full article

I have made an online version of my MAC address vendor lookup script. Of course there are many of these already, but well, choice is good, right? You can query my vendor lookup tool here: http://isquared.nl/doapp.html?appid=mac2vendor

Bourne/ Bash Shell CGI Scripts

posted 2008-11-01 21:49:09, link to this article
Read full article

Usually I do my server-side scripting in Perl, but some time ago when writing CGI scripts for an embedded system I ran into memory and flash space contraints. Because the system used Busybox, I had the Bourne compatible ash shell available.

So I wrote a very small Bourne shell script to include in my CGI scripts, which I share here, maybe it is of use to someone.