Skip to content

Commit

Permalink
Iterate through all unlocked keyrings
Browse files Browse the repository at this point in the history
  • Loading branch information
n8henrie committed Apr 18, 2017
1 parent 6422aef commit c55c9c7
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pycookiecheat/pycookiecheat.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def clean(x):
'~/Library/Application Support/Google/Chrome/Default/Cookies'
)

# If running Chromium on Linux
elif sys.platform.startswith('linux'):

# Set the default linux password
my_pass = 'peanuts'

# Try to get from Gnome / libsecret if it seems available
# https://github.com/n8henrie/pycookiecheat/issues/12
try:
Expand All @@ -87,16 +89,20 @@ def clean(x):
service = Secret.Service.get_sync(flags)

gnome_keyring = service.get_collections()
unlocked_keyring = service.unlock_sync(gnome_keyring).unlocked[0]

for item in unlocked_keyring.get_items():
if item.get_label() == "Chrome Safe Storage":
item.load_secret_sync()
my_pass = item.get_secret().get_text()
break

else:
my_pass = 'peanuts'
unlocked_keyrings = service.unlock_sync(gnome_keyring).unlocked

for unlocked_keyring in unlocked_keyrings:
for item in unlocked_keyring.get_items():
if item.get_label() == "Chrome Safe Storage":
item.load_secret_sync()
my_pass = item.get_secret().get_text()
break
else:
# Inner loop didn't `break`, keep looking
continue

# Inner loop did `break`, so `break` outer loop
break

iterations = 1
cookie_file = cookie_file or os.path.expanduser(
Expand Down

0 comments on commit c55c9c7

Please sign in to comment.