问题
I need to get the password from the user that is logged on on Windows. I need this information as string for a Windows Forms application. is there any way of doing that with LDAP, SSO, external dll or similar? Thanks a lot!
回答1:
Windows does not store the password as plain text. The password is stored hashed with NTLMv2 and therefor highly encrypted. It is not possible to reverse engineer that password or get it.
As Lucax said it would be a huge security issue if every program could read the password because it would enable every application (also viruses or trojans) to read the passwords of every user.
回答2:
You can ask the user. If you have a legitimate use, they'll surely comply.
That's about the only way, unless you try digging into security leaks in the system and its applications. For the most part, passwords are stored in an irreversible format, so the only point when they actually exist in memory is when the user is typing them in.
You can authenticate as the user, under certain circumstances - which may be quite enough to achieve what you're trying to do. However, there's little point going deeper into these when we don't know what you're actually trying to do.
来源:https://stackoverflow.com/questions/50527810/get-windows-user-password-in-a-windows-forms-application