How to get registration from ICAO 24 bit code?
Apparently (according to these folks) some countries use an algorithm to generate their ICAO (Mode S) 24-bit IDs. For those countries, you can simply reverse the algorithm and get a registration given the Mode S ID.

Others countries allow you to download their registration database, complete with the Mode S identifier (you can get the US registration database here) - it's a simple matter to load this into your own software and map the ICAO/Mode S ID code to a registration number.

As the folks at Gatwick Aviation Society have noted, some countries are tight-lipped about how their codes are assigned (and who they're assigned to), so these lookups are probably not complete.