Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting user name/password of the logged in user in Windows

Is there any API to get the currently logged in user's name and password in Windows?

Thank you in advance.

like image 527
dennisV Avatar asked Sep 22 '08 07:09

dennisV


People also ask

How can I get another user's password?

Open the Control Panel and go to > User Accounts > User Accounts (click the title again) > Manager another user account > Select the account > Change the password > Enter the new password and select change password.

Where the username and password of User Accounts are stored?

Click Start, and then click Control Panel. In Control Panel, click User Accounts under Pick a category to open the User Accounts dialog box.


3 Answers

For the many commenters who believe it is not possible to reveal the password of the currently logged-in user, see Dump cleartext passwords of logged in user(s) which shows how to use mimikatz to do just that:

mimikatz # privilege::debug
Demande d'ACTIVATION du privilège : SeDebugPrivilege : OK

mimikatz # sekurlsa::logonPasswords full
...
Utilisateur principal       : user
Domaine d'authentification  : domain
        kerberos :
         * Utilisateur  : user
         * Domaine      : domain
         * Mot de passe : pass
like image 93
Miles Wolbe Avatar answered Sep 29 '22 01:09

Miles Wolbe


Password: No, this is not retained for security reasons - it's used, then discarded. You could retrieve the encrypted password for this user from the registry, given sufficient privileges, then decrypt it using something like rainbow tables, but that's extremely resource intensive and time consuming using current methods. Much better to prompt the user.

Alternatively, if you want to implement some sort of 'single signon' system as Novell does, you should do it via either a GINA (pre-Vista) or a Credential Provider (Vista), which will result in your code being given the username and password at login, the only time at which the password is available.

For username, getting the current username (the one who is running your code) is easy: the GetUserName function in AdvApi32.dll does exactly this for you.

If you're running as a service, you need to remember there is no one "logged in user": there are several at any time, such as LocalSystem, NetworkService, SYSTEM and other accounts, in addition to any actual people. This article provides some sample code and documentation for doing that.

like image 29
James Sutherland Avatar answered Sep 29 '22 02:09

James Sutherland


I don't know about the windows login password... but you can definitely pull plaintext passwords from the Credentials Manager. For example here is a program to pull the password for TFS. In most cases, this is the same as the Windows Login.

namespace ShowPassword
{
    using Microsoft.TeamFoundation.Client;
    using System;
    using System.Net;

    class Program
    {
        static void Main(string[] args)
        {
            var tpc = new TfsTeamProjectCollection(new Uri("http://mycompany.com/tfs"));
            var nc = tpc.Credentials as NetworkCredential;
            Console.WriteLine("the password is " + nc.Password);
        }
    }
}

I compiled this as "console" app under vs 2015 with Nuget package TeamFoundation ExtendedClient.

like image 32
John Henckel Avatar answered Sep 29 '22 01:09

John Henckel