Skip to content

Commit

Permalink
mozilla update fix
Browse files Browse the repository at this point in the history
The situation when key3.db version updates to key4.db version and both files are present.
  • Loading branch information
m41nt41n3r authored Mar 20, 2018
1 parent c6e72c2 commit 31d1b43
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions Windows/lazagne/softwares/browsers/mozilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,47 @@ def get_key(self, profile, master_password=''):
row = c.next()

(globalSalt, master_password, entrySalt) = self.manage_masterpassword(master_password='', key_data=row)
if not globalSalt:
return None

# Decrypt 3DES key to decrypt "logins.json" content
c.execute("SELECT a11,a102 FROM nssPrivate;")
a11, a102 = c.next()
# a11 : CKA_VALUE
# a102 : f8000000000000000000000000000001, CKA_ID
self.printASN1(a11, len(a11), 0)
"""
SEQUENCE {
if globalSalt:
# Decrypt 3DES key to decrypt "logins.json" content
c.execute("SELECT a11,a102 FROM nssPrivate;")
a11, a102 = c.next()
# a11 : CKA_VALUE
# a102 : f8000000000000000000000000000001, CKA_ID
self.printASN1(a11, len(a11), 0)
"""
SEQUENCE {
OBJECTIDENTIFIER 1.2.840.113549.1.12.5.1.3
SEQUENCE {
OCTETSTRING entry_salt_for_3des_key
INTEGER 01
OBJECTIDENTIFIER 1.2.840.113549.1.12.5.1.3
SEQUENCE {
OCTETSTRING entry_salt_for_3des_key
INTEGER 01
}
}
OCTETSTRING encrypted_3des_key (with 8 bytes of PKCS#7 padding)
}
OCTETSTRING encrypted_3des_key (with 8 bytes of PKCS#7 padding)
}
"""
decodedA11 = decoder.decode( a11 )
entrySalt = decodedA11[0][0][1][0].asOctets()
cipherT = decodedA11[0][1].asOctets()
key = self.decrypt3DES(globalSalt, master_password, entrySalt, cipherT)
"""
decodedA11 = decoder.decode( a11 )
entrySalt = decodedA11[0][0][1][0].asOctets()
cipherT = decodedA11[0][1].asOctets()
key = self.decrypt3DES(globalSalt, master_password, entrySalt, cipherT)
if key:
yield key[:24]

except:
pass

try:
key_data = self.readBsddb(os.path.join(profile, 'key3.db'))

# Check masterpassword
(globalSalt, master_password, entrySalt) = self.manage_masterpassword(master_password='', key_data=key_data, new_version=False)
if not globalSalt:
return None

key = self.extractSecretKey(key_data=key_data, globalSalt=globalSalt, master_password=master_password, entrySalt=entrySalt)
if globalSalt:
key = self.extractSecretKey(key_data=key_data, globalSalt=globalSalt, master_password=master_password, entrySalt=entrySalt)
if key:
yield key[:24]
except:
pass

if not key: return None
return key[:24]

def getShortLE(self, d, a):
return unpack('<H',(d)[a:a+2])[0]
Expand Down Expand Up @@ -380,8 +384,7 @@ def run(self, software_name=None):
for profile in self.get_firefox_profiles(path):
print_debug('INFO', u'Profile path found: {profile}'.format(profile=profile))

key = self.get_key(profile)
if key:
for key in self.get_key(profile):
credentials = self.getLoginData(profile)

for user, passw, url in credentials:
Expand All @@ -396,4 +399,4 @@ def run(self, software_name=None):
except Exception, e:
print_debug('DEBUG', u'An error occured decrypting the password: {error}'.format(error=e))

return pwdFound
return pwdFound

0 comments on commit 31d1b43

Please sign in to comment.