How can I extract contacts from an iTunes backup of an iPhone?

I have an iTunes backup of an iPhone, and I want to extract the contacts from there as a file, e.g., vcf or csv.

There are many advertised paid software packages. Is there any free option?


Well, you can use this simple script I made half a year ago, but decided to publish when saw your question.

It renames all files to their normal names. After that you can find AddressBook in HomeDomain/Library/AddressBook/AddressBook.sqlitedb

It's not CSV, but quick look through it show that you should take a "person" from ABPerson table (ROWID, First and Last are the most interesting).
After that you look up persons in ABMultiValue table: ROWID acquired in previous step links to record_id, value has the actual value, and label seems to be really weird for me. I'd recommend you to take all values looking as numbers.

Hope you have some programming skills or know someone who can help you.
If not, I could look into making some kind of helper script for it, but can't promise anything.
Those shitty paid apps always made me angry, and I can't understand why is there no FOSS apps for recovering data from iTunes backups. Meh.