How to reset the local admin password of a Hyper-V VM

Do you ever get that sinking feeling, when you’ve forgotten the root password to your test lab?  Again?

I hate it too!  So I decided to figure out a way around it, using an work around.

Reboot your VM with your Windows OS or Server install disc.  Any version will work.

Image

Hit Shift+F10 for a command prompt.

Image

Next, browse to your windows\system32 directory.  We’re going to make a copy of utilman.exe and replace the original binary with a copy of CMD.exe.  This will allow us to use an ages-old trick to launch a command prompt as the System account from the logon screen.

Image

Once completed, restart the system.

Image

At this point, clicking the Accessibility Icon in the bottom-left hand corner, or hitting left-shift 5 times will call the UtilMan.exe, which we earlier replaced with cmd.exe. This means you now have access to a system authority level account without needing to logon!  You can have a lot of fun with this.  More on that later.

Image

We are now just a few short steps away from a localadmin account.

The quickest way to do this is to create an account:

net user /add localadmin Dr0wssap!

Now give the account privilege.

net localgroup administrators localadmin /add

Image

Now simply logon with these credentials.

Image

To save on keystrokes, you can use .\ notation to log on to the local system.

Image

And you’re in!

From here, you can use other means to reset your domain accounts to gain access to your lab again.

As I mentioned earlier, the ability to launch a privileged command prompt at the logon screen allows for some curious behavior.  For instance, if you call Explorer.exe, very interesting things happen.  Not as much fun on Windows Server 2012 or Windows 8.  On Server 2008 or Windows 7, you can have the Start Bar and desktop display over top of the logon screen!

Here is an example of a similar situation, launching Explorer while a Task Sequence is running.

Image

This is also a potent security risk.  It is a reminder of why we always maintain physical control of our servers and encrypt our VM Virtual Hard Drives.  With the new ease of cloning Domain Controllers as VMs, someone might potentially attempt this on a domain controller.  If they are able to log on as the Local System or local Admin account to a DC, there is opportunity for mischief.

I hope this post will be helpful to others.

Advertisements

4 thoughts on “How to reset the local admin password of a Hyper-V VM

  1. William Hardin November 8, 2013 / 6:02 pm

    This is a super handy alternative to the Linux boot disc password recovery method! Me gusta! 🙂
    -Rex

    • FoxDeploy November 14, 2013 / 8:55 pm

      Happy to help! When I realized how easy this approach was, I became very paranoid about making sure access to my VHDs is as restricted as allowable.

  2. David February 21, 2014 / 12:53 pm

    It’s awful! But I don’t know how to get your trick to work become I am using the Microsoft account sign-in option. Eventually I unlocked my laptop with PCUnlocker Live CD, a paid tool that supports Microsoft account password reset.

    • FoxDeploy February 21, 2014 / 1:31 pm

      In that scenario, you would setup an additional local account using net user temp, then net localgroup administrators temp /add

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s