Skip to content

Instantly share code, notes, and snippets.

@sarnau
Created September 5, 2018 10:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarnau/0b3a4a1e4a2efe96f786dcb72ac91288 to your computer and use it in GitHub Desktop.
Save sarnau/0b3a4a1e4a2efe96f786dcb72ac91288 to your computer and use it in GitHub Desktop.
Star Money 2 (macOS) accessing the encrypted database
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import keychain
import codecs
from pysqlcipher import dbapi2 as lite
kc = keychain.Keychain()
#kc.set_generic_password('login','StarMoney','PASSWORD',servicename="StarMoney",)
password = kc.get_generic_password('login', 'StarMoney')['password']
locTable = {}
for line in codecs.open("/Applications/StarMoney 2.app/Contents/Resources/%s.lproj/Localizable.strings" % 'en', encoding='utf-16'):
if line.startswith('"'):
key = line[:-1].split('=')
if key:
locTable[key[0].strip('"\t ')] = key[1][:-2].strip('"\t ')
con = lite.connect(os.path.expanduser("~/Library/Containers/de.starfinanz.StarMoney.Mac.2.Global/Data/Library/Application Support/StarMoney/userdata.db"))
with con:
cur = con.cursor()
cur.execute('PRAGMA key = "%s"' % password)
cur.execute('PRAGMA cipher_use_hmac = off')
# cur.execute('PRAGMA cipher_page_size = 1024')
# cur.execute('PRAGMA kdf_iter = 4000')
cur.execute('SELECT rowid,title,color,imagename,uuid FROM "Kategorie" WHERE mainId=%d ORDER BY rowId ASC' % 0)
for row in cur.fetchall():
if row[1] in locTable:
print locTable[row[1]]
else:
print row[1]#,row[2],row[3],row[4]
cur.execute('SELECT rowid,title,color,imagename,uuid FROM "Kategorie" WHERE mainId=%d ORDER BY rowId ASC' % row[0])
for row in cur.fetchall():
if row[1] in locTable:
print ' ',locTable[row[1]]
else:
print ' ',row[1]#,row[2],row[3],row[4]
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment