Last active
December 8, 2020 19:53
-
-
Save jalbam/a24edff03fee1241e98dce8c86f8968e to your computer and use it in GitHub Desktop.
Revisions
-
jalbam revised this gist
Dec 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ ' Visual Basic Script (VBS) which asks for the password, being masked (not displaying typed characters), and stores it into a variable (working on Windows 10). ' * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/a24edff03fee1241e98dce8c86f8968e ' Asks for the password: Set WshShell = CreateObject("WScript.Shell") -
jalbam revised this gist
Dec 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ' Visual Basic Script (VBS) which asks for the password, being masked (not displaying typed characters), and stores it into a variable (working on Windows 10). ' * Author: Joan Alba Maldonado ' Asks for the password: -
jalbam created this gist
Dec 8, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ ' Visual Basic Script which asks for the password, being masked (not displaying typed characters), and stores it into a variable (working on Windows 10). ' * Author: Joan Alba Maldonado ' Asks for the password: Set WshShell = CreateObject("WScript.Shell") powerShellCommand = "powershell -noprofile -command " & _ "$passwordEncrypted = Read-Host -assecurestring ""Please, enter your password"";" & _ "$passwordBinary = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($passwordEncrypted);" & _ "$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($passwordBinary);" & _ "write-output $password" Set executor = WshShell.Exec(powerShellCommand) executor.StdIn.Close typedPassword = executor.StdOut.ReadAll Call WshShell.Run("powershell -noprofile -command Remove-Variable -Name * -ErrorAction SilentlyContinue", 0, TRUE) ' Removes carriage return or new line invisible characters (if any): If (Right(typedPassword, 2) = vbCrLf OR Right(typedPassword, 2) = vbNewLine) Then typedPassword = Left(typedPassword, Len(typedPassword) - 2) End If ' Shows the password typed: ' * NOTE: instead of doing this, do whatever you want with the password stored in 'typedPassword'. WScript.Echo "[" & typedPassword & "]"