Skip to content

Instantly share code, notes, and snippets.

@matsu911
Last active December 23, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsu911/6608998 to your computer and use it in GitHub Desktop.
Save matsu911/6608998 to your computer and use it in GitHub Desktop.
require 'digest/sha1'
require 'sqlite3'
def sha1(s)
Digest::SHA1.hexdigest(s)
end
backup_dir = '1b345454cbec76848e94c41ce0a2d6b7328973e9'
backup_path = "#{ENV['HOME']}/Library/Application Support/MobileSync/Backup/#{backup_dir}"
domain = "HomeDomain"
file = "Library/AddressBook/AddressBook.sqlitedb"
hash = sha1 "#{domain}-#{file}"
db = SQLite3::Database.new "#{backup_path}/#{hash}"
db.execute("select ROWID, ABPerson.first,ABPerson.last, ABPerson.organization from ABPerson").each do |row|
data = Hash[header.zip(row)]
db.execute("select ABMultiValueLabel.value, ABMultiValue.value from ABMultiValue, ABMultiValueLabel where ABMultiValueLabel.ROWID=ABMultiValue.label and record_id=#{row[0]}").each do |row|
data = data.merge(Hash[[row]])
end
p data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment