Yearly Archives: 2011

Thursday Quote: Michael Lopp

November 17, 2011 » Geek

“The only thing engineers like about a deadline is it’s precision.”

– Michael Lopp

Fixing Broken Droid2 Root

November 16, 2011 » Consume, Geek

I had previously rooted my Droid2, but it was broken when the OTA Gingerbread came down. I don’t really use root for much now that I don’t really develop for Android anymore, but I found a need today, so I decided to re-root.

I found a nicely packaged exploit on rootzwiki, but when I ran it I hit a snag.

My old root was blocking my new root. Lame.

Easy to fix after poking around on the file system.

Essentially it boils down to this:

  1. Manually remove old Superuser.apk
  2. Clean up Superuser.apk data files
  3. Install new super user apk
  4. Link up new su

Details below, but as always YMMV.

Manually remove old Superuser.apk

Make sure you know the full namespace before you delete this file, you will need it later (i.e.

Clean up Superuser.apk data files

Install new super user apk

From here on out you are essentially just finishing up the root script that got skipped.

Link up new su

All done! You should be rooted again.

Pushing a row to the end of a sort with MySQL

November 11, 2011 » Geek

Sometimes you have weird requirements to meet. It’s a fact of life.

One of these requirements I came across recently was outputting a result set in alpha order, but with a specific tuple at the end, instead of where it belongs in the sort.

I decided I’d figure out how to do this in SQL instead of gross rendering or a re-sort.

Please note there are other ways to solve this that are less brittle, but this was in a fairly static data set for a one off solution.

Consider this table:

Now, pull them out in alpha order:

But what if we always want “Other” at the end?

Well, our unique indices allow us to guarantee a conditional sort on the slug (or name).

To do this, we will use the CASE statement.

Here we have two ORDER BY clauses. We first use CASE to return 1 whenever the slug is “other”, and sort on that. Then we sort the sub-groups (“other” and “non-other”) by slug.

CASE is handy for other stuff too, and can handle complex expressions.

Do you ever use CASE?

Thursday Quote: Juan Reyero

November 10, 2011 » Geek

“It is the curse of the engineer: if it can be done, tadalafil it will be done.”

– Juan Reyero
23 visits a day

Replacing Kohana 3 Auth module hashing

November 9, 2011 » Geek

The password hashing in the Auth module provided with Kohana 3.1 is not very good. By default it is a simple sha256 hmac with a global salt.


This isn’t strong. If you loose the hashes and the salt it’s just a matter of winding up a GPU.

So how can we fix this? Well, thanks to Kohana’s structure we can easily override the Auth class and tweak it. However, due to Auth’s structure, we can’t drop the global salt. The hash function has to stand alone, so no passing in salts from the database.

That leaves us with key stretching.

Now, I don’t want to deal with a custom key stretching implementation, I’m not a cryptographer. So, let’s find an existing algorithm.

One that pops to mind is PBKDF2. This is a pretty simple algorithm, so it was easy to find and spot check a PHP implementation

We just take some test vectors from RFC 3962 and run them against the code we found.

Run it, and everything checks out:

So now all that’s left is to drop it in, which is pretty simple. One thing to note is that I wanted this to stay compatible with the default auth config file, so I just extended that a little bit.



One item to note is that I am packing these with base64_encode. This is to fit into the default field type for the ORM driver. That is also why my length is stunted to 45. If you really want to go all out, alter your table to use a TINYBLOB, up the length to 256 bit and up the rounds.

So that is how I replace weak hashing in K3 with something a bit better.

How do you do it?