Skip to content

Commit

Permalink
check logins.json exists (PR 299)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroZ committed Oct 2, 2018
1 parent 22197ed commit d433a88
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
26 changes: 15 additions & 11 deletions Linux/lazagne/softwares/browsers/mozilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,21 @@ def get_login_data(self, profile):
try:
c.execute('SELECT * FROM moz_logins;')
except sqlite3.OperationalError: # Since Firefox 32, json is used instead of sqlite3
loginf = open(os.path.join(profile, 'logins.json'), 'r').read()
json_logins = json.loads(loginf)
if 'logins' not in json_logins:
self.debug('No logins key in logins.json')
return logins
for row in json_logins['logins']:
enc_username = row['encryptedUsername']
enc_password = row['encryptedPassword']
logins.append((self.decode_login_data(enc_username),
self.decode_login_data(enc_password), row['hostname']))
return logins
logins_json = os.path.join(profile, 'logins.json')
if os.path.isfile(logins_json):
with open(logins_json) as f:
loginf = f.read()
if loginf:
json_logins = json.loads(loginf)
if 'logins' not in json_logins:
self.debug('No logins key in logins.json')
return logins
for row in json_logins['logins']:
enc_username = row['encryptedUsername']
enc_password = row['encryptedPassword']
logins.append((self.decode_login_data(enc_username),
self.decode_login_data(enc_password), row['hostname']))
return logins

# Using sqlite3 database
for row in c:
Expand Down
26 changes: 15 additions & 11 deletions Mac/lazagne/softwares/browsers/mozilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,21 @@ def get_login_data(self, profile):
try:
c.execute('SELECT * FROM moz_logins;')
except sqlite3.OperationalError: # Since Firefox 32, json is used instead of sqlite3
loginf = open(os.path.join(profile, 'logins.json'), 'r').read()
json_logins = json.loads(loginf)
if 'logins' not in json_logins:
self.debug('No logins key in logins.json')
return logins
for row in json_logins['logins']:
enc_username = row['encryptedUsername']
enc_password = row['encryptedPassword']
logins.append((self.decode_login_data(enc_username),
self.decode_login_data(enc_password), row['hostname']))
return logins
logins_json = os.path.join(profile, 'logins.json')
if os.path.isfile(logins_json):
with open(logins_json) as f:
loginf = f.read()
if loginf:
json_logins = json.loads(loginf)
if 'logins' not in json_logins:
self.debug('No logins key in logins.json')
return logins
for row in json_logins['logins']:
enc_username = row['encryptedUsername']
enc_password = row['encryptedPassword']
logins.append((self.decode_login_data(enc_username),
self.decode_login_data(enc_password), row['hostname']))
return logins

# Using sqlite3 database
for row in c:
Expand Down

0 comments on commit d433a88

Please sign in to comment.