@@ -67,43 +67,47 @@ def get_key(self, profile, master_password=''):
6767 row = c .next ()
6868
6969 (globalSalt , master_password , entrySalt ) = self .manage_masterpassword (master_password = '' , key_data = row )
70- if not globalSalt :
71- return None
72-
73- # Decrypt 3DES key to decrypt "logins.json" content
74- c .execute ("SELECT a11,a102 FROM nssPrivate;" )
75- a11 , a102 = c .next ()
76- # a11 : CKA_VALUE
77- # a102 : f8000000000000000000000000000001, CKA_ID
78- self .printASN1 (a11 , len (a11 ), 0 )
79- """
80- SEQUENCE {
70+ if globalSalt :
71+ # Decrypt 3DES key to decrypt "logins.json" content
72+ c .execute ("SELECT a11,a102 FROM nssPrivate;" )
73+ a11 , a102 = c .next ()
74+ # a11 : CKA_VALUE
75+ # a102 : f8000000000000000000000000000001, CKA_ID
76+ self .printASN1 (a11 , len (a11 ), 0 )
77+ """
8178 SEQUENCE {
82- OBJECTIDENTIFIER 1.2.840.113549.1.12.5.1.3
8379 SEQUENCE {
84- OCTETSTRING entry_salt_for_3des_key
85- INTEGER 01
80+ OBJECTIDENTIFIER 1.2.840.113549.1.12.5.1.3
81+ SEQUENCE {
82+ OCTETSTRING entry_salt_for_3des_key
83+ INTEGER 01
84+ }
8685 }
86+ OCTETSTRING encrypted_3des_key (with 8 bytes of PKCS#7 padding)
8787 }
88- OCTETSTRING encrypted_3des_key (with 8 bytes of PKCS#7 padding)
89- }
90- """
91- decodedA11 = decoder .decode ( a11 )
92- entrySalt = decodedA11 [0 ][0 ][1 ][0 ].asOctets ()
93- cipherT = decodedA11 [0 ][1 ].asOctets ()
94- key = self .decrypt3DES (globalSalt , master_password , entrySalt , cipherT )
88+ """
89+ decodedA11 = decoder .decode ( a11 )
90+ entrySalt = decodedA11 [0 ][0 ][1 ][0 ].asOctets ()
91+ cipherT = decodedA11 [0 ][1 ].asOctets ()
92+ key = self .decrypt3DES (globalSalt , master_password , entrySalt , cipherT )
93+ if key :
94+ yield key [:24 ]
95+
9596 except :
97+ pass
98+
99+ try :
96100 key_data = self .readBsddb (os .path .join (profile , 'key3.db' ))
97101
98102 # Check masterpassword
99103 (globalSalt , master_password , entrySalt ) = self .manage_masterpassword (master_password = '' , key_data = key_data , new_version = False )
100- if not globalSalt :
101- return None
102-
103- key = self .extractSecretKey (key_data = key_data , globalSalt = globalSalt , master_password = master_password , entrySalt = entrySalt )
104+ if globalSalt :
105+ key = self .extractSecretKey (key_data = key_data , globalSalt = globalSalt , master_password = master_password , entrySalt = entrySalt )
106+ if key :
107+ yield key [:24 ]
108+ except :
109+ pass
104110
105- if not key : return None
106- return key [:24 ]
107111
108112 def getShortLE (self , d , a ):
109113 return unpack ('<H' ,(d )[a :a + 2 ])[0 ]
@@ -380,8 +384,7 @@ def run(self, software_name=None):
380384 for profile in self .get_firefox_profiles (path ):
381385 print_debug ('INFO' , u'Profile path found: {profile}' .format (profile = profile ))
382386
383- key = self .get_key (profile )
384- if key :
387+ for key in self .get_key (profile ):
385388 credentials = self .getLoginData (profile )
386389
387390 for user , passw , url in credentials :
@@ -396,4 +399,4 @@ def run(self, software_name=None):
396399 except Exception , e :
397400 print_debug ('DEBUG' , u'An error occured decrypting the password: {error}' .format (error = e ))
398401
399- return pwdFound
402+ return pwdFound
0 commit comments