Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to extract passwords from all user contexts (Linux) #125

Merged
merged 11 commits into from
May 23, 2017

Conversation

alxchk
Copy link
Contributor

@alxchk alxchk commented May 23, 2017

#121

I don't have all those software to check that something wasn't broken, but looks like most works ok. To feel the difference try to run as root on PC with running user sessions

@AlessandroZ
Copy link
Owner

Awesome work !!! Thanks a lot.

@AlessandroZ AlessandroZ merged commit c4ef71d into AlessandroZ:master May 23, 2017
@AlessandroZ
Copy link
Owner

I have added a missing tab to retrieve all profiles on firefox (here).

And I have an error running the wallet module with sudo:

sudo python laZagne.py wallet -g

raceback (most recent call last):
  File "laZagne.py", line 146, in launch_module
    pwdFound = module[i].run(i.capitalize())	# run the module
  File "/home/me/Linux/lazagne/softwares/wallet/libsecret.py", line 22, in run
    for session in homes.sessions():
  File "/home/me/Linux/lazagne/config/homes.py", line 79, in sessions
    previous = os.environ['DBUS_SESSION_BUS_ADDRESS']
  File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'DBUS_SESSION_BUS_ADDRESS'

The problem is that DBUS_SESSION_BUS_ADDRESS is in environ but not in os.environ.

So if replace every os.environ by environ or the contrary, it works without errors but not passwords were found. I don't know if you managed to retrieved passwords from wallets when sudo.

Thanks again for your work.

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

To be able to access dbus seteuid to the user should be done. I'll check what is wrong with sudo

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

alxchk@26c1bba

I have no issues with sudo. Check that you have secretstorage installed for root user

@AlessandroZ
Copy link
Owner

I don't understand how it could work with sudo for wallets (at least on gnome and kde) because I had added a verification line to not run the tool with sudo (gnome and kde).

For libsecrets, I have this error which is produced here (the error is catched by the except line so it's not a blocking point but no passwords are retrieved from this module).

The '/org/freedesktop/secrets/aliases/default' object does not exist
The '/org/freedesktop/secrets/aliases/default' object does not exist
The '/org/freedesktop/secrets/aliases/default' object does not exist
The '/org/freedesktop/secrets/aliases/default' object does not exist

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

Well, I don't know how gnome/kde works (don't use DEs for years), and didn't add enumeration for these modules. So enumeration (should) work just for libsecrets.
For libsecrets it tries to connect to user's session bus. So if you can retrieve passwords from user context and can't from root, then there may be several cases which may be debugged.

  1. homes.sessions couldn't find proper dbus address.
  2. for some strange reason dbus denies requests from the process.
  3. for some strange reason libsecrets can't retrieve passwords from valid context.

You can try to check with strace where you connect when extraction is successful and compare to addresses which extracted by homes.session. Messages about 'object does not exist' comes from valid dbus session daemons which are not connected to desktop session with secrets provider.
What distribution do you use?

@AlessandroZ
Copy link
Owner

Ok I will investigate it on these possible errors when I will have some time.

Here is my distribution:

Distributor ID:	Ubuntu
Description:	Ubuntu 15.10
Release:	15.10
Codename:	wily

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

I can reproduce but it's a bit non-trivial case. Will look into it deeper once have some time

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

Well, situation is a bit sad. The situation is sad because dbus is shit and was written by shit masters. Looks like user session initialized only once after library load.

@alxchk
Copy link
Contributor Author

alxchk commented May 24, 2017

Please try my latest head - alxchk@d499805

@AlessandroZ
Copy link
Owner

AlessandroZ commented May 24, 2017

Ahaha you make me laugh, I could feel your disappointment :)

The situation is sad because dbus is shit and was written by shit masters.

With your new patch, it works great. It takes a little longer to execute but it works so it's great. Thanks a lot for your contribution.
elapsed time = 22.0574820042

@AlessandroZ
Copy link
Owner

Just to let you now, it takes a bit longer because it receives a timeout response (but then I got all credentials).
Here is the output written on the stdout:

Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

@alxchk
Copy link
Contributor Author

alxchk commented May 25, 2017

I started PR with omitting DBUS connections where secrets are not activated yet. This will be faster, but in theory there is probability that something may be missing (I think it's very unlikely, but maybe that can be checked)

AlessandroZ added a commit that referenced this pull request Aug 14, 2018
Try to extract passwords from all user contexts (Linux)
AlessandroZ added a commit that referenced this pull request Aug 14, 2018
Try to extract passwords from all user contexts (Linux)

Former-commit-id: a941deaacd296483f6e491030a256304d822bd94 [formerly fe64595]
Former-commit-id: 0daa1776712369f5fddfb706235c18b04b99b455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants